You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2007/10/18 06:43:27 UTC
svn commit: r585863 - in /cocoon/trunk/core:
cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/
cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/
cocoon-site...
Author: vgritsenko
Date: Wed Oct 17 21:43:24 2007
New Revision: 585863
URL: http://svn.apache.org/viewvc?rev=585863&view=rev
Log:
converting tree processor and other components to commons logging
Modified:
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/DefaultsModule.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSource.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSourceFactory.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSourceFactory.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml
cocoon/trunk/core/cocoon-util/src/main/java/org/apache/cocoon/util/avalon/CLLoggerWrapper.java
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/DefaultsModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/DefaultsModule.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/DefaultsModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/DefaultsModule.java Wed Oct 17 21:43:24 2007
@@ -16,18 +16,18 @@
*/
package org.apache.cocoon.components.modules.input;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
* Set a number of constants. To override the values with input from
@@ -45,54 +45,54 @@
* @version $Id$
*/
public class DefaultsModule extends AbstractLogEnabled
- implements InputModule, Configurable, ThreadSafe {
+ implements InputModule, Configurable, ThreadSafe {
- private Map constants = null;
-
- public void configure(Configuration config) throws ConfigurationException {
+ private Map constants;
+
+ public void configure(Configuration config) throws ConfigurationException {
+
this.constants = new HashMap();
Configuration[] consts = config.getChild("values").getChildren();
- for (int i=0; i<consts.length; i++) {
+ for (int i = 0; i < consts.length; i++) {
this.constants.put(consts[i].getName(), consts[i].getValue(""));
}
}
+ public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel )
+ throws ConfigurationException {
- public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel )
- throws ConfigurationException {
-
- String parameter=name;
+ String parameter = name;
Configuration mConf = null;
- if (modeConf!=null) {
- mConf = modeConf.getChild("values");
+ if (modeConf != null) {
+ mConf = modeConf.getChild("values");
}
Object[] values = new Object[1];
- values[0] = (mConf!=null? mConf.getChild(parameter).getValue((String) this.constants.get(parameter))
- : this.constants.get(parameter));
+ values[0] = mConf != null ? mConf.getChild(parameter).getValue((String) this.constants.get(parameter))
+ : this.constants.get(parameter);
return values;
}
public Iterator getAttributeNames( Configuration modeConf, Map objectModel )
- throws ConfigurationException {
+ throws ConfigurationException {
SortedSet matchset = new TreeSet(this.constants.keySet());
- if (modeConf!=null) {
+ if (modeConf != null) {
Configuration[] consts = modeConf.getChild("values").getChildren();
- for (int i=0; i<consts.length; i++)
+ for (int i = 0; i < consts.length; i++)
matchset.add(consts[i].getName());
}
+
return matchset.iterator();
- }
+ }
- public Object getAttribute( String name, Configuration modeConf, Map objectModel )
- throws ConfigurationException {
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel)
+ throws ConfigurationException {
- Object[] values = this.getAttributeValues(name,modeConf,objectModel);
+ Object[] values = this.getAttributeValues(name, modeConf, objectModel);
return values[0];
}
-
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java Wed Oct 17 21:43:24 2007
@@ -22,24 +22,25 @@
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.commons.collections.IteratorUtils;
+
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.processing.ProcessInfoProvider;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
-import org.apache.commons.collections.IteratorUtils;
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
* This module allows access to properties defined in the settings.
*
* @version $Id$
*/
-public final class SettingsInputModule
- extends AbstractLogEnabled
- implements InputModule, ThreadSafe, Serviceable, Disposable {
+public final class SettingsInputModule extends AbstractLogEnabled
+ implements InputModule, ThreadSafe, Serviceable,
+ Disposable {
protected ServiceManager manager;
protected ProcessInfoProvider infoProvider;
@@ -56,7 +57,7 @@
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
public void dispose() {
- if ( this.manager != null ) {
+ if (this.manager != null) {
this.manager.release(this.infoProvider);
this.infoProvider = null;
this.manager = null;
@@ -85,10 +86,11 @@
*/
public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
- Object o = this.getAttribute(name, modeConf, objectModel);
+ Object o = getAttribute(name, modeConf, objectModel);
if (o != null) {
- return new Object[] {o};
+ return new Object[]{o};
}
+
return null;
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSource.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSource.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSource.java Wed Oct 17 21:43:24 2007
@@ -17,27 +17,25 @@
package org.apache.cocoon.components.source.impl;
-import java.io.InputStream;
-import java.io.IOException;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
-
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.impl.AbstractSource;
import org.apache.cocoon.components.modules.input.InputModule;
-import org.apache.commons.jxpath.JXPathContext;
-
-
/**
* A <code>Source</code> that takes its content from a
* module.
@@ -52,29 +50,29 @@
* </ul>
* </p>
*
+ * @version $Id$
*/
-public class ModuleSource
- extends AbstractSource {
+public class ModuleSource extends AbstractSource {
+
+ private static final String SCHEME = "module";
+
+ private final Log logger = LogFactory.getLog(getClass());
- private final static String SCHEME = "module";
private String attributeType;
private String attributeName;
private String xPath;
private ServiceManager manager;
private Map objectModel;
- private Logger logger;
-
+
/**
* Create a module source from a 'module:' uri and a the object model.
* <p>The uri is of the form "module:attribute-type:attribute-name#xpath</p>
*/
- public ModuleSource( Map objectModel, String uri,
- ServiceManager manager, Logger logger )
- throws MalformedURLException {
+ public ModuleSource(Map objectModel, String uri, ServiceManager manager)
+ throws MalformedURLException {
this.objectModel = objectModel;
this.manager = manager;
- this.logger = logger;
setSystemId( uri );
@@ -120,9 +118,9 @@
*
* @throws IOException if I/O error occured.
*/
- public InputStream getInputStream() throws IOException, SourceException {
- if ( this.logger.isDebugEnabled() ) {
- this.logger.debug( "Getting InputStream for " + getURI() );
+ public InputStream getInputStream() throws IOException {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Getting InputStream for " + getURI());
}
Object obj = getInputAttribute( this.attributeType, this.attributeName );
@@ -162,18 +160,19 @@
*
*/
public boolean exists() {
- boolean exists = false;
+ boolean exists;
try {
- exists = getInputAttribute( this.attributeType, this.attributeName ) != null;
- } catch ( SourceException e ) {
+ exists = getInputAttribute(this.attributeType, this.attributeName) != null;
+ } catch (SourceException e) {
exists = false;
}
return exists;
}
private Object getInputAttribute( String inputModuleName, String attributeName )
- throws SourceException {
+ throws SourceException {
Object obj;
+
ServiceSelector selector = null;
InputModule inputModule = null;
try {
@@ -181,15 +180,17 @@
inputModule = (InputModule) selector.select( inputModuleName );
obj = inputModule.getAttribute( attributeName, null, this.objectModel );
- } catch ( ServiceException e ) {
- throw new SourceException( "Could not find an InputModule of the type " +
- inputModuleName , e );
- } catch ( ConfigurationException e ) {
- throw new SourceException( "Could not find an attribute: " + attributeName +
- " from the InputModule " + inputModuleName, e );
+ } catch (ServiceException e) {
+ throw new SourceException("Could not find an InputModule of the type " +
+ inputModuleName, e);
+ } catch (ConfigurationException e) {
+ throw new SourceException("Could not find an attribute: " + attributeName +
+ " from the InputModule " + inputModuleName, e);
} finally {
- if ( inputModule != null ) selector.release( inputModule );
- this.manager.release( selector );
+ if (inputModule != null) {
+ selector.release(inputModule);
+ }
+ this.manager.release(selector);
}
return obj;
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSourceFactory.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSourceFactory.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/ModuleSourceFactory.java Wed Oct 17 21:43:24 2007
@@ -18,29 +18,28 @@
package org.apache.cocoon.components.source.impl;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceFactory;
import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
* A factory for 'module:' sources (see {@link ModuleSource}).
*
+ * @version $Id$
*/
public class ModuleSourceFactory extends AbstractLogEnabled
- implements SourceFactory, Serviceable, Contextualizable, ThreadSafe {
+ implements SourceFactory, Serviceable, Contextualizable, ThreadSafe {
private ServiceManager manager;
private Context context;
@@ -66,18 +65,16 @@
* @param location The URI to resolve - this URI includes the scheme.
* @param parameters this is optional and not used here
*/
- public Source getSource( String location, Map parameters )
- throws IOException, MalformedURLException {
+ public Source getSource(String location, Map parameters) throws IOException {
- Map objectModel = ContextHelper.getObjectModel( this.context );
- return new ModuleSource( objectModel, location, this.manager, getLogger() );
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ return new ModuleSource(objectModel, location, this.manager);
}
-
+
/**
* Release a {@link Source} object.
*/
public void release( Source source ) {
// Do nothing here
}
-
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java Wed Oct 17 21:43:24 2007
@@ -24,10 +24,15 @@
import java.util.Iterator;
import java.util.Map;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.xml.sax.XMLizable;
+
import org.apache.cocoon.Processor;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.components.source.util.SourceUtil;
@@ -37,14 +42,10 @@
import org.apache.cocoon.environment.internal.EnvironmentHelper;
import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.xml.ContentHandlerWrapper;
import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceException;
-import org.apache.excalibur.source.SourceNotFoundException;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.xml.sax.XMLizable;
+
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
@@ -55,9 +56,8 @@
*
* @version $Id$
*/
-public final class SitemapSource
- extends AbstractLogEnabled
- implements Source, XMLizable {
+public final class SitemapSource extends AbstractLogEnabled
+ implements Source, XMLizable {
/** The internal event pipeline validities */
private SitemapSourceValidity validity;
@@ -108,8 +108,7 @@
*/
public SitemapSource(ServiceManager manager,
String uri,
- Map parameters,
- Logger logger)
+ Map parameters)
throws MalformedURLException {
Environment env = EnvironmentHelper.getCurrentEnvironment();
@@ -117,7 +116,6 @@
throw new MalformedURLException("The cocoon protocol can not be used outside an environment.");
}
this.manager = manager;
- this.enableLogging(logger);
SitemapSourceInfo info = SitemapSourceInfo.parseURI(env, uri);
this.protocol = info.protocol;
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java Wed Oct 17 21:43:24 2007
@@ -17,19 +17,18 @@
package org.apache.cocoon.components.source.impl;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.Map;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceFactory;
-import org.apache.excalibur.source.URIAbsolutizer;
import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.URIAbsolutizer;
+
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
* This class implements the cocoon: protocol.
@@ -38,53 +37,47 @@
*
* @version $Id$
*/
-public final class SitemapSourceFactory
- extends AbstractLogEnabled
- implements SourceFactory, ThreadSafe, Serviceable, URIAbsolutizer
-{
+public final class SitemapSourceFactory extends AbstractLogEnabled
+ implements SourceFactory, ThreadSafe, Serviceable,
+ URIAbsolutizer {
/** The <code>ServiceManager</code> */
private ServiceManager manager;
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ /**
+ * @see Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
}
- /* (non-Javadoc)
- * @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
+ /**
+ * @see SourceFactory#getSource(java.lang.String, java.util.Map)
*/
- public Source getSource( String location, Map parameters )
- throws MalformedURLException, IOException {
- if( getLogger().isDebugEnabled() ) {
- getLogger().debug( "Creating source object for " + location );
+ public Source getSource(String location, Map parameters) throws IOException {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Creating source object for " + location);
}
- return new SitemapSource( this.manager,
- location,
- parameters,
- getLogger());
+ return new SitemapSource(this.manager, location, parameters);
}
-
- /* (non-Javadoc)
- * @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
+
+ /**
+ * @see SourceFactory#release(org.apache.excalibur.source.Source)
*/
- public void release( Source source ) {
- if ( null != source ) {
- if ( this.getLogger().isDebugEnabled() ) {
- this.getLogger().debug("Releasing source " + source.getURI());
+ public void release(Source source) {
+ if (source != null) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Releasing source " + source.getURI());
}
- ((SitemapSource)source).recycle();
+ ((SitemapSource) source).recycle();
}
}
- /* (non-Javadoc)
- * @see org.apache.excalibur.source.URIAbsolutizer#absolutize(java.lang.String, java.lang.String)
+ /**
+ * @see URIAbsolutizer#absolutize(java.lang.String, java.lang.String)
*/
public String absolutize(String baseURI, String location) {
return SourceUtil.absolutize(baseURI, location, true);
}
-
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java Wed Oct 17 21:43:24 2007
@@ -17,20 +17,21 @@
package org.apache.cocoon.components.source.impl;
-import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
-
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.excalibur.source.ModifiableSource;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.impl.AbstractSource;
@@ -44,11 +45,8 @@
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.apache.cocoon.xml.dom.DOMStreamer;
-import org.apache.commons.jxpath.JXPathContext;
-
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -68,18 +66,20 @@
* </ul>
* </p>
*
+ * @version $Id$
*/
-public class XModuleSource
- extends AbstractSource
- implements ModifiableSource, XMLizable, DOMBuilder.Listener {
+public class XModuleSource extends AbstractSource
+ implements ModifiableSource, XMLizable, DOMBuilder.Listener {
+
+ private static final String SCHEME = "xmodule";
+
+ private final Log logger = LogFactory.getLog(getClass());
- private final static String SCHEME = "xmodule";
private String attributeType;
private String attributeName;
private String xPath;
protected ServiceManager manager;
private Map objectModel;
- private Logger logger;
// TODO: make this actually configurable
private String configuredSerializerName = "xml";
@@ -87,13 +87,11 @@
* Create a xmodule source from a 'xmodule:' uri and a the object model.
* <p>The uri is of the form "xmodule:/attribute-type/attribute-name/xpath</p>
*/
- public XModuleSource( Map objectModel, String uri,
- ServiceManager manager, Logger logger )
- throws MalformedURLException {
+ public XModuleSource(Map objectModel, String uri, ServiceManager manager)
+ throws MalformedURLException {
this.objectModel = objectModel;
this.manager = manager;
- this.logger = logger;
setSystemId( uri );
@@ -180,9 +178,9 @@
*
* @throws IOException if I/O error occured.
*/
- public InputStream getInputStream() throws IOException, SourceException {
- if ( this.logger.isDebugEnabled() ) {
- this.logger.debug( "Getting InputStream for " + getURI() );
+ public InputStream getInputStream() throws IOException {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Getting InputStream for " + getURI());
}
// Serialize the SAX events to the XMLSerializer
@@ -218,10 +216,10 @@
*
*/
public boolean exists() {
- boolean exists = false;
+ boolean exists;
try {
- exists = getInputAttribute( this.attributeType, this.attributeName ) != null;
- } catch ( SAXException e ) {
+ exists = getInputAttribute(this.attributeType, this.attributeName) != null;
+ } catch (SAXException e) {
exists = false;
}
return exists;
@@ -242,24 +240,24 @@
* Delete the source
*/
public void delete() throws SourceException {
- if ( !(this.xPath.length() == 0 || this.xPath.equals( "/" )) ) {
+ if (!(this.xPath.length() == 0 || this.xPath.equals("/"))) {
Object value;
try {
- value = getInputAttribute( this.attributeType, this.attributeName );
- } catch ( SAXException e ) {
- throw new SourceException( "delete: ", e );
+ value = getInputAttribute(this.attributeType, this.attributeName);
+ } catch (SAXException e) {
+ throw new SourceException("delete: ", e);
}
- if ( value == null )
- throw new SourceException( " The attribute: " + this.attributeName +
- " is empty" );
+ if (value == null)
+ throw new SourceException(" The attribute: " + this.attributeName +
+ " is empty");
- JXPathContext context = JXPathContext.newContext( value );
- context.removeAll( this.xPath );
+ JXPathContext context = JXPathContext.newContext(value);
+ context.removeAll(this.xPath);
} else {
try {
- setOutputAttribute( this.attributeType, this.attributeName, null );
- } catch ( SAXException e ) {
- throw new SourceException( "delete: ", e );
+ setOutputAttribute(this.attributeType, this.attributeName, null);
+ } catch (SAXException e) {
+ throw new SourceException("delete: ", e);
}
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSourceFactory.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSourceFactory.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSourceFactory.java Wed Oct 17 21:43:24 2007
@@ -24,23 +24,24 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceFactory;
import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
* A factory for 'xmodule:' sources (see {@link XModuleSource}).
*
+ * @version $Id$
*/
public class XModuleSourceFactory extends AbstractLogEnabled
- implements SourceFactory, Serviceable, Contextualizable, ThreadSafe {
+ implements SourceFactory, Serviceable, Contextualizable,
+ ThreadSafe {
private ServiceManager manager;
private Context context;
@@ -59,24 +60,22 @@
this.context = context;
}
-
/**
* Get a {@link XModuleSource} object.
*
* @param location The URI to resolve - this URI includes the scheme.
* @param parameters this is optional and not used here
*/
- public Source getSource( String location, Map parameters )
- throws IOException, MalformedURLException {
+ public Source getSource(String location, Map parameters) throws IOException {
- Map objectModel = ContextHelper.getObjectModel( this.context );
- return new XModuleSource( objectModel, location, this.manager, getLogger() );
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ return new XModuleSource(objectModel, location, this.manager);
}
-
+
/**
* Release a {@link Source} object.
*/
- public void release( Source source ) {
+ public void release(Source source) {
// Do nothing here
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java Wed Oct 17 21:43:24 2007
@@ -23,10 +23,10 @@
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.commons.collections.iterators.EmptyIterator;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.util.HashMap;
-import org.apache.commons.collections.iterators.EmptyIterator;
/**
* AbstractInputModule gives you the infrastructure for easily
@@ -35,9 +35,8 @@
*
* @version $Id$
*/
-public abstract class AbstractInputModule
- extends AbstractLogEnabled
- implements InputModule, Configurable, Disposable {
+public abstract class AbstractInputModule extends AbstractLogEnabled
+ implements InputModule, Configurable, Disposable {
/**
* Stores (global) configuration parameters as <code>key</code> /
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java Wed Oct 17 21:43:24 2007
@@ -16,18 +16,18 @@
*/
package org.apache.cocoon.components.modules.output;
+import java.util.Map;
+
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.util.HashMap;
-import java.util.Map;
-
/**
* AbstractOutputModule gives you the infrastructure for easily
* deploying more output modules.
@@ -37,7 +37,7 @@
* @version $Id$
*/
public abstract class AbstractOutputModule extends AbstractLogEnabled
- implements OutputModule, Configurable, Disposable {
+ implements OutputModule, Configurable, Disposable {
/**
* Stores (global) configuration parameters as <code>key</code> /
@@ -118,11 +118,8 @@
final Request request = ObjectModelHelper.getRequest(objectModel);
Map map = (Map) request.getAttribute(trans_place);
- if (map == null) {
- return false;
- }
+ return map != null && map.containsKey(name);
- return map.containsKey(name);
}
/**
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java Wed Oct 17 21:43:24 2007
@@ -16,12 +16,14 @@
*/
package org.apache.cocoon.components.treeprocessor;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.cocoon.sitemap.ExecutionContext;
import org.apache.cocoon.sitemap.SitemapExecutor;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.util.location.Location;
/**
+ * Base class for ProcessingNode implementations.
+ *
* @version $Id$
*/
public abstract class AbstractProcessingNode extends AbstractLogEnabled
@@ -36,12 +38,11 @@
protected SitemapExecutor executor;
- public AbstractProcessingNode(String type) {
- this.componentName = type;
+ public AbstractProcessingNode() {
}
- public AbstractProcessingNode() {
- this(null);
+ public AbstractProcessingNode(String type) {
+ this.componentName = type;
}
/**
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java Wed Oct 17 21:43:24 2007
@@ -18,9 +18,10 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceManager;
+
import org.apache.cocoon.core.container.spring.avalon.AvalonUtils;
+import org.apache.cocoon.util.AbstractLogEnabled;
/**
*
@@ -34,11 +35,11 @@
protected ServiceManager manager;
/**
- * @see org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder#setBuilder(org.apache.cocoon.components.treeprocessor.TreeBuilder)
+ * @see ProcessingNodeBuilder#setBuilder(TreeBuilder)
*/
public void setBuilder(TreeBuilder treeBuilder) {
this.treeBuilder = treeBuilder;
- this.manager = (ServiceManager)treeBuilder.getWebApplicationContext().getBean(AvalonUtils.SERVICE_MANAGER_ROLE);
+ this.manager = (ServiceManager) treeBuilder.getWebApplicationContext().getBean(AvalonUtils.SERVICE_MANAGER_ROLE);
}
/**
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Wed Oct 17 21:43:24 2007
@@ -24,8 +24,11 @@
import java.util.Map;
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceManager;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Processor;
import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
@@ -44,11 +47,9 @@
import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
import org.apache.cocoon.sitemap.SitemapExecutor;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.LocationImpl;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.web.context.WebApplicationContext;
/**
* The concrete implementation of {@link Processor}, containing the evaluation tree and associated
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java Wed Oct 17 21:43:24 2007
@@ -30,7 +30,6 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
@@ -38,21 +37,19 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
/**
* This is the selector used to select/create node builders.
*
* @version $Id$
* @since 2.2
*/
-public class NodeBuilderSelector
- extends AbstractLogEnabled
- implements Serviceable,
- Configurable,
- Initializable,
- Contextualizable {
+public class NodeBuilderSelector extends AbstractLogEnabled
+ implements Serviceable, Configurable, Initializable,
+ Contextualizable {
- /** The application context for components
- */
+ /** The application context for components */
protected ServiceManager serviceManager;
/** The application context for components */
@@ -64,45 +61,31 @@
/** All singletons. */
protected final Map singletons = Collections.synchronizedMap(new HashMap());
+ protected static class BuilderInfo {
+ public Configuration configuration;
+ public Class builderClass;
+ }
+
+
/**
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ * @see Contextualizable#contextualize(Context)
*/
- public void contextualize( final Context avalonContext ) {
+ public void contextualize(final Context avalonContext) {
this.context = avalonContext;
}
/**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ * @see Serviceable#service(ServiceManager)
*/
- public void service( final ServiceManager componentManager )
+ public void service(final ServiceManager componentManager)
throws ServiceException {
this.serviceManager = componentManager;
}
- public Object getBuilder( String name )
- throws Exception {
- Object component = this.singletons.get(name);
- if ( component == null ) {
- final BuilderInfo info = (BuilderInfo)this.componentInfos.get( name );
-
- // Retrieve the instance of the requested component
- if( null == info ) {
- throw new Exception( "Node builder selector could not find builder for key [" + name + "]" );
- }
- try {
- component = this.createComponent(info);
- } catch (Exception e) {
- throw new Exception("Unable to create new builder: " + name, e);
- }
- }
-
- return component;
- }
-
/**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ * @see Configurable#configure(Configuration)
*/
- public void configure( final Configuration config )
+ public void configure(final Configuration config)
throws ConfigurationException {
final Configuration[] instances = config.getChildren();
for (int i = 0; i < instances.length; i++) {
@@ -110,64 +93,77 @@
final String name = instance.getAttribute("name").trim();
final String className = instance.getAttribute("builder").trim();
try {
- if( this.getLogger().isDebugEnabled() ) {
- this.getLogger().debug( "Adding builder (" + name + " = " + className + ")" );
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Adding builder (" + name + " = " + className + ")");
}
- final Class clazz = this.getClass().getClassLoader().loadClass( className );
+ final Class clazz = getClass().getClassLoader().loadClass(className);
final BuilderInfo info = new BuilderInfo();
info.builderClass = clazz;
info.configuration = instance;
- this.componentInfos.put( name, info );
-
- } catch( final ClassNotFoundException cnfe ) {
- final String message = "Could not get class (" + className + ") for builder "
- + name + " at " + instance.getLocation();
+ this.componentInfos.put(name, info);
- throw new ConfigurationException( message, cnfe );
- } catch( final Exception e ) {
+ } catch (final ClassNotFoundException cnfe) {
+ final String message = "Could not get class (" + className + ") for builder " + name + " at " +
+ instance.getLocation();
+ throw new ConfigurationException(message, cnfe);
+ } catch (final Exception e) {
final String message = "Unexpected exception when setting up builder " + name + " at " + instance.getLocation();
- throw new ConfigurationException( message, e );
- }
+ throw new ConfigurationException(message, e);
+ }
+ }
+ }
+
+ /**
+ * @see Initializable#initialize()
+ */
+ public void initialize()
+ throws Exception {
+ final Iterator i = this.componentInfos.entrySet().iterator();
+ while (i.hasNext()) {
+ final Map.Entry entry = (Map.Entry) i.next();
+ final BuilderInfo info = (BuilderInfo) entry.getValue();
+ if (ThreadSafe.class.isAssignableFrom(info.builderClass)) {
+ this.singletons.put(entry.getKey(), this.createComponent(info));
+ }
}
}
+ public Object getBuilder(String name)
+ throws Exception {
+ Object component = this.singletons.get(name);
+ if (component == null) {
+ final BuilderInfo info = (BuilderInfo) this.componentInfos.get(name);
+ if (info == null) {
+ throw new Exception("Node builder selector could not find builder for key [" + name + "]");
+ }
+
+ // Retrieve the instance of the requested component
+ try {
+ component = createComponent(info);
+ } catch (Exception e) {
+ throw new Exception("Unable to create new builder: " + name, e);
+ }
+ }
+
+ return component;
+ }
+
/**
* Create a new component.
*/
protected Object createComponent(BuilderInfo info)
throws Exception {
final Object component = info.builderClass.newInstance();
- ContainerUtil.enableLogging(component, this.getLogger());
ContainerUtil.contextualize(component, this.context);
ContainerUtil.service(component, this.serviceManager);
ContainerUtil.configure(component, info.configuration);
- if ( component instanceof Parameterizable ) {
+ if (component instanceof Parameterizable) {
ContainerUtil.parameterize(component, Parameters.fromConfiguration(info.configuration));
}
ContainerUtil.initialize(component);
return component;
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize()
- throws Exception {
- final Iterator i = this.componentInfos.entrySet().iterator();
- while ( i.hasNext() ) {
- final Map.Entry entry = (Map.Entry)i.next();
- final BuilderInfo info = (BuilderInfo)entry.getValue();
- if ( ThreadSafe.class.isAssignableFrom( info.builderClass ) ) {
- this.singletons.put(entry.getKey(), this.createComponent(info));
- }
- }
- }
-
- protected static class BuilderInfo {
- public Configuration configuration;
- public Class builderClass;
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Wed Oct 17 21:43:24 2007
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.net.URL;
-
import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
@@ -32,27 +31,27 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.NamespacedSAXConfigurationHandler;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.regexp.RE;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Processor;
import org.apache.cocoon.components.flow.Interpreter;
-import org.apache.cocoon.components.source.util.SourceUtil;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
+import org.apache.cocoon.components.source.util.SourceUtil;
import org.apache.cocoon.components.treeprocessor.sitemap.FlowNode;
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
import org.apache.cocoon.sitemap.SitemapExecutor;
import org.apache.cocoon.sitemap.impl.DefaultExecutor;
-//TODO rcl
-//import org.apache.commons.jci.listeners.NotificationListener;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.regexp.RE;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
import org.xml.sax.SAXException;
/**
@@ -63,7 +62,8 @@
public class TreeProcessor extends AbstractLogEnabled
implements ThreadSafe, Processor, Serviceable,
Configurable,
- Disposable, Initializable { // TODO rcl ,NotificationListener {
+ Disposable, Initializable {
+ // TODO: RCL: implement NotificationListener
/** The parent TreeProcessor, if any */
protected TreeProcessor parent;
@@ -135,7 +135,6 @@
String prefix)
throws Exception {
this.parent = parent;
- enableLogging(parent.getLogger());
// Copy all that can be copied from the parent
this.source = sitemapSource;
@@ -406,7 +405,7 @@
Configuration sitemapProgram = createSitemapProgram(this.source);
newLastModified = this.source.getLastModified();
- newProcessor = createConcreteTreeProcessor();
+ newProcessor = new ConcreteTreeProcessor(this, this.sitemapExecutor);
// Get the treebuilder that can handle this version of the sitemap.
TreeBuilder treeBuilder = getTreeBuilder(sitemapProgram);
@@ -446,12 +445,6 @@
// Switch to the new processor (ensure it's never temporarily null)
this.concreteProcessor = newProcessor;
this.lastModified = newLastModified;
- }
-
- private ConcreteTreeProcessor createConcreteTreeProcessor() {
- ConcreteTreeProcessor newProcessor = new ConcreteTreeProcessor(this, this.sitemapExecutor);
- setupLogger(newProcessor);
- return newProcessor;
}
/**
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java Wed Oct 17 21:43:24 2007
@@ -19,6 +19,7 @@
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
@@ -72,7 +73,7 @@
/**
* The component manager is used to create error pipelines
*/
- public void service(ServiceManager manager) {
+ public void service(ServiceManager manager) throws ServiceException {
this.errorHandlerHelper.service(manager);
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java Wed Oct 17 21:43:24 2007
@@ -17,6 +17,7 @@
package org.apache.cocoon.components.treeprocessor.sitemap;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
@@ -51,7 +52,7 @@
* Keep the component manager used everywhere in the tree so that we can
* cleanly dispose it.
*/
- public void service(ServiceManager manager) {
+ public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
this.errorHandlerHelper.service(manager);
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Wed Oct 17 21:43:24 2007
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.servlet.ServletContext;
import org.apache.avalon.excalibur.pool.Recyclable;
@@ -39,10 +38,16 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.commons.lang.StringUtils;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.regexp.RE;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.web.context.WebApplicationContext;
+
import org.apache.cocoon.Constants;
import org.apache.cocoon.classloader.reloading.Monitor;
import org.apache.cocoon.components.LifecycleHelper;
@@ -69,24 +74,19 @@
import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
import org.apache.cocoon.sitemap.PatternException;
import org.apache.cocoon.sitemap.SitemapParameters;
+import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.LocationImpl;
import org.apache.cocoon.util.location.LocationUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.regexp.RE;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.web.context.WebApplicationContext;
/**
* The tree builder for the sitemap language.
*
* @version $Id$
*/
-public class SitemapLanguage
- extends AbstractLogEnabled
- implements TreeBuilder, Contextualizable, Serviceable, Recyclable {
+public class SitemapLanguage extends AbstractLogEnabled
+ implements TreeBuilder, Contextualizable, Serviceable,
+ Recyclable {
// Regexp's for splitting expressions
private static final String COMMA_SPLIT_REGEXP = "[\\s]*,[\\s]*";
@@ -361,7 +361,7 @@
this.itsComponentInfo = (PipelineComponentInfo) this.itsManager.lookup(PipelineComponentInfo.ROLE);
// Create a helper object to setup components
- this.itsLifecycle = new LifecycleHelper(getLogger(), itsContext, this.itsManager, null /* configuration */);
+ this.itsLifecycle = new LifecycleHelper(null /* logger */, itsContext, this.itsManager, null /* configuration */);
// Create & initialize the NodeBuilder selector.
{
@@ -381,13 +381,20 @@
resolver.release(src);
}
} catch (Exception e) {
- throw new ConfigurationException("Could not load TreeBuilder configuration from "
- + url, e);
+ throw new ConfigurationException("Could not load TreeBuilder configuration from " +
+ url, e);
} finally {
this.manager.release(resolver);
}
- LifecycleHelper.setupComponent(selector, getLogger(), itsContext, this.itsManager,
- config.getChild("nodes", false), true);
+
+ // ContainerUtil.contextualize(selector, itsContext);
+ // ContainerUtil.service(selector, this.itsManager);
+ // ContainerUtil.configure(selector, config.getChild("nodes", false));
+ // ContainerUtil.initialize(selector);
+ LifecycleHelper.setupComponent(selector,
+ null /* logger */, itsContext, this.itsManager,
+ config.getChild("nodes", false), true);
+
this.itsBuilders = selector;
}
@@ -606,21 +613,19 @@
* Register all registered sitemap listeners
*/
protected void registerListeners() {
- if ( this.itsContainer instanceof ListableBeanFactory ) {
- final ListableBeanFactory listableFactory = (ListableBeanFactory)this.itsContainer;
- Map beans = listableFactory.getBeansOfType(EnterSitemapEventListener.class);
- if ( beans != null ) {
- final Iterator i = beans.values().iterator();
- while ( i.hasNext() ) {
- this.enterSitemapEventListeners.add(i.next());
- }
+ final ListableBeanFactory listableFactory = this.itsContainer;
+ Map beans = listableFactory.getBeansOfType(EnterSitemapEventListener.class);
+ if ( beans != null ) {
+ final Iterator i = beans.values().iterator();
+ while ( i.hasNext() ) {
+ this.enterSitemapEventListeners.add(i.next());
}
- beans = listableFactory.getBeansOfType(LeaveSitemapEventListener.class);
- if ( beans != null ) {
- final Iterator i = beans.values().iterator();
- while ( i.hasNext() ) {
- this.leaveSitemapEventListeners.add(i.next());
- }
+ }
+ beans = listableFactory.getBeansOfType(LeaveSitemapEventListener.class);
+ if ( beans != null ) {
+ final Iterator i = beans.values().iterator();
+ while ( i.hasNext() ) {
+ this.leaveSitemapEventListeners.add(i.next());
}
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java Wed Oct 17 21:43:24 2007
@@ -460,13 +460,12 @@
}
if ( includeURI != null ) {
- Resource src = null;
try {
- src = this.resolver.getResource(this.getUrl(includeURI, contextURI));
-
- this.loadURI(src, loadedURIs, includeStatement);
+ Resource src = this.resolver.getResource(getUrl(includeURI, contextURI));
+ loadURI(src, loadedURIs, includeStatement);
} catch (Exception e) {
- throw new ConfigurationException("Cannot load '" + includeURI + "' at " + includeStatement.getLocation(), e);
+ throw new ConfigurationException("Cannot load '" + includeURI + "' at " +
+ includeStatement.getLocation(), e);
}
} else {
@@ -509,7 +508,7 @@
this.logger.debug("Loading configuration: " + uri);
}
// load it and store it in the read set
- Configuration includeConfig = null;
+ Configuration includeConfig;
try {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(true);
includeConfig = builder.build(src.getInputStream(), uri);
@@ -528,7 +527,7 @@
this.configureRoles(includeConfig);
} else {
throw new ConfigurationException("Unknow document '" + includeKind + "' included at " +
- includeStatement.getLocation());
+ includeStatement.getLocation());
}
}
}
@@ -555,14 +554,12 @@
}
if (includeURI != null) {
- Resource src = null;
try {
- src = this.resolver.getResource(this.getUrl(includeURI, contextURI));
-
- this.configInfo.addImport(this.getUrl(src));
+ Resource src = this.resolver.getResource(getUrl(includeURI, contextURI));
+ this.configInfo.addImport(getUrl(src));
} catch (Exception e) {
- throw new ConfigurationException("Cannot load '" + includeURI + "' at "
- + includeStatement.getLocation(), e);
+ throw new ConfigurationException("Cannot load '" + includeURI + "' at " +
+ includeStatement.getLocation(), e);
}
} else {
@@ -583,8 +580,9 @@
+ directoryURI);
}
} else {
- if ( !includeStatement.getAttributeAsBoolean("optional", false) ) {
- throw new ConfigurationException("Directory '" + directoryURI + "' does not exist (" + includeStatement.getLocation() + ").");
+ if (!includeStatement.getAttributeAsBoolean("optional", false)) {
+ throw new ConfigurationException("Directory '" + directoryURI + "' does not exist (" +
+ includeStatement.getLocation() + ").");
}
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml Wed Oct 17 21:43:24 2007
@@ -29,20 +29,24 @@
<!ELEMENT forbidden-children (#PCDATA)>
]>
-<!--+
- | The sitemap language.
- | $Id$
- +-->
+<!--
+ - The sitemap language.
+ - This file defines all possible sitemap elements and theirs implementations.
+ -
+ - $Id$
+ -->
<sitemap-language>
<!-- node definitions for the sitemap language -->
<nodes>
- <!-- A node has the following attributes :
- - name : the node name, given as a local name in the language namespace (no prefix)
- - builder : the class name of the ProcessingNodeBuilder for this node
-
- The contents of a node definition is the configuration of Configurable
- ProcessingNodeBuilders.
+
+ <!--
+ - A node has the following attributes :
+ - * name : the node name, given as a local name in the language namespace (no prefix)
+ - * builder : the class name of the ProcessingNodeBuilder for this node
+ -
+ - The contents of a node definition is the configuration of Configurable
+ - ProcessingNodeBuilders.
-->
<!-- Sitemap root node -->
@@ -98,28 +102,22 @@
</node>
<node name="redirect-to" builder="org.apache.cocoon.components.treeprocessor.sitemap.RedirectToNodeBuilder"/>
-
<node name="call" builder="org.apache.cocoon.components.treeprocessor.sitemap.CallNodeBuilder"/>
-
<node name="mount" builder="org.apache.cocoon.components.treeprocessor.sitemap.MountNodeBuilder"/>
<node name="read" builder="org.apache.cocoon.components.treeprocessor.sitemap.ReadNodeBuilder"/>
-
<node name="aggregate" builder="org.apache.cocoon.components.treeprocessor.sitemap.AggregateNodeBuilder"/>
<node name="generate" builder="org.apache.cocoon.components.treeprocessor.sitemap.GenerateNodeBuilder"/>
-
<node name="transform" builder="org.apache.cocoon.components.treeprocessor.sitemap.TransformNodeBuilder"/>
-
<node name="serialize" builder="org.apache.cocoon.components.treeprocessor.sitemap.SerializeNodeBuilder"/>
<node name="handle-errors" builder="org.apache.cocoon.components.treeprocessor.sitemap.HandleErrorsNodeBuilder"/>
-
</nodes>
- <!--+
- | You can add specific nodes for a specific sitemap version, using
- | <nodes-{version}>
- +-->
+ <!--
+ - You can add specific nodes for a specific sitemap version, using
+ - <nodes-{version}>
+ -->
</sitemap-language>
Modified: cocoon/trunk/core/cocoon-util/src/main/java/org/apache/cocoon/util/avalon/CLLoggerWrapper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-util/src/main/java/org/apache/cocoon/util/avalon/CLLoggerWrapper.java?rev=585863&r1=585862&r2=585863&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-util/src/main/java/org/apache/cocoon/util/avalon/CLLoggerWrapper.java (original)
+++ cocoon/trunk/core/cocoon-util/src/main/java/org/apache/cocoon/util/avalon/CLLoggerWrapper.java Wed Oct 17 21:43:24 2007
@@ -19,6 +19,11 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
+/**
+ * Commons Logging to Avalon Logger adapter.
+ *
+ * @version $Id$
+ */
public class CLLoggerWrapper implements Logger {
protected final Log log;