vgritsenko 2004/06/16 07:57:54
Modified: src/java/org/apache/cocoon/components/modules/input
PropertiesFileModule.java
SelectMetaInputModule.java XMLFileModule.java
Log:
zap tabs
Revision Changes Path
1.5 +27 -32
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/PropertiesFileModule.java
Index: PropertiesFileModule.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/PropertiesFileModule.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropertiesFileModule.java 5 Mar 2004 13:02:48 -0000 1.4
+++ PropertiesFileModule.java 16 Jun 2004 14:57:54 -0000 1.5
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,43 +32,42 @@
/**
* Input module for accessing properties in a properties file.
- *
+ *
* <p>
* The properties file can only be configured statically and
* is resolved via the SourceResolver system.
* </p>
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
-public class PropertiesFileModule extends AbstractJXPathModule
+public class PropertiesFileModule extends AbstractJXPathModule
implements InputModule, Serviceable, Configurable, ThreadSafe {
-
+
private ServiceManager m_manager;
-
private SourceResolver m_resolver;
-
private Properties m_properties;
-
-
+
+
/* (non-Javadoc)
- * @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ * @see Serviceable#service(ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
m_manager = manager;
m_resolver = (SourceResolver) m_manager.lookup(SourceResolver.ROLE);
}
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- super.dispose();
- if ( this.m_manager != null ) {
- this.m_manager.release( this.m_resolver );
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (this.m_manager != null) {
+ this.m_manager.release(this.m_resolver);
this.m_manager = null;
this.m_resolver = null;
}
- }
+ }
+
/**
* Configure the location of the properties file:
* <p>
@@ -80,7 +79,7 @@
String file = configuration.getChild("file").getAttribute("src");
load(file);
}
-
+
private void load(String file) throws ConfigurationException {
Source source = null;
InputStream stream = null;
@@ -89,28 +88,24 @@
stream = source.getInputStream();
m_properties = new Properties();
m_properties.load(stream);
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new ConfigurationException("Cannot load properties file "
+ file);
- }
- finally {
+ } finally {
if (source != null) {
m_resolver.release(source);
}
if (stream != null) {
try {
stream.close();
- }
- catch (IOException e) {
+ } catch (IOException ignored) {
}
}
}
}
-
+
protected Object getContextObject(Configuration modeConf, Map
objectModel)
- throws ConfigurationException {
-
+ throws ConfigurationException {
+
return m_properties;
}
-
}
1.4 +24 -22
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/SelectMetaInputModule.java
Index: SelectMetaInputModule.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/SelectMetaInputModule.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SelectMetaInputModule.java 28 Apr 2004 18:15:58 -0000 1.3
+++ SelectMetaInputModule.java 16 Jun 2004 14:57:54 -0000 1.4
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@
import org.apache.avalon.framework.thread.ThreadSafe;
/**
- *
+ *
* <h2>Configuration</h2>
* <table><tbody>
* <tr><th>input-module</th>
@@ -45,7 +45,7 @@
* <td></td><td>String</td><td><code>null</code></td>
* </tr>
* </tbody></table>
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @version CVS $Id$
*/
@@ -57,13 +57,12 @@
private String parameter = null;
public SelectMetaInputModule() {
- super();
+ super();
this.defaultInput = null; // not needed
}
-
-
+
/* (non-Javadoc)
- * @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ * @see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
public void configure(Configuration config) throws
ConfigurationException {
@@ -93,6 +92,7 @@
this.otherwise = new ModuleHolder(name, others[i], null);
}
}
+
if (whens != null) {
for (int i = 0; i < whens.length; i++) {
String name = whens[i].getAttribute("name");
@@ -101,23 +101,25 @@
new ModuleHolder(name, whens[i], null));
}
}
-
}
/* (non-Javadoc)
- * @see
org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttribute(String,
Configuration, Map)
*/
- public Object getAttribute(String name, Configuration modeConf, Map
objectModel) throws ConfigurationException {
+ public Object getAttribute(String name, Configuration modeConf, Map
objectModel)
+ throws ConfigurationException {
Object result = this.getAttribute(name, modeConf, objectModel,
false);
return result;
}
- public Object[] getAttributeValues(String name, Configuration modeConf,
Map objectModel) throws ConfigurationException {
+ public Object[] getAttributeValues(String name, Configuration modeConf,
Map objectModel)
+ throws ConfigurationException {
Object result = this.getAttribute(name, modeConf, objectModel, true);
return (result != null ? (Object[]) result : null );
}
-
- private Object getAttribute(String name, Configuration modeConf, Map
objectModel, boolean getValues) throws ConfigurationException {
+
+ private Object getAttribute(String name, Configuration modeConf, Map
objectModel, boolean getValues)
+ throws ConfigurationException {
if (!this.initialized) {
this.lazy_initialize();
}
@@ -198,7 +200,7 @@
} else {
result = (module == null ? null : this.getValue(name,
objectModel, module));
}
-
+
if (needRelease && module != null) {
this.releaseModule(module.input);
}
@@ -209,7 +211,7 @@
}
/* (non-Javadoc)
- * @see
org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
+ * @see
org.apache.avalon.framework.component.Composable#compose(ComponentManager)
*/
public void compose(ComponentManager manager) throws ComponentException {
super.compose(manager);
@@ -240,11 +242,12 @@
* @see
org.apache.cocoon.components.modules.input.AbstractMetaModule#lazy_initialize()
*/
public synchronized void lazy_initialize() {
-
- if (this.initialized) return;
+ if (this.initialized) {
+ return;
+ }
super.lazy_initialize();
-
+
if (this.expression != null) {
this.expression.input = this.obtainModule(this.expression.name);
}
@@ -258,5 +261,4 @@
}
}
}
-
}
1.17 +26 -30
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
Index: XMLFileModule.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XMLFileModule.java 5 Mar 2004 13:02:48 -0000 1.16
+++ XMLFileModule.java 16 Jun 2004 14:57:54 -0000 1.17
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@
</define>
</grammar>
-
+
* This module provides an Input Module interface to any XML document, by
using
* XPath expressions as attribute keys.
* The XML can be obtained from any Cocoon <code>Source</code> (e.g.,
@@ -75,7 +75,7 @@
* src="protocol:path/to/file.xml" reloadable="true"
* cacheable="true"/></code> optionally overriding defaults for
* caching and or reloading.</p>
- *
+ *
* <p>In addition, xpath expressions are cached for higher performance.
* Thus, if an expression has been evaluated for a file, the result
* is cached and will be reused, the expression is not evaluated
@@ -114,7 +114,6 @@
/**
* Takes care of (re-)loading and caching of sources.
- *
*/
protected class DocumentHelper {
@@ -208,19 +207,18 @@
this.resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
}
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- super.dispose();
- if ( this.manager != null ) {
- this.manager.release( this.resolver );
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (this.manager != null) {
+ this.manager.release(this.resolver);
this.manager = null;
this.resolver = null;
}
- }
-
+ }
+
/**
* Static (cocoon.xconf) configuration.
* Configuration is expected to be of the form:
@@ -272,7 +270,6 @@
}
-
/**
* Get the DOM object that JXPath will operate on when evaluating
* attributes. This DOM is loaded from a Source, specified in the
@@ -296,15 +293,15 @@
Configuration fileConf = null; // the nested <file>, if any
if (modeConf != null && modeConf.getChildren().length > 0) {
- fileConf = modeConf.getChild("file", false);
- if (fileConf == null) {
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Missing 'file' child
element at " + modeConf.getLocation());
- }
-
- } else {
- hasDynamicConf = true;
- }
+ fileConf = modeConf.getChild("file", false);
+ if (fileConf == null) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Missing 'file' child element at " +
modeConf.getLocation());
+ }
+
+ } else {
+ hasDynamicConf = true;
+ }
}
if (hasDynamicConf) {
@@ -358,8 +355,8 @@
Object result = this.getAttribute(name, modeConf, objectModel, true);
return (result != null ? (Object[]) result : null);
}
-
-
+
+
public Object getAttribute(String name, Configuration modeConf, Map
objectModel, boolean getValues) throws ConfigurationException {
Object contextObj = getContextObject(modeConf, objectModel);
@@ -433,5 +430,4 @@
}
return cache;
}
-
}