You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2003/10/16 16:50:23 UTC
cvs commit: cocoon-2.2/src/java/org/apache/cocoon/acting AbstractComplementaryConfigurableAction.java AbstractMultiAction.java ClearCacheAction.java ClearPersistentStoreAction.java InputModuleAction.java ServerPagesAction.java
bloritsch 2003/10/16 07:50:23
Modified: src/java/org/apache/cocoon/acting
AbstractComplementaryConfigurableAction.java
AbstractMultiAction.java ClearCacheAction.java
ClearPersistentStoreAction.java
InputModuleAction.java ServerPagesAction.java
Log:
UPdate these to be Serviceable.
Revision Changes Path
1.3 +2 -2 cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java
Index: AbstractComplementaryConfigurableAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractComplementaryConfigurableAction.java 16 May 2003 07:04:56 -0000 1.2
+++ AbstractComplementaryConfigurableAction.java 16 Oct 2003 14:50:22 -0000 1.3
@@ -71,7 +71,7 @@
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @version CVS $Id$
*/
-public abstract class AbstractComplementaryConfigurableAction extends ConfigurableComposerAction {
+public abstract class AbstractComplementaryConfigurableAction extends ConfigurableServiceableAction {
private static Map configurations = new HashMap();
/**
1.7 +2 -2 cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractMultiAction.java
Index: AbstractMultiAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractMultiAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractMultiAction.java 24 Sep 2003 21:26:51 -0000 1.6
+++ AbstractMultiAction.java 16 Oct 2003 14:50:22 -0000 1.7
@@ -78,7 +78,7 @@
* @author <a href="mailto:tcurdt@dff.st">Torsten Curdt</a>
* @version CVS $Id$
*/
-public abstract class AbstractMultiAction extends ConfigurableComposerAction {
+public abstract class AbstractMultiAction extends ConfigurableServiceableAction {
private static final String ACTION_METHOD_PREFIX = "do";
private static final String ACTION_METHOD_PARAMETER = "method";
1.4 +12 -12 cocoon-2.2/src/java/org/apache/cocoon/acting/ClearCacheAction.java
Index: ClearCacheAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/ClearCacheAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClearCacheAction.java 15 Oct 2003 20:09:50 -0000 1.3
+++ ClearCacheAction.java 16 Oct 2003 14:50:22 -0000 1.4
@@ -1,36 +1,36 @@
/*
-
+
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,12 +41,12 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
-
+
*/
package org.apache.cocoon.acting;
1.3 +12 -12 cocoon-2.2/src/java/org/apache/cocoon/acting/ClearPersistentStoreAction.java
Index: ClearPersistentStoreAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/ClearPersistentStoreAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClearPersistentStoreAction.java 15 Oct 2003 20:09:50 -0000 1.2
+++ ClearPersistentStoreAction.java 16 Oct 2003 14:50:22 -0000 1.3
@@ -1,36 +1,36 @@
/*
-
+
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,12 +41,12 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
-
+
*/
package org.apache.cocoon.acting;
1.3 +11 -11 cocoon-2.2/src/java/org/apache/cocoon/acting/InputModuleAction.java
Index: InputModuleAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/InputModuleAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InputModuleAction.java 15 Aug 2003 15:54:15 -0000 1.2
+++ InputModuleAction.java 16 Oct 2003 14:50:22 -0000 1.3
@@ -74,33 +74,33 @@
* <map:parameter name="module" value="defaults"/>
* <map:parameter name="attribute" value="{1}"/>
* <map:parameter name="single-value" value="false"/>
- *
+ *
* <!-- do something with the result: "{1}" -->
- *
+ *
* </map:act>
- * </pre>
- * The action invokes the
+ * </pre>
+ * The action invokes the
* {@link org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(String, Configuration, Map) getAttributeValues()}
* method and returns all results numbered from "1". If no result exists,
* "null" is returned and the nested block is skipped.
* The name of the input module to use may be preconfigured when
* declaring the action in your sitemap:
* <pre>
- * <map:action name="inputmodule"
- * src="org.apache.cocoon.acting.InputModuleAction"
+ * <map:action name="inputmodule"
+ * src="org.apache.cocoon.acting.InputModuleAction"
* logger="sitemap.action.inputmodule">
* <module>defaults</module>
* <single-value>false</single-value>
* </map:action>
* </pre>
- *
- *
+ *
+ *
* @see org.apache.cocoon.components.modules.input.InputModule
- *
+ *
* @author <a href="mailto:haul@apache.org">Christian Haul</a>
* @version CVS $Id$
*/
-public class InputModuleAction extends ConfigurableComposerAction {
+public class InputModuleAction extends ConfigurableServiceableAction {
/* (non-Javadoc)
* @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
1.4 +47 -31 cocoon-2.2/src/java/org/apache/cocoon/acting/ServerPagesAction.java
Index: ServerPagesAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/acting/ServerPagesAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerPagesAction.java 15 Oct 2003 18:10:46 -0000 1.3
+++ ServerPagesAction.java 16 Oct 2003 14:50:22 -0000 1.4
@@ -54,12 +54,21 @@
import java.util.Map;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
-
-import org.apache.avalon.excalibur.component.ComponentHandler;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.DefaultServiceManager;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.fortress.impl.handler.ComponentHandler;
+import org.apache.avalon.fortress.impl.handler.PoolableComponentHandler;
+import org.apache.avalon.fortress.impl.handler.ComponentFactory;
+import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
import org.apache.cocoon.components.sax.XMLByteStreamFragment;
@@ -69,6 +78,7 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.ServerPagesGenerator;
import org.apache.cocoon.xml.AbstractXMLConsumer;
+import org.apache.excalibur.mpool.ObjectFactory;
/**
* Allows actions to be written in XSP. This allows to use XSP to produce
@@ -108,41 +118,23 @@
*/
public class ServerPagesAction
extends ConfigurableServiceableAction
- implements Disposable, ThreadSafe {
+ implements Disposable,Contextualizable, Initializable, ThreadSafe {
public static final String REDIRECTOR_OBJECT = "xsp-action:redirector";
public static final String ACTION_RESULT_OBJECT = "xsp-action:result";
public static final String ACTION_SUCCESS_OBJECT = "xsp-action:success";
- ComponentHandler generatorHandler;
+ ComponentHandler m_generatorHandler;
+ Configuration m_conf;
+ private Context m_context;
public void configure(Configuration conf)
throws ConfigurationException {
- try {
- this.generatorHandler = ComponentHandler.getComponentHandler(
- ServerPagesGenerator.class,
- conf,
- this.manager,
- null, // Context
- null, // RoleManager
- null, // LogkitLoggerManager
- null, // InstrumentManager
- "N/A" // instrumentableName
- );
-
- this.generatorHandler.enableLogging(getLogger());
- this.generatorHandler.initialize();
-
- } catch(Exception e) {
- throw new ConfigurationException("Cannot set up component handler", e);
- }
+ m_conf = conf;
}
public void dispose() {
- if (this.generatorHandler != null) {
- this.generatorHandler.dispose();
- this.generatorHandler = null;
- }
+ ContainerUtil.dispose(m_generatorHandler);
}
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
@@ -158,14 +150,12 @@
Object success = null;
// Get a ServerPagesGenerator
- ServerPagesGenerator generator = (ServerPagesGenerator)this.generatorHandler.get();
+ ServerPagesGenerator generator = (ServerPagesGenerator)this.m_generatorHandler.get();
// Generator ouptut, if output-attribute was given
XMLByteStreamCompiler compiler = null;
try {
- generator.enableLogging(getLogger());
- generator.service(this.manager);
generator.setup(resolver, objectModel, source, parameters);
// Setup generator output
@@ -188,7 +178,7 @@
} finally {
// Release generator
- generatorHandler.put(generator);
+ m_generatorHandler.put(generator);
// Clean up object model
objectModel.remove(REDIRECTOR_OBJECT);
@@ -210,5 +200,31 @@
}
return (success == Boolean.TRUE) ? resultMap : null;
+ }
+
+ public void initialize() throws Exception
+ {
+ ComponentFactory factory = new ComponentFactory(
+ ServerPagesGenerator.class,
+ m_conf,
+ manager, // ServiceManager
+ m_context, // Context
+ null, // LoggerManager
+ null ); // Extension Manager
+ m_generatorHandler = new PoolableComponentHandler();
+
+ DefaultServiceManager newManager = new DefaultServiceManager(manager);
+ newManager.put(ObjectFactory.class.getName(), factory);
+
+ ContainerUtil.enableLogging( m_generatorHandler, getLogger() );
+ ContainerUtil.contextualize( m_generatorHandler, m_context );
+ ContainerUtil.service(m_generatorHandler, newManager);
+ ContainerUtil.configure(m_generatorHandler, m_conf);
+ ContainerUtil.initialize(m_generatorHandler);
+ }
+
+ public void contextualize( Context context ) throws ContextException
+ {
+ m_context = context;
}
}