You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/04/15 00:11:52 UTC

svn commit: r394213 - in /cocoon/trunk/blocks: ./ cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/ cocoon-xsp/cocoon-xsp-impl/ cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ co...

Author: cziegeler
Date: Fri Apr 14 15:11:47 2006
New Revision: 394213

URL: http://svn.apache.org/viewcvs?rev=394213&view=rev
Log:
Fix xsp and python block

Added:
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java   (with props)
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java   (with props)
Modified:
    cocoon/trunk/blocks/cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/PythonProgram.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/pom.xml
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ServerPagesAction.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/Program.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/JavaProgram.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/javascript/JavascriptProgram.java
    cocoon/trunk/blocks/pom.xml

Modified: cocoon/trunk/blocks/cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/PythonProgram.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/PythonProgram.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/PythonProgram.java (original)
+++ cocoon/trunk/blocks/cocoon-python/cocoon-python-impl/src/main/java/org/apache/cocoon/components/language/programming/python/PythonProgram.java Fri Apr 14 15:11:47 2006
@@ -21,11 +21,11 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceManager;
 
-import org.apache.cocoon.components.ComponentInfo;
 import org.apache.cocoon.components.language.programming.Program;
 import org.apache.cocoon.components.language.generator.CompiledComponent;
-import org.apache.cocoon.core.container.handler.AbstractComponentHandler;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+import org.apache.cocoon.xsp.handler.AbstractComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 import java.io.File;
 import java.util.Collection;
@@ -49,7 +49,7 @@
 
         config = new DefaultConfiguration("", "GeneratorSelector");
         // Instruct the core to avoid proxying this class
-        config.setAttribute("model", ComponentInfo.TYPE_NON_THREAD_SAFE_POOLED);
+        config.setAttribute("model", ComponentInfo.MODEL_POOLED);
         DefaultConfiguration child = new DefaultConfiguration("file", "");
         child.setValue(file.toString());
         config.addChild(child);

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/pom.xml?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/pom.xml (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/pom.xml Fri Apr 14 15:11:47 2006
@@ -48,6 +48,11 @@
       <artifactId>jdtcore</artifactId>
       <version>3.1.0</version>
     </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>2.0.2</version>
+    </dependency>
     <dependency>
       <groupId>excalibur-datasource</groupId>
       <artifactId>excalibur-datasource</artifactId>
@@ -59,5 +64,12 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <dependency>
+      <groupId>sun.jdk</groupId>
+      <artifactId>tools</artifactId>
+      <version>1.4.0</version>
+      <scope>system</scope>
+      <systemPath>${java.home}/../lib/tools.jar</systemPath>
+    </dependency>
   </dependencies>
 </project>

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ServerPagesAction.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ServerPagesAction.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ServerPagesAction.java (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/acting/ServerPagesAction.java Fri Apr 14 15:11:47 2006
@@ -27,14 +27,14 @@
 
 import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
 import org.apache.cocoon.components.sax.XMLByteStreamFragment;
-import org.apache.cocoon.core.container.handler.AbstractComponentHandler;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.generation.ServerPagesGenerator;
 import org.apache.cocoon.xml.AbstractXMLConsumer;
+import org.apache.cocoon.xsp.handler.AbstractComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 /**
  * Allows actions to be written in XSP. This allows to use XSP to produce

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java Fri Apr 14 15:11:47 2006
@@ -33,8 +33,8 @@
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.components.classloader.ClassLoaderManager;
 import org.apache.cocoon.components.language.programming.Program;
-import org.apache.cocoon.core.container.handler.AbstractComponentHandler;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.xsp.handler.AbstractComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 /**
  * This interface is the common base of all Compiled Components.  This

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/Program.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/Program.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/Program.java (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/Program.java Fri Apr 14 15:11:47 2006
@@ -19,7 +19,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 
 import org.apache.cocoon.components.language.generator.CompiledComponent;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 /**
  * This interface states the functionality of a program.

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/JavaProgram.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/JavaProgram.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/JavaProgram.java (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/JavaProgram.java Fri Apr 14 15:11:47 2006
@@ -20,11 +20,11 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceManager;
 
-import org.apache.cocoon.components.ComponentInfo;
 import org.apache.cocoon.components.language.generator.CompiledComponent;
 import org.apache.cocoon.components.language.programming.Program;
-import org.apache.cocoon.core.container.handler.AbstractComponentHandler;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+import org.apache.cocoon.xsp.handler.AbstractComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 /**
  * This represents program in Java language.
@@ -42,7 +42,7 @@
         this.program = program;
         this.config = new DefaultConfiguration("", "GeneratorSelector");
         // Instruct the core to avoid proxying this class
-        this.config.setAttribute("model", ComponentInfo.TYPE_NON_THREAD_SAFE_POOLED);
+        config.setAttribute("model", ComponentInfo.MODEL_POOLED);
     }
 
     public String getName() {

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/javascript/JavascriptProgram.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/javascript/JavascriptProgram.java?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/javascript/JavascriptProgram.java (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/javascript/JavascriptProgram.java Fri Apr 14 15:11:47 2006
@@ -21,11 +21,11 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceManager;
 
-import org.apache.cocoon.components.ComponentInfo;
 import org.apache.cocoon.components.language.generator.CompiledComponent;
 import org.apache.cocoon.components.language.programming.Program;
-import org.apache.cocoon.core.container.handler.AbstractComponentHandler;
-import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+import org.apache.cocoon.xsp.handler.AbstractComponentHandler;
+import org.apache.cocoon.xsp.handler.ComponentHandler;
 
 import java.io.File;
 import java.util.Collection;
@@ -50,7 +50,7 @@
 
         config = new DefaultConfiguration("", "GeneratorSelector");
         // Instruct the core to avoid proxying this class
-        config.setAttribute("model", ComponentInfo.TYPE_NON_THREAD_SAFE_POOLED);
+        config.setAttribute("model", ComponentInfo.MODEL_POOLED);
         child = new DefaultConfiguration("file", "");
         child.setValue(file.toString());
         config.addChild(child);

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,269 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.excalibur.pool.Poolable;
+import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.thread.SingleThreaded;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * This class acts like a Factory to instantiate the correct version
+ * of the component handler that you need.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public abstract class AbstractComponentHandler 
+implements ComponentHandler {
+    
+    private final Object referenceSemaphore = new Object();
+    private int references = 0;
+
+    protected final Logger logger;
+    
+    /** State management boolean stating whether the Handler is disposed or not */
+    protected boolean disposed = false;
+
+    /** State management boolean stating whether the Handler is initialized or not */
+    private boolean initialized = false;
+    
+    /** Information about the component */
+    private ComponentInfo info;
+    
+    /**
+     * Looks up and returns a component handler for a given component class.
+     *
+     * @param role the component's role. Can be <code>null</code> if the role isn't known.
+     * @param componentEnv The component's creation environment.
+     * @param info          The description of the component (configuration, lifecycle etc.)
+     *
+     * @throws Exception If there were any problems obtaining a ComponentHandler
+     */
+    public static ComponentHandler getComponentHandler(String role, 
+                                                       ComponentEnvironment componentEnv,
+                                                       ComponentInfo info) 
+    throws Exception {
+        
+       // Load the class
+        Class componentClass;
+        
+        try {
+            componentClass = componentEnv.loadClass(info.getComponentClassName());
+        } catch (ClassNotFoundException cnfe) {
+            throw new Exception("Cannot find class " + info.getComponentClassName() + " for component at " +
+                    info.getConfiguration().getLocation(), cnfe);
+        }
+
+        int numInterfaces = 0;
+
+        // Early check for Composable
+        if ( Composable.class.isAssignableFrom( componentClass ) ) {
+            throw new Exception("Interface Composable is not supported anymore. Please change class "
+                                + componentClass.getName() + " to use Serviceable instead.");
+        }
+
+        if( SingleThreaded.class.isAssignableFrom( componentClass ) ) {
+            numInterfaces++;
+            info.setModel(ComponentInfo.MODEL_PRIMITIVE);
+        }
+
+        if( ThreadSafe.class.isAssignableFrom( componentClass ) ) {
+            numInterfaces++;
+            info.setModel(ComponentInfo.MODEL_SINGLETON);
+        }
+
+        if( Poolable.class.isAssignableFrom( componentClass ) ) {
+            numInterfaces++;
+        }
+
+        if( numInterfaces > 1 ) {
+            throw new Exception( "[CONFLICT] More than one lifecycle interface in "
+                                 + componentClass.getName() + "  May implement no more than one of "
+                                 + "SingleThreaded, ThreadSafe, or Poolable" );
+        }
+
+        if ( numInterfaces == 0 ) {
+            // this component does not use avalon interfaces, so get the info from the configuration
+            info.fill(info.getConfiguration());
+        }
+        info.setRole(role);
+        
+        // Create the factory to use to create the instances of the Component.
+        ComponentFactory factory;
+        ComponentHandler handler;
+                
+        factory = new ComponentFactory(componentEnv, info);
+
+        if( info.getModel() == ComponentInfo.MODEL_POOLED)  {
+            handler = new NonThreadSafePoolableComponentHandler( info, componentEnv.logger, factory, info.getConfiguration() );
+        } else if( info.getModel() == ComponentInfo.MODEL_SINGLETON ) {
+            handler = new ThreadSafeComponentHandler( info, componentEnv.logger, factory );
+        } else {
+            // This is a SingleThreaded component
+            handler = new SingleThreadedComponentHandler( info, componentEnv.logger, factory );
+        }
+
+        return handler;
+    }
+
+    /**
+     * Creates a new ComponentHandler.
+     */
+    public AbstractComponentHandler(ComponentInfo info, Logger logger) {
+        this.logger = logger;
+        this.info = info;
+    }
+    
+    public ComponentInfo getInfo() {
+        return this.info;
+    }
+
+    /**
+     * Get an instance of the type of component handled by this handler.
+     * <p>
+     * Subclasses should not extend this method but rather the doGet method below otherwise
+     *  reference counts will not be supported.
+     * <p>
+     *
+     * @return an instance
+     * @exception Exception if an error occurs
+     */
+    public final Object get() throws Exception {
+        initialize();
+        if( this.disposed ) {
+            throw new IllegalStateException( "You cannot get a component from a disposed handler." );
+        }
+        
+        final Object component = this.doGet();
+
+        synchronized( this.referenceSemaphore ) {
+            this.references++;
+        }
+
+        return component;
+    }
+
+    /**
+     * Put back an instance of the type of component handled by this handler.
+     * <p>
+     * Subclasses should not extend this method but rather the doPut method below otherwise
+     *  reference counts will not be supported.
+     * <p>
+     *
+     * @param component a service
+     * @exception Exception if an error occurs
+     */
+    public final void put( Object component ) 
+    throws Exception {
+        if( !this.initialized ) {
+            throw new IllegalStateException(
+                "You cannot put a component to an uninitialized handler." );
+        }
+        //  The reference count must be decremented before any calls to doPut.
+        //  If there is another thread blocking, then this thread could stay deep inside
+        //  doPut for an undetermined amount of time until the thread scheduler gives it
+        //  some cycles again.  (It happened).  All ComponentHandler state must therefor
+        //  reflect the thread having left this method before the call to doPut to avoid
+        //  warning messages from the dispose() cycle if that takes place before this
+        //  thread has a chance to continue.
+        synchronized( this.referenceSemaphore ) {
+            this.references--;
+        }
+
+        try {
+            this.doPut( component );
+        } catch( Throwable t ) {
+            this.logger.error("Exception during putting back a component.", t);
+        }
+    }
+
+    /**
+     * Concrete implementation of getting a component.
+     *
+     * @return a service
+     * @exception Exception if an error occurs
+     */
+    protected abstract Object doGet() throws Exception;
+
+    /**
+     * Concrete implementation of putting back a component.
+     *
+     * @param component a <code>Component</code> value
+     * @exception Exception if an error occurs
+     */
+    protected abstract void doPut( Object component ) throws Exception;
+
+    /**
+     * Default here is to return <code>false</code>
+     */
+    public boolean isSingleton() {
+        return false;
+    }
+    
+    /**
+     * Returns <code>true</code> if this component handler can safely be
+     * disposed (i.e. none of the components it is handling are still
+     * being used).
+     *
+     * @return <code>true</code> if this component handler can safely be
+     *         disposed; <code>false</code> otherwise
+     */
+    public final boolean canBeDisposed() {
+        return ( this.references == 0 );
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.core.container.ComponentHandler#dispose()
+     */
+    public void dispose() {
+        this.disposed = true;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.core.container.ComponentHandler#initialize()
+     */
+    public final void initialize() throws Exception {
+        if( this.initialized ) {
+            return;
+        }
+
+        doInitialize();
+        this.initialized = true;
+    }
+    
+    protected abstract void doInitialize() throws Exception;
+
+    /**
+     * Create a component handler (version used by XSP)
+     * TODO - perhaps we can remove this later?
+     */
+    public static ComponentHandler getComponentHandler(Class clazz, Logger logger, Context context, ServiceManager manager, Configuration config) throws Exception {
+        ComponentEnvironment env = new ComponentEnvironment(logger, context, manager);
+        ComponentInfo info = new ComponentInfo();
+        info.setComponentClassName(clazz.getName());
+        info.setConfiguration(config);
+        info.setRole("XSP");
+        return getComponentHandler(null, env, info);
+
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractComponentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,57 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * This class acts like a Factory to instantiate the correct version
+ * of the component handler that you need.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public abstract class AbstractFactoryHandler extends AbstractComponentHandler {
+    
+    /** This factory is used to created new objects */
+    protected final ComponentFactory factory;
+    
+    /**
+     * Creates a new ComponentHandler.
+     */
+    public AbstractFactoryHandler(ComponentInfo info, Logger logger, ComponentFactory factory) {
+        super(info, logger);
+        this.factory = factory;
+    }
+
+    /**
+     * Decommission a component
+     * @param component Object to be decommissioned
+     */
+    protected void decommission( final Object component ) {
+        try {
+            this.factory.decommission( component );
+        } catch( final Exception e ) {
+            if( this.logger.isWarnEnabled() ) {
+                this.logger.warn( "Error decommissioning component: "
+                    + this.factory.getCreatedClass().getName(), e );
+            }
+        }
+    }
+    
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/AbstractFactoryHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,48 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+
+/**
+ * The component enviromnent contains all objects necessary to create
+ * a new component; it's just a "container" of objects.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class ComponentEnvironment {
+
+    public final ServiceManager serviceManager;
+    public final Context context;
+    public final Logger logger;
+
+    public ComponentEnvironment(Logger logger,
+                                Context context,
+                                ServiceManager serviceManager) {
+
+        this.logger = logger;
+        this.context = context;
+        this.serviceManager = serviceManager;
+    }
+
+    public Class loadClass(String name) throws ClassNotFoundException {
+        return this.getClass().getClassLoader().loadClass(name);
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentEnvironment.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,138 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.excalibur.pool.Recyclable;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * Factory for Avalon based components.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class ComponentFactory {
+    
+    protected final ComponentInfo serviceInfo;
+    
+    protected final ComponentEnvironment environment;
+    
+    /**
+     * The component's logger, which may be different from the environment's logger
+     */
+    protected final Logger componentLogger;
+    
+    /** The parameters for this component
+     */
+    protected final Parameters parameters;
+    
+    protected final Class serviceClass;
+
+    /**
+     * Construct a new component factory for the specified component.
+     *
+     * @param environment Describes the environment for the component.
+     * @param info Describes the configuration/settings for the component.
+     *
+     */
+    public ComponentFactory( final ComponentEnvironment environment,
+                             final ComponentInfo info) 
+    throws Exception {
+        this.environment = environment;
+        this.serviceInfo = info;
+        
+        // this is our default logger:
+        Logger actualLogger = this.environment.logger;
+        this.componentLogger = actualLogger;
+        
+        this.serviceClass = this.environment.loadClass(this.serviceInfo.getComponentClassName());
+        if ( Parameterizable.class.isAssignableFrom(this.serviceClass) ) {
+            this.parameters = Parameters.fromConfiguration( this.serviceInfo.getConfiguration() );            
+        } else {
+            this.parameters = null;
+        }
+    }
+    
+    /**
+     * Create a new instance
+     */
+    public final Object newInstance()
+    throws Exception {
+        final Object component = this.serviceClass.newInstance();
+
+        setupInstance(component);
+        return component;
+    }
+    
+    /**
+     * Invoke the various lifecycle interfaces to setup a newly created component
+     * @param component
+     * @throws Exception
+     */
+    protected void setupInstance(Object component) throws Exception {
+        if( this.environment.logger.isDebugEnabled() ) {
+            this.environment.logger.debug( "ComponentFactory creating new instance of " +
+                    this.serviceClass.getName() + "." );
+        }
+
+        ContainerUtil.enableLogging(component, this.componentLogger);
+        ContainerUtil.contextualize( component, this.environment.context );
+        ContainerUtil.service( component, this.environment.serviceManager );
+        ContainerUtil.configure( component, this.serviceInfo.getConfiguration() );
+
+        if( component instanceof Parameterizable ) {
+            ContainerUtil.parameterize( component, this.parameters );
+        }
+
+        ContainerUtil.initialize( component );
+
+        ContainerUtil.start( component );
+    }
+
+    public Class getCreatedClass() {
+        return this.serviceClass;
+    }
+
+    /**
+     * Destroy an instance
+     */
+    public void decommission( final Object component )
+    throws Exception {
+        if( this.environment.logger.isDebugEnabled() ) {
+            this.environment.logger.debug( "ComponentFactory decommissioning instance of " +
+                    this.serviceClass.getName() + "." );
+        }
+
+        ContainerUtil.stop( component );
+        ContainerUtil.dispose( component );
+    }
+
+    /**
+     * Handle service specific methods for putting it into the pool
+     */
+    public void enteringPool( final Object component )
+    throws Exception {
+        // Handle Recyclable objects
+        if( component instanceof Recyclable ) {
+            ( (Recyclable)component ).recycle();
+        }
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,72 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+/**
+ * This class acts like a Factory to instantiate the correct version
+ * of the component handler that you need.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public interface ComponentHandler {
+
+    /**
+     * Get an instance of the type of component handled by this handler.
+     * 
+     * @return an instance
+     * @exception Exception if an error occurs
+     */
+    Object get() throws Exception;
+
+    /**
+     * Put back an instance of the type of component handled by this handler.
+     *
+     * @param component a service
+     * @exception Exception if an error occurs
+     */
+    void put( Object component ) 
+    throws Exception;
+    
+    /**
+     * Indicates if this handler manages a single object, i.e. all calls to {@link #get()}
+     * will return the same object.
+     * 
+     * @return <code>true</code> if managed object is a singleton
+     */
+    boolean isSingleton();
+
+    /**
+     * Returns <code>true</code> if this component handler can safely be
+     * disposed (i.e. none of the components it is handling are still
+     * being used).
+     *
+     * @return <code>true</code> if this component handler can safely be
+     *         disposed; <code>false</code> otherwise
+     */
+    boolean canBeDisposed();
+
+    /**
+     * Dispose of the component handler and any associated Pools and Factories.
+     */
+    public void dispose();
+    
+    /**
+     * Initialize this handler
+     */
+    void initialize() throws Exception;
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ComponentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,282 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * The PoolableComponentHandler to make sure that poolable components are initialized
+ * destroyed and pooled correctly.
+ * <p>
+ * Components which implement Poolable may be configured to be pooled using the following
+ *  example configuration.  This example assumes that the user component class MyComp
+ *  implements Poolable.
+ * <p>
+ * Configuration Example:
+ * <pre>
+ *   &lt;my-comp pool-max="8"/&gt;
+ * </pre>
+ * <p>
+ * Roles Example:
+ * <pre>
+ *   &lt;role name="com.mypkg.MyComponent"
+ *         shorthand="my-comp"
+ *         default-class="com.mypkg.DefaultMyComponent"/&gt;
+ * </pre>
+ * <p>
+ * Configuration Attributes:
+ * <ul>
+ * <li>The <code>pool-max</code> attribute is used to set the maximum number of components which
+ *  will be pooled. (Defaults to "8") If additional instances are required, they're created,
+ *  but not pooled.</li>
+ * </ul>
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class NonThreadSafePoolableComponentHandler
+extends AbstractFactoryHandler {
+    
+    /** The default max size of the pool */
+    public static final int DEFAULT_MAX_POOL_SIZE = 8;
+
+    /**
+     * Object used to synchronize access to the get and put methods
+     */
+    protected final Object semaphore = new Object();
+
+    /**
+     * The maximum size of the pool.
+     */
+    private final int max;
+
+    /**
+     * List of the Poolable instances which are available for use.
+     */
+    private LinkedList ready;
+
+    /**
+     * Store the size of the ready list to optimize operations which require this value.
+     */
+    private int readySize;
+
+    /**
+     * Total number of Poolable instances in the pool
+     */
+    private int size;
+
+    /**
+     * Total number of Poolable instances created 
+     */
+    private int highWaterMark;
+    
+    /**
+     * Create a PoolableComponentHandler which manages a pool of Components
+     *  created by the specified factory object.
+     *
+     * @param factory The factory object which is responsible for creating the components
+     *                managed by the ComponentHandler.
+     * @param config The configuration to use to configure the pool.
+     */
+    public NonThreadSafePoolableComponentHandler( final ComponentInfo info,
+                                     final Logger logger,
+                                     final ComponentFactory factory,
+                                     final Configuration config )
+    throws Exception {
+        super(info, logger, factory);
+
+        final int poolMax = config.getAttributeAsInteger( "pool-max", DEFAULT_MAX_POOL_SIZE );
+        this.max = ( poolMax <= 0 ? Integer.MAX_VALUE : poolMax );
+
+        // Create the pool lists.
+        this.ready = new LinkedList();
+    }
+
+    /**
+     * Dispose of the ComponentHandler and any associated Pools and Factories.
+     */
+    public void dispose() {
+        super.dispose();
+
+        // Any Poolables in the m_ready list need to be disposed of
+        synchronized( this.semaphore ) {
+            // Remove objects in the ready list.
+            for( Iterator iter = this.ready.iterator(); iter.hasNext(); ) {
+                Object poolable = iter.next();
+                iter.remove();
+                this.readySize--;
+                this.permanentlyRemovePoolable( poolable );
+            }
+
+            if( this.size > 0 && this.logger.isDebugEnabled() ) {
+                this.logger.debug( "There were " + this.size
+                                   + " outstanding objects when the pool was disposed." );
+            }
+        }
+    }
+    
+    /**
+     * Permanently removes a poolable from the pool's active list and
+     *  destroys it so that it will not ever be reused.
+     * <p>
+     * This method is only called by threads that have m_semaphore locked.
+     */
+    protected void permanentlyRemovePoolable( Object poolable ) {
+        this.size--;
+        this.decommission( poolable );
+    }
+
+    /**
+     * Gets a Poolable from the pool.  If there is room in the pool, a new Poolable will be
+     *  created.  Depending on the parameters to the constructor, the method may block or throw
+     *  an exception if a Poolable is not available on the pool.
+     *
+     * @return Always returns a Poolable.  Contract requires that put must always be called with
+     *  the Poolable returned.
+     * @throws Exception An exception may be thrown as described above or if there is an exception
+     *  thrown by the ObjectFactory's newInstance() method.
+     */
+    protected Object getFromPool() throws Exception {
+        Object poolable;
+        synchronized( this.semaphore ) {
+            // Look for a Poolable at the end of the m_ready list
+            if ( this.readySize > 0 ){
+                // A poolable is ready and waiting in the pool
+                poolable = this.ready.removeLast();
+                this.readySize--;
+            } else {
+                // Create a new poolable.  May throw an exception if the poolable can not be
+                //  instantiated.
+                poolable = this.factory.newInstance();
+                this.size++;
+                this.highWaterMark = (this.highWaterMark < this.size ? this.size : this.highWaterMark);
+
+                if ( this.logger.isDebugEnabled() ) {
+                    this.logger.debug( "Created a new " + poolable.getClass().getName()
+                                       + " from the object factory." );
+                }
+            }
+        }
+
+        if( this.logger.isDebugEnabled() ) {
+            this.logger.debug( "Got a " + poolable.getClass().getName() + " from the pool." );
+        }
+
+        return poolable;
+    }
+
+    /**
+     * Returns a poolable to the pool 
+     *
+     * @param poolable Poolable to return to the pool.
+     */
+    protected void putIntoPool( final Object poolable ) {
+        try {
+            this.factory.enteringPool(poolable);
+        } catch (Exception ignore) {
+            this.logger.warn("Exception during putting component back into the pool.", ignore);
+        }
+
+        synchronized( this.semaphore ) {
+            if( this.size <= this.max ) {
+                if( this.disposed ) {
+                    // The pool has already been disposed.
+                    if( this.logger.isDebugEnabled() ) {
+                        this.logger.debug( "Put called for a " + poolable.getClass().getName()
+                                           + " after the pool was disposed." );
+                    }
+
+                    this.permanentlyRemovePoolable( poolable );
+                } else {
+                    // There is room in the pool to keep this poolable.
+                    if( this.logger.isDebugEnabled() ) {
+                        this.logger.debug( "Put a " + poolable.getClass().getName()
+                                           + " back into the pool." );
+                    }
+
+                    this.ready.addLast( poolable );
+                    this.readySize++;
+
+                }
+            } else {
+                // More Poolables were created than can be held in the pool, so remove.
+                if( this.logger.isDebugEnabled() ) {
+                    this.logger.debug( "No room to put a " + poolable.getClass().getName()
+                                       + " back into the pool, so remove it." );
+                }
+
+                this.permanentlyRemovePoolable( poolable );
+            }
+        }
+    }
+    
+    protected void doInitialize() {
+        // nothing to do here
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.core.container.handler.AbstractComponentHandler#doGet()
+     */
+    protected Object doGet() throws Exception {
+        return this.getFromPool();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.core.container.handler.AbstractComponentHandler#doPut(java.lang.Object)
+     */
+    protected void doPut(Object component) throws Exception {
+        this.putIntoPool(component);
+    }
+
+    /**
+     * @return Returns the max.
+     */
+    public int getMax()
+    {
+        return max;
+    }
+
+    /**
+     * @return Returns the readySize.
+     */
+    public int getReadySize()
+    {
+        return readySize;
+    }
+
+    /**
+     * @return Returns the size.
+     */
+    public int getSize()
+    {
+        return size;
+    }
+
+    /**
+     * @return Returns the highWaterMark.
+     */
+    public int getHighWaterMark()
+    {
+        return highWaterMark;
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/NonThreadSafePoolableComponentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,93 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * The DefaultComponentHandler to make sure components are initialized
+ * and destroyed correctly.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class SingleThreadedComponentHandler
+extends AbstractFactoryHandler {
+
+    private long maxCreated = 0;
+    private long maxDecommissioned = 0;
+    
+    /**
+     * Create a SingleThreadedComponentHandler which manages a pool of Components
+     *  created by the specified factory object.
+     *
+     * @param logger The logger to use
+     * @param factory The factory object which is responsible for creating the components
+     *                managed by the handler.
+     */
+    public SingleThreadedComponentHandler( final ComponentInfo info,
+                                    final Logger logger,
+                                    final ComponentFactory factory ) {
+        super(info, logger, factory);
+    }
+
+    /**
+     * Get a reference of the desired Component
+     *
+     * @return A component instance.
+     *
+     * @throws Exception If there are any problems encountered acquiring a
+     *                   component instance.
+     */
+    protected Object doGet()
+    throws Exception {
+        maxCreated++;
+        return this.factory.newInstance();
+    }
+
+    /**
+     * Return a reference of the desired Component
+     *
+     * @param component Component to be be put/released back to the handler.
+     */
+    protected void doPut( final Object component ) {
+        this.decommission( component );
+        maxDecommissioned++;
+    }
+    
+    protected void doInitialize() {
+        // nothing to do here
+    }
+
+    /**
+     * @return Returns the maxCreated.
+     */
+    public long getMaxCreated()
+    {
+        return maxCreated;
+    }
+
+    /**
+     * @return Returns the maxDecommisioned.
+     */
+    public long getMaxDecommissioned()
+    {
+        return maxDecommissioned;
+    }
+
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/SingleThreadedComponentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java?rev=394213&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java (added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java Fri Apr 14 15:11:47 2006
@@ -0,0 +1,81 @@
+/* 
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.xsp.handler;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.core.container.spring.ComponentInfo;
+
+/**
+ * The ThreadSafeComponentHandler to make sure components are initialized
+ * and destroyed correctly.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class ThreadSafeComponentHandler
+extends AbstractFactoryHandler {
+    
+    private Object instance;
+
+    /**
+     * Create a ThreadSafeComponentHandler which manages a single instance
+     * of an object return by the component factory.
+     * @param logger The logger to use
+     * @param factory The factory object which is responsible for creating the components
+     *                managed by the handler.
+     */
+    public ThreadSafeComponentHandler( final ComponentInfo info,
+                                       final Logger logger,
+                                       final ComponentFactory factory ) {
+        super(info, logger, factory);
+    }
+    
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void doInitialize() throws Exception {
+        if( this.instance == null ) {
+            this.instance = this.factory.newInstance();
+        }
+    }
+
+    /**
+     * Get a reference of the desired Component
+     */
+    protected Object doGet()
+    throws Exception {
+        return this.instance;
+    }
+
+    /**
+     * Return a reference of the desired Component
+     */
+    protected void doPut( final Object component ) {
+        // nothing to do
+    }
+
+    /**
+     * Dispose of the ComponentHandler and any associated Pools and Factories.
+     */
+    public void dispose() {
+        this.decommission( this.instance );
+        this.instance = null;
+
+        super.dispose();
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/xsp/handler/ThreadSafeComponentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/pom.xml?rev=394213&r1=394212&r2=394213&view=diff
==============================================================================
--- cocoon/trunk/blocks/pom.xml (original)
+++ cocoon/trunk/blocks/pom.xml Fri Apr 14 15:11:47 2006
@@ -75,7 +75,7 @@
 		<module>cocoon-portal</module>
 		<module>cocoon-profiler</module>
 		<module>cocoon-proxy</module>
-		<!-- module>cocoon-python</module -->
+		<module>cocoon-python</module>
 		<module>cocoon-qdox</module>
 		<module>cocoon-querybean</module>
 		<module>cocoon-repository</module>
@@ -91,7 +91,7 @@
 		<module>cocoon-velocity</module>
 		<module>cocoon-web3</module>
 		<module>cocoon-webdav</module>
-		<!-- module>cocoon-xsp</module -->
+		<module>cocoon-xsp</module>
 	</modules>
   <scm>
     <connection>scm:svn:http://svn.apache.org/repos/asf/cocoon/trunk/blocks</connection>