cziegeler 2003/11/05 13:29:08
Modified: src/java/org/apache/cocoon/components/treeprocessor
InvokeContext.java
src/java/org/apache/cocoon/components
RequestLifestyleComponentHandler.java
SitemapConfigurableAccessor.java
RequestLifecycleHelper.java
CocoonComponentManager.java CocoonContainer.java
src/java/org/apache/cocoon/components/pipeline
ProcessingPipeline.java
AbstractProcessingPipeline.java
Log:
Readding methods for compatibility in CocoonComponentManager
Fixing autorelease of components
Making pipelines "reserviceable"
Correting formatting and licence headers
Revision Changes Path
1.5 +3 -3
cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
Index: InvokeContext.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InvokeContext.java 7 Oct 2003 16:08:33 -0000 1.4
+++ InvokeContext.java 5 Nov 2003 21:29:08 -0000 1.5
@@ -163,7 +163,7 @@
this.currentManager = manager;
if (this.processingPipeline != null) {
- this.processingPipeline.recompose(manager);
+ this.processingPipeline.reservice(manager);
}
}
@@ -189,7 +189,7 @@
this.pipelineSelector =
(ComponentSelector)this.pipelinesManager.lookup(ProcessingPipeline.ROLE+"Selector");
this.processingPipeline =
(ProcessingPipeline)this.pipelineSelector.select(this.processingPipelineName);
- this.processingPipeline.recompose( this.pipelinesManager );
+ this.processingPipeline.reservice( this.pipelinesManager );
this.processingPipeline.setup(
VariableResolver.buildParameters(this.processingPipelineParameters,
this,
this.processingPipelineObjectModel)
1.4 +6 -5
cocoon-2.2/src/java/org/apache/cocoon/components/RequestLifestyleComponentHandler.java
Index: RequestLifestyleComponentHandler.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/RequestLifestyleComponentHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RequestLifestyleComponentHandler.java 29 Oct 2003 18:58:05 -0000
1.3
+++ RequestLifestyleComponentHandler.java 5 Nov 2003 21:29:08 -0000
1.4
@@ -22,9 +22,9 @@
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
- 4. The names "Jakarta", "Avalon", "Excalibur" 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
+ 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
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
@@ -43,8 +43,9 @@
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. For more information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
+ on behalf of the Apache Software Foundation and was originally created by
+ Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components;
1.2 +6 -5
cocoon-2.2/src/java/org/apache/cocoon/components/SitemapConfigurableAccessor.java
Index: SitemapConfigurableAccessor.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/SitemapConfigurableAccessor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SitemapConfigurableAccessor.java 22 Oct 2003 15:37:50 -0000 1.1
+++ SitemapConfigurableAccessor.java 5 Nov 2003 21:29:08 -0000 1.2
@@ -22,9 +22,9 @@
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
- 4. The names "Jakarta", "Avalon", "Excalibur" 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
+ 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
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
@@ -43,8 +43,9 @@
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. For more information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
+ on behalf of the Apache Software Foundation and was originally created by
+ Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components;
1.6 +130 -116
cocoon-2.2/src/java/org/apache/cocoon/components/RequestLifecycleHelper.java
Index: RequestLifecycleHelper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/RequestLifecycleHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RequestLifecycleHelper.java 29 Oct 2003 18:58:05 -0000 1.5
+++ RequestLifecycleHelper.java 5 Nov 2003 21:29:08 -0000 1.6
@@ -22,9 +22,9 @@
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
- 4. The names "Jakarta", "Avalon", "Excalibur" 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
+ 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
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
@@ -43,8 +43,9 @@
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. For more information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
+ on behalf of the Apache Software Foundation and was originally created by
+ Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components;
@@ -57,6 +58,8 @@
import org.apache.avalon.fortress.impl.handler.ComponentHandler;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.EnvironmentContext;
@@ -65,100 +68,110 @@
/**
* RequestLifecycleHelper Encapsulates all the static processing that is
needed
* for handling RequestLifecycle components.
- *
+ *
* @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
* @version CVS $ Revision: 1.1 $
*/
class RequestLifecycleHelper {
static final String KEY = RequestLifecycleHelper.class.getName();
-
+
static EnvironmentDescription getEnvironmentDescription() {
- final EnvironmentContext context =
EnvironmentHelper.getCurrentContext();
- EnvironmentDescription desc = (EnvironmentDescription)
context.getAttribute(KEY);
- if ( desc == null ) {
+ final EnvironmentContext context =
+ EnvironmentHelper.getCurrentContext();
+ EnvironmentDescription desc =
+ (EnvironmentDescription) context.getAttribute(KEY);
+ if (desc == null) {
desc = new EnvironmentDescription(context.getEnvironment());
context.addAttribute(KEY, desc);
}
return desc;
}
-
+
+ /**
+ * Add an automatically released component
+ */
+ static void addComponentForAutomaticRelease(final ServiceManager manager,
+ final Object component)
+ throws ProcessingException {
+ EnvironmentDescription desc = getEnvironmentDescription();
+ if (null != desc) {
+ desc.addToAutoRelease(manager, component);
+ }
+ }
+
/**
* Add an automatically released component
*/
- static void addComponentForAutomaticRelease(final ComponentHandler
manager,
- final Object
component)
+ static void addComponentForAutomaticRelease(final ServiceSelector
selector,
+ final Object component,
+ final ServiceManager manager)
throws ProcessingException {
EnvironmentDescription desc = getEnvironmentDescription();
- if ( null != desc ) {
+ if (null != desc) {
desc.addToAutoRelease(manager, component);
}
}
/**
- * Remove from automatically released components
- */
+ * Remove from automatically released components
+ */
public static void removeFromAutomaticRelease(final Object component)
- throws ProcessingException {
+ throws ProcessingException {
EnvironmentDescription desc = getEnvironmentDescription();
- if ( null != desc ) {
+ if (null != desc) {
desc.removeFromAutoRelease(component);
}
}
}
-final class EnvironmentDescription
-implements Disposable
-{
+final class EnvironmentDescription implements Disposable {
Environment environment;
Map objectModel;
Map requestLifecycleComponents;
- List autoreleaseComponents = new ArrayList( 4 );
+ List autoreleaseComponents = new ArrayList(4);
/**
- * Constructor
- */
- EnvironmentDescription( Environment env )
- {
+ * Constructor
+ */
+ EnvironmentDescription(Environment env) {
this.environment = env;
this.objectModel = env.getObjectModel();
}
- Map getGlobalRequestLifcecycleComponents()
- {
- Map m = (Map) environment.getAttribute(
GlobalRequestLifecycleComponent.class.getName() );
- if ( m == null )
- {
+ Map getGlobalRequestLifcecycleComponents() {
+ Map m =
+ (Map) environment.getAttribute(
+ GlobalRequestLifecycleComponent.class.getName());
+ if (m == null) {
m = new HashMap();
- environment.setAttribute(
GlobalRequestLifecycleComponent.class.getName(), m );
+ environment.setAttribute(
+ GlobalRequestLifecycleComponent.class.getName(),
+ m);
}
return m;
}
/**
- * Release all components of this environment
- * All RequestLifecycleComponents and autoreleaseComponents are
- * released.
- */
- public void dispose()
- {
- if ( this.requestLifecycleComponents != null )
- {
- final Iterator iter =
this.requestLifecycleComponents.values().iterator();
- while ( iter.hasNext() )
- {
+ * Release all components of this environment All
+ * RequestLifecycleComponents and autoreleaseComponents are released.
+ */
+ public void dispose() {
+ if (this.requestLifecycleComponents != null) {
+ final Iterator iter =
+ this.requestLifecycleComponents.values().iterator();
+ while (iter.hasNext()) {
final Object[] o = (Object[]) iter.next();
final Object component = o[0];
- ((ComponentHandler)o[1]).put(component);
+ ((ComponentHandler) o[1]).put(component);
}
this.requestLifecycleComponents.clear();
}
- for ( int i = 0; i < autoreleaseComponents.size(); i++ )
- {
- final Object[] o = (Object[]) autoreleaseComponents.get( i );
+ for (int i = 0; i < autoreleaseComponents.size(); i++) {
+ final Object[] o = (Object[]) autoreleaseComponents.get(i);
final Object component = o[0];
- final ComponentHandler handler = (ComponentHandler)o[1];
+ final ComponentHandler handler = (ComponentHandler) o[1];
handler.put(component);
}
this.autoreleaseComponents.clear();
@@ -166,76 +179,69 @@
this.objectModel = null;
}
-
/**
- * Add a RequestLifecycleComponent to the environment
- */
- void addRequestLifecycleComponent( final String role,
- final Object co,
- final ComponentHandler manager )
- {
- if ( this.requestLifecycleComponents == null )
- {
+ * Add a RequestLifecycleComponent to the environment
+ */
+ void addRequestLifecycleComponent(
+ final String role,
+ final Object co,
+ final ComponentHandler manager) {
+ if (this.requestLifecycleComponents == null) {
this.requestLifecycleComponents = new HashMap();
}
- this.requestLifecycleComponents.put( role, new Object[]{co, manager}
);
+ this.requestLifecycleComponents.put(role, new Object[] { co, manager
});
}
/**
- * Add a GlobalRequestLifecycleComponent to the environment
- */
- void addGlobalRequestLifecycleComponent( final String role,
- final Object co,
- final ComponentHandler manager )
- {
- this.getGlobalRequestLifcecycleComponents().put( role, new
Object[]{co, manager} );
+ * Add a GlobalRequestLifecycleComponent to the environment
+ */
+ void addGlobalRequestLifecycleComponent(
+ final String role,
+ final Object co,
+ final ComponentHandler manager) {
+ this.getGlobalRequestLifcecycleComponents().put(
+ role,
+ new Object[] { co, manager });
}
/**
- * Do we already have a request lifecycle component
- */
- boolean containsRequestLifecycleComponent( final String role )
- {
- if ( this.requestLifecycleComponents == null )
- {
+ * Do we already have a request lifecycle component
+ */
+ boolean containsRequestLifecycleComponent(final String role) {
+ if (this.requestLifecycleComponents == null) {
return false;
}
- return this.requestLifecycleComponents.containsKey( role );
+ return this.requestLifecycleComponents.containsKey(role);
}
/**
- * Do we already have a global request lifecycle component
- */
- boolean containsGlobalRequestLifecycleComponent( final String role )
- {
- return this.getGlobalRequestLifcecycleComponents().containsKey( role
);
+ * Do we already have a global request lifecycle component
+ */
+ boolean containsGlobalRequestLifecycleComponent(final String role) {
+ return this.getGlobalRequestLifcecycleComponents().containsKey(role);
}
/**
- * Search a RequestLifecycleComponent
- */
- Object getRequestLifecycleComponent( final String role )
- {
- if ( this.requestLifecycleComponents == null )
- {
+ * Search a RequestLifecycleComponent
+ */
+ Object getRequestLifecycleComponent(final String role) {
+ if (this.requestLifecycleComponents == null) {
return null;
}
- final Object[] o = (Object[]) this.requestLifecycleComponents.get(
role );
- if ( null != o )
- {
+ final Object[] o = (Object[])
this.requestLifecycleComponents.get(role);
+ if (null != o) {
return o[0];
}
return null;
}
/**
- * Search a GlobalRequestLifecycleComponent
- */
- Object getGlobalRequestLifecycleComponent( final String role )
- {
- final Object[] o = (Object[])
this.getGlobalRequestLifcecycleComponents().get( role );
- if ( null != o )
- {
+ * Search a GlobalRequestLifecycleComponent
+ */
+ Object getGlobalRequestLifecycleComponent(final String role) {
+ final Object[] o =
+ (Object[]) this.getGlobalRequestLifcecycleComponents().get(role);
+ if (null != o) {
return o[0];
}
return null;
@@ -244,38 +250,46 @@
/**
* Add an automatically released component
*/
- void addToAutoRelease( final ComponentHandler manager,
- final Object component )
- {
- this.autoreleaseComponents.add( new Object[]{component, manager} );
+ void addToAutoRelease(final ServiceSelector selector,
+ final Object component,
+ final ServiceManager manager) {
+ this.autoreleaseComponents.add(new Object[] {component, selector,
manager});
}
/**
- * Remove from automatically released components
- */
- void removeFromAutoRelease( final Object component )
- throws ProcessingException
- {
+ * Add an automatically released component
+ */
+ void addToAutoRelease(final ServiceManager manager,
+ final Object component) {
+ this.autoreleaseComponents.add(new Object[] { component, manager });
+ }
+
+ /**
+ * Remove from automatically released components
+ */
+ void removeFromAutoRelease(final Object component)
+ throws ProcessingException {
int i = 0;
boolean found = false;
- while ( i < this.autoreleaseComponents.size() && !found )
- {
- final Object[] o = (Object[]) this.autoreleaseComponents.get( i
);
- if ( o[0] == component )
- {
+ while (i < this.autoreleaseComponents.size() && !found) {
+ final Object[] o = (Object[]) this.autoreleaseComponents.get(i);
+ if (o[0] == component) {
found = true;
- final ComponentHandler handler = (ComponentHandler)o[1];
- handler.put(component);
- this.autoreleaseComponents.remove( i );
- }
- else
- {
+ if (o[1] instanceof ServiceManager) {
+ ((ServiceManager)o[1]).release( component );
+ } else {
+ ((ServiceSelector)o[1]).release( component );
+ if (o[2] != null) {
+ ((ServiceManager)o[2]).release( o[1] );
+ }
+ }
+ this.autoreleaseComponents.remove(i);
+ } else {
i++;
}
}
- if ( !found )
- {
- throw new ProcessingException( "Unable to remove component from
automatic release: component not found." );
+ if (!found) {
+ throw new ProcessingException("Unable to remove component from
automatic release: component not found.");
}
}
}
1.29 +29 -1
cocoon-2.2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
Index: CocoonComponentManager.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- CocoonComponentManager.java 30 Oct 2003 12:38:26 -0000 1.28
+++ CocoonComponentManager.java 5 Nov 2003 21:29:08 -0000 1.29
@@ -53,6 +53,8 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.EnvironmentHelper;
import java.util.ArrayList;
@@ -165,6 +167,32 @@
return EnvironmentHelper.getSitemapServiceManager();
}
+ /**
+ * Add an automatically released component
+ */
+ public static void addComponentForAutomaticRelease(final ServiceSelector
selector,
+ final Object
component,
+ final ServiceManager
manager)
+ throws ProcessingException {
+ RequestLifecycleHelper.addComponentForAutomaticRelease(selector,
component, manager);
+ }
+
+ /**
+ * Add an automatically released component
+ */
+ public static void addComponentForAutomaticRelease(final ServiceManager
manager,
+ final Object
component)
+ throws ProcessingException {
+ RequestLifecycleHelper.addComponentForAutomaticRelease(manager,
component);
+ }
+
+ /**
+ * Remove from automatically released components
+ */
+ public static void removeFromAutomaticRelease(final Object component)
+ throws ProcessingException {
+ RequestLifecycleHelper.removeFromAutomaticRelease(component);
+ }
}
1.8 +6 -5
cocoon-2.2/src/java/org/apache/cocoon/components/CocoonContainer.java
Index: CocoonContainer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/CocoonContainer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CocoonContainer.java 24 Oct 2003 20:23:23 -0000 1.7
+++ CocoonContainer.java 5 Nov 2003 21:29:08 -0000 1.8
@@ -22,9 +22,9 @@
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
- 4. The names "Jakarta", "Avalon", "Excalibur" 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
+ 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
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
@@ -43,8 +43,9 @@
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. For more information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
+ on behalf of the Apache Software Foundation and was originally created by
+ Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components;
1.5 +11 -4
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Index: ProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProcessingPipeline.java 27 Oct 2003 08:09:36 -0000 1.4
+++ ProcessingPipeline.java 5 Nov 2003 21:29:08 -0000 1.5
@@ -50,8 +50,9 @@
*/
package org.apache.cocoon.components.pipeline;
-import org.apache.avalon.framework.component.Recomposable;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.generation.Generator;
@@ -80,11 +81,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @version CVS $Id$
*/
-public interface ProcessingPipeline
- extends Recomposable {
+public interface ProcessingPipeline {
String ROLE = ProcessingPipeline.class.getName();
+ /**
+ * Set the correct manager for the sitemap this pipeline
+ * is used in
+ */
+ void reservice(ServiceManager manager)
+ throws ServiceException;
+
/**
* Setup this component
*/
1.15 +4 -6
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AbstractProcessingPipeline.java 31 Oct 2003 11:22:17 -0000 1.14
+++ AbstractProcessingPipeline.java 5 Nov 2003 21:29:08 -0000 1.15
@@ -58,8 +58,6 @@
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
@@ -168,10 +166,10 @@
}
/**
- * Recomposable Interface
+ * Reserviceable Interface
*/
- public void recompose (ComponentManager manager)
- throws ComponentException {
+ public void reservice (ServiceManager manager)
+ throws ServiceException {
this.newManager = manager;
}