bloritsch 01/03/19 09:08:46
Modified: src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java Main.java
src/org/apache/cocoon/components Tag: xml-cocoon2
CocoonComponentHandler.java
CocoonComponentManager.java
CocoonComponentSelector.java ComponentFactory.java
ComponentPool.java
src/org/apache/cocoon/servlet Tag: xml-cocoon2
CocoonServlet.java
Log:
Fixed proper cleanup of Components.
Revision Changes Path
No revision
No revision
1.4.2.66 +13 -8 xml-cocoon/src/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.4.2.65
retrieving revision 1.4.2.66
diff -u -r1.4.2.65 -r1.4.2.66
--- Cocoon.java 2001/03/16 21:50:21 1.4.2.65
+++ Cocoon.java 2001/03/19 17:08:31 1.4.2.66
@@ -19,6 +19,7 @@
import org.apache.avalon.Composer;
import org.apache.avalon.Context;
import org.apache.avalon.Contextualizable;
+import org.apache.avalon.Disposable;
import org.apache.avalon.Modifiable;
import org.apache.avalon.configuration.Configurable;
import org.apache.avalon.configuration.Configuration;
@@ -47,18 +48,12 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4.2.65 $ $Date: 2001/03/16 21:50:21 $
+ * @version CVS $Revision: 1.4.2.66 $ $Date: 2001/03/19 17:08:31 $
*/
-public class Cocoon extends AbstractLoggable implements Component,
Initializable, Modifiable, Processor, Contextualizable {
+public class Cocoon extends AbstractLoggable implements Component,
Initializable, Disposable, Modifiable, Processor, Contextualizable {
/** The application context */
private Context context;
- /** The table of role-class */
- private HashMap components = new HashMap();
-
- /** The table of role-configuration */
- private HashMap configurations = new HashMap();
-
/** The configuration file */
private URL configurationFile;
@@ -80,6 +75,9 @@
/** The component manager. */
private CocoonComponentManager componentManager;
+ /** flag for disposed or not */
+ private boolean disposed = false;
+
/** Create a new <code>Cocoon</code> instance. */
public Cocoon() throws ConfigurationException {
// Set the system properties needed by Xalan2.
@@ -205,11 +203,18 @@
System.setProperties(systemProps);
}
+ public synchronized void dispose() {
+ this.disposed = true;
+
+ this.componentManager.dispose();
+ }
+
/**
* Process the given <code>Environment</code> to produce the output.
*/
public boolean process(Environment environment)
throws Exception {
+ if (disposed) throw new IllegalStateException("You cannot process a
Disposed Cocoon engine.");
return this.sitemapManager.invoke(environment, "",
this.sitemapFileName, true);
}
1.1.4.27 +2 -1 xml-cocoon/src/org/apache/cocoon/Attic/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Main.java,v
retrieving revision 1.1.4.26
retrieving revision 1.1.4.27
diff -u -r1.1.4.26 -r1.1.4.27
--- Main.java 2001/03/12 05:55:18 1.1.4.26
+++ Main.java 2001/03/19 17:08:32 1.1.4.27
@@ -50,7 +50,7 @@
* Command line entry point.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.4.26 $ $Date: 2001/03/12 05:55:18 $
+ * @version CVS $Revision: 1.1.4.27 $ $Date: 2001/03/19 17:08:32 $
*/
public class Main {
@@ -216,6 +216,7 @@
Main main = new Main(c, context, dest);
main.warmup();
main.process(targets, xspOnly);
+ c.dispose();
log.info("Done");
} catch (Exception e) {
log.fatalError("Exception caught ", e);
No revision
No revision
1.1.2.3 +26 -9
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentHandler.java
Index: CocoonComponentHandler.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentHandler.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- CocoonComponentHandler.java 2001/03/16 21:46:03 1.1.2.2
+++ CocoonComponentHandler.java 2001/03/19 17:08:36 1.1.2.3
@@ -14,22 +14,37 @@
import org.apache.avalon.Context;
import org.apache.avalon.Disposable;
import org.apache.avalon.Initializable;
-import org.apache.avalon.Loggable;
+import org.apache.avalon.AbstractLoggable;
import org.apache.avalon.Poolable;
import org.apache.avalon.Stoppable;
import org.apache.log.Logger;
-class CocoonComponentHandler implements Initializable, Disposable, Loggable {
+class CocoonComponentHandler extends AbstractLoggable implements
Initializable, Disposable {
+ /** Indicates that the Handler is holding a <code>ThreadSafe</code>
Component */
final static int THREADSAFE = 0;
+
+ /** Indicates that the Handler is holding a <code>Poolable</code>
Component */
final static int POOLABLE = 1;
+
+ /** Indicates that the Handler is holding a <code>SingleThreaded</code>
Component */
final static int SINGLETHREADED = 2;
- private Logger log = null;
+ /** The instance of the ComponentFactory that creates and disposes of
the Component */
private ComponentFactory factory;
+
+ /** The pool of components for <code>Poolable</code> Components */
private ComponentPool pool;
+
+ /** The instance of the Component for <code>ThreadSafe</code> Components
*/
private Component instance;
+
+ /** The type of the Component: THREADSAFE, POOLABLE, or SINGLETHREADED */
private final int type;
+
+ /** State management boolean stating whether the Handler is initialized
or not */
private boolean initialized = false;
+
+ /** State management boolean stating whether the Handler is disposed or
not */
private boolean disposed = false;
/**
@@ -69,13 +84,15 @@
* Sets the logger that the ComponentHandler will use.
*/
public void setLogger(Logger log) {
- this.factory.setLogger(log);
+ if (this.factory != null) {
+ this.factory.setLogger(log);
+ }
if (this.pool != null) {
this.pool.setLogger(log);
}
- this.log = log;
+ super.setLogger(log);
}
/**
@@ -91,14 +108,14 @@
this.instance =
(Component)this.factory.newInstance();
}
} catch (Exception e) {
- this.log.error("Cannot use component: " +
this.factory.getCreatedClass().getName(), e);
+ getLogger().error("Cannot use component: " +
this.factory.getCreatedClass().getName(), e);
}
break;
case CocoonComponentHandler.POOLABLE:
try {
this.pool.init();
} catch (Exception e) {
- this.log.error("Cannot use component: " +
this.factory.getCreatedClass().getName(), e);
+ getLogger().error("Cannot use component: " +
this.factory.getCreatedClass().getName(), e);
}
break;
default:
@@ -160,7 +177,7 @@
try {
this.factory.decommission(comp);
} catch (Exception e) {
- this.log.warn("Error decommissioning component: " +
this.factory.getCreatedClass().getName(), e);
+ getLogger().warn("Error decommissioning component: " +
this.factory.getCreatedClass().getName(), e);
}
break;
}
@@ -206,7 +223,7 @@
this.factory = null;
} catch (Exception e) {
- this.log.warn("Error decommissioning component: " +
this.factory.getCreatedClass().getName(), e);
+ getLogger().warn("Error decommissioning component: " +
this.factory.getCreatedClass().getName(), e);
}
}
}
1.1.2.6 +61 -25
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentManager.java
Index: CocoonComponentManager.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentManager.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- CocoonComponentManager.java 2001/03/16 21:50:29 1.1.2.5
+++ CocoonComponentManager.java 2001/03/19 17:08:37 1.1.2.6
@@ -12,6 +12,8 @@
import java.util.Map;
import java.util.Collections;
import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.avalon.ComponentManager;
import org.apache.avalon.Component;
@@ -23,22 +25,19 @@
import org.apache.avalon.Composer;
import org.apache.avalon.configuration.ConfigurationException;
import org.apache.avalon.configuration.DefaultConfiguration;
+import org.apache.avalon.Disposable;
import org.apache.avalon.Initializable;
+import org.apache.avalon.AbstractLoggable;
import org.apache.cocoon.util.ClassUtils;
import org.apache.cocoon.util.RoleUtils;
import org.apache.cocoon.Roles;
-import org.apache.log.Logger;
-import org.apache.avalon.Loggable;
-
/** Default component manager for Cocoon's non sitemap components.
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/03/16 21:50:29 $
+ * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/03/19 17:08:37 $
*/
-public class CocoonComponentManager implements ComponentManager, Loggable,
Configurable, Contextualizable {
-
- protected Logger log;
+public class CocoonComponentManager extends AbstractLoggable implements
ComponentManager, Configurable, Contextualizable, Disposable {
/** The application context for components
*/
@@ -52,6 +51,9 @@
*/
private Map componentHandlers;
+ /** Is the Manager disposed or not? */
+ private boolean disposed = false;
+
/** Construct a new default component manager.
*/
public CocoonComponentManager() {
@@ -59,36 +61,63 @@
componentHandlers = Collections.synchronizedMap(new HashMap());
componentMapping = Collections.synchronizedMap(new HashMap());
}
-
- public void setLogger(Logger logger) {
- if (this.log == null) {
- this.log = logger;
- }
- }
+ /** Set up the Component's Context.
+ */
public void contextualize(Context context) {
if (this.context == null) {
this.context = context;
}
}
- /** Return an instance of a component.
+ /** Properly dispose of the Child handlers.
*/
+ public synchronized void dispose() {
+ this.disposed = true;
+
+ Iterator keys = this.componentHandlers.keySet().iterator();
+ List keyList = new ArrayList();
+
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ CocoonComponentHandler handler = (CocoonComponentHandler)
+ this.componentHandlers.get(key);
+
+ handler.dispose();
+ keyList.add(key);
+ }
+
+ keys = keyList.iterator();
+
+ while (keys.hasNext()) {
+ this.componentHandlers.remove(keys.next());
+ }
+
+ keyList.clear();
+ }
+
+ /**
+ * Return an instance of a component based on a Role. The Role is
usually the Interface's
+ * Fully Qualified Name(FQN)--unless there are multiple Components for
the same Role. In that
+ * case, the Role's FQN is appended with "Selector", and we return a
ComponentSelector.
+ */
public Component lookup( String role )
throws ComponentManagerException {
+ if (disposed) throw new IllegalStateException("You cannot lookup
components on a disposed ComponentManager");
+
CocoonComponentHandler handler = null;
Component component = null;
if ( role == null ) {
- log.error("CocoonComponentManager Attempted to retrieve
component with null role.");
+ getLogger().error("CocoonComponentManager Attempted to retrieve
component with null role.");
throw new ComponentManagerException("Attempted to retrieve
component with null role.");
}
handler = (CocoonComponentHandler) this.componentHandlers.get(role);
// Retrieve the instance of the requested component
if ( handler == null ) {
- this.log.debug("Could not find ComponentHandler, attempting to
create one for role: " + role);
+ getLogger().debug("Could not find ComponentHandler, attempting
to create one for role: " + role);
Class componentClass = null;
Configuration config = new DefaultConfiguration("", "-");
@@ -96,10 +125,10 @@
componentClass =
ClassUtils.loadClass(RoleUtils.defaultClass(role));
handler = new CocoonComponentHandler(componentClass, config,
this, this.context);
- handler.setLogger(this.log);
+ handler.setLogger(getLogger());
handler.init();
} catch (Exception e) {
- log.error("CocoonComponentManager Could not find component
for role: " + role, e);
+ getLogger().error("CocoonComponentManager Could not find
component for role: " + role, e);
throw new ComponentManagerException("Could not find
component for role: " + role, e);
}
@@ -124,6 +153,9 @@
return component;
}
+ /**
+ * Configure the ComponentManager.
+ */
public void configure(Configuration conf) throws ConfigurationException {
// Set components
@@ -142,10 +174,10 @@
}
try {
- log.debug("Adding component (" + role + " = " + className +
")");
+ getLogger().debug("Adding component (" + role + " = " +
className + ")");
this.addComponent(role,ClassUtils.loadClass(className),e[i]);
} catch ( Exception ex ) {
- log.error("Could not load class " + className, ex);
+ getLogger().error("Could not load class " + className, ex);
throw new ConfigurationException("Could not get class " +
className
+ " for role " + role, ex);
}
@@ -164,10 +196,10 @@
}
try {
- log.debug("Adding component (" + role + " = " +
className + ")");
+ getLogger().debug("Adding component (" + role + " = " +
className + ")");
this.addComponent(role, ClassUtils.loadClass(className),
co);
} catch ( Exception ex ) {
- log.error("Could not load class " + className, ex);
+ getLogger().error("Could not load class " + className,
ex);
throw new ConfigurationException("Could not get class "
+ className
+ " for role " + role, ex);
}
@@ -175,6 +207,10 @@
}
}
+ /**
+ * Release a Component. This implementation makes sure it has a handle
on the propper
+ * ComponentHandler, and let's the ComponentHandler take care of the
actual work.
+ */
public void release(Component component) {
if (component == null) return;
CocoonComponentHandler handler = (CocoonComponentHandler)
this.componentMapping.get(component);
@@ -192,7 +228,7 @@
throws ComponentManagerException {
try {
CocoonComponentHandler handler = new
CocoonComponentHandler(component, config, this, this.context);
- handler.setLogger(this.log);
+ handler.setLogger(getLogger());
this.componentHandlers.put(role, handler);
} catch (Exception e) {
throw new ComponentManagerException ("Could not set up Component
for role: " + role, e);
@@ -206,10 +242,10 @@
public void addComponentInstance(String role, Object instance) {
try {
CocoonComponentHandler handler = new
CocoonComponentHandler((Component) instance);
- handler.setLogger(this.log);
+ handler.setLogger(getLogger());
this.componentHandlers.put(role, handler);
} catch (Exception e) {
- this.log.warn("Could not set up Component for role: " + role, e);
+ getLogger().warn("Could not set up Component for role: " + role,
e);
}
}
}
1.1.2.5 +62 -24
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentSelector.java
Index: CocoonComponentSelector.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentSelector.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- CocoonComponentSelector.java 2001/03/16 21:19:26 1.1.2.4
+++ CocoonComponentSelector.java 2001/03/19 17:08:38 1.1.2.5
@@ -12,6 +12,8 @@
import java.util.Map;
import java.util.Collections;
import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.avalon.ComponentManager;
import org.apache.avalon.ComponentSelector;
@@ -24,23 +26,20 @@
import org.apache.avalon.Composer;
import org.apache.avalon.configuration.ConfigurationException;
import org.apache.avalon.configuration.DefaultConfiguration;
+import org.apache.avalon.AbstractLoggable;
+import org.apache.avalon.Disposable;
import org.apache.avalon.ThreadSafe;
import org.apache.cocoon.util.ClassUtils;
import org.apache.cocoon.util.RoleUtils;
import org.apache.cocoon.Roles;
-import org.apache.log.Logger;
-import org.apache.avalon.Loggable;
-
/** Default component manager for Cocoon's non sitemap components.
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/03/16 21:19:26 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/03/19 17:08:38 $
*/
-public class CocoonComponentSelector implements Contextualizable,
ComponentSelector, Composer, Configurable, ThreadSafe, Loggable {
-
- protected Logger log;
+public class CocoonComponentSelector extends AbstractLoggable implements
Contextualizable, ComponentSelector, Composer, Configurable, ThreadSafe,
Disposable {
/** The application context for components
*/
@@ -50,16 +49,20 @@
*/
private ComponentManager manager;
- /** Static component handlers.
+ /** Dynamic component handlers mapping.
*/
private Map componentMapping;
+ /** Static configuraiton object.
+ */
private Configuration conf = null;
/** Static component handlers.
*/
private Map componentHandlers;
+ private boolean disposed = false;
+
/** Construct a new default component manager.
*/
public CocoonComponentSelector() {
@@ -67,35 +70,64 @@
componentHandlers = Collections.synchronizedMap(new HashMap());
componentMapping = Collections.synchronizedMap(new HashMap());
}
-
- public void setLogger(Logger logger) {
- if (this.log == null) {
- this.log = logger;
- }
- }
+ /** Provide the application Context.
+ */
public void contextualize(Context context) {
if (this.context == null) {
this.context = context;
}
}
+ /** Compose the ComponentSelector so that we know what the parent
ComponentManager is.
+ */
public void compose(ComponentManager manager) throws
ComponentManagerException {
if (this.manager == null) {
this.manager = manager;
}
}
+
+ /**
+ * Properly dispose of all the ComponentHandlers.
+ */
+ public synchronized void dispose() {
+ this.disposed = true;
+
+ Iterator keys = this.componentHandlers.keySet().iterator();
+ List keyList = new ArrayList();
+
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ CocoonComponentHandler handler = (CocoonComponentHandler)
+ this.componentHandlers.get(key);
+
+ handler.dispose();
+ keyList.add(key);
+ }
+
+ keys = keyList.iterator();
+
+ while (keys.hasNext()) {
+ this.componentHandlers.remove(keys.next());
+ }
+
+ keyList.clear();
+ }
- /** Return an instance of a component.
+ /**
+ * Return an instance of a component based on a hint. The Composer has
already selected the
+ * role, so the only part left it to make sure the Component is handled.
*/
public Component select( Object hint )
throws ComponentManagerException {
+ if (disposed) throw new IllegalStateException("You cannot select a
Component from a disposed ComponentSelector");
+
CocoonComponentHandler handler = null;
Component component = null;
if ( hint == null ) {
- log.error(this.conf.getName() + ": CocoonComponentSelector
Attempted to retrieve component with null hint.");
+ getLogger().error(this.conf.getName() + ":
CocoonComponentSelector Attempted to retrieve component with null hint.");
throw new ComponentManagerException("Attempted to retrieve
component with null hint.");
}
@@ -119,9 +151,12 @@
return component;
}
+ /**
+ * Default Configuration handler for ComponentSelector.
+ */
public void configure(Configuration conf) throws ConfigurationException {
this.conf = conf;
- log.debug("CocoonComponentSelector setting up with root element: " +
conf.getName());
+ getLogger().debug("CocoonComponentSelector setting up with root
element: " + conf.getName());
Configuration[] instances = conf.getChildren("component-instance");
for (int i = 0; i < instances.length; i++) {
@@ -131,12 +166,15 @@
try {
this.addComponent(hint, ClassUtils.loadClass(className),
instances[i]);
} catch (Exception e) {
- log.error("CocoonComponentSelector The component instance
for \"" + hint + "\" has an invalid class name.", e);
+ getLogger().error("CocoonComponentSelector The component
instance for \"" + hint + "\" has an invalid class name.", e);
throw new ConfigurationException("The component instance for
'" + hint + "' has an invalid class name.", e);
}
}
}
+ /**
+ * Release the Component to the propper ComponentHandler.
+ */
public void release(Component component) {
if (component == null) return;
CocoonComponentHandler handler = (CocoonComponentHandler)
this.componentMapping.get(component);
@@ -154,12 +192,12 @@
throws ComponentManagerException {
try {
CocoonComponentHandler handler = new
CocoonComponentHandler(component, config, this.manager, this.context);
- handler.setLogger(this.log);
+ handler.setLogger(getLogger());
handler.init();
this.componentHandlers.put(hint, handler);
- this.log.debug("Adding " + component.getName() + " for " +
hint.toString());
+ getLogger().debug("Adding " + component.getName() + " for " +
hint.toString());
} catch (Exception e) {
- this.log.error("Could not set up Component for hint: " + hint,
e);
+ getLogger().error("Could not set up Component for hint: " +
hint, e);
throw new ComponentManagerException ("Could not set up Component
for hint: " + hint, e);
}
}
@@ -171,12 +209,12 @@
public void addComponentInstance(String hint, Object instance) {
try {
CocoonComponentHandler handler = new
CocoonComponentHandler((Component) instance);
- handler.setLogger(this.log);
+ handler.setLogger(getLogger());
handler.init();
this.componentHandlers.put(hint, handler);
- this.log.debug("Adding " + instance.getClass().getName() + " for
" + hint.toString());
+ getLogger().debug("Adding " + instance.getClass().getName() + "
for " + hint.toString());
} catch (Exception e) {
- this.log.error("Could not set up Component for hint: " + hint,
e);
+ getLogger().error("Could not set up Component for hint: " +
hint, e);
}
}
}
1.1.2.3 +9 -13
xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentFactory.java
Index: ComponentFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentFactory.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ComponentFactory.java 2001/03/16 19:54:01 1.1.2.2
+++ ComponentFactory.java 2001/03/19 17:08:38 1.1.2.3
@@ -23,16 +23,14 @@
import org.apache.avalon.Disposable;
import org.apache.avalon.Stoppable;
import org.apache.avalon.Startable;
-
-import org.apache.log.Logger;
+import org.apache.avalon.AbstractLoggable;
import org.apache.avalon.Loggable;
/** Factory for Cocoon components.
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/03/16 19:54:01 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/03/19 17:08:38 $
*/
-public class ComponentFactory implements ObjectFactory, ThreadSafe, Loggable
{
- private Logger log;
+public class ComponentFactory extends AbstractLoggable implements
ObjectFactory, ThreadSafe {
/** The class which this <code>ComponentFactory</code>
* should create.
@@ -63,16 +61,10 @@
this.context = context;
}
- public void setLogger(Logger logger) {
- if (this.log == null) {
- this.log = logger;
- }
- }
-
public Object newInstance() throws Exception {
Object comp = componentClass.newInstance();
- log.debug("ComponentFactory creating new instance of "
+ getLogger().debug("ComponentFactory creating new instance of "
+ componentClass.getName() + "."
);
@@ -81,7 +73,7 @@
}
if ( comp instanceof Loggable) {
- ((Loggable)comp).setLogger(this.log);
+ ((Loggable)comp).setLogger(getLogger());
}
if ( comp instanceof Composer) {
@@ -108,6 +100,10 @@
}
public final void decommission(Object comp) throws Exception {
+ getLogger().debug("ComponentFactory decommissioning instance of "
+ + componentClass.getName() + "."
+ );
+
if ( comp instanceof Stoppable ) {
((Stoppable)comp).stop();
}
1.1.2.3 +4 -13
xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentPool.java
Index: ComponentPool.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentPool.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ComponentPool.java 2001/03/16 19:53:59 1.1.2.2
+++ ComponentPool.java 2001/03/19 17:08:39 1.1.2.3
@@ -11,28 +11,25 @@
import org.apache.avalon.Poolable;
import org.apache.avalon.ThreadSafe;
-import org.apache.avalon.Loggable;
+//import org.apache.avalon.Loggable;
import org.apache.avalon.util.pool.Pool;
import org.apache.avalon.util.pool.ObjectFactory;
import org.apache.avalon.Recyclable;
import org.apache.cocoon.components.ComponentFactory;
+import org.apache.avalon.AbstractLoggable;
-import org.apache.log.Logger;
-
/**
* This is a implementation of <code>Pool</code> for SitemapComponents
* that is thread safe.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
*/
-public class ComponentPool implements Pool, ThreadSafe, Loggable {
+public class ComponentPool extends AbstractLoggable implements Pool,
ThreadSafe {
public final static int DEFAULT_POOL_SIZE = 8;
public final static int DEFAULT_WAIT_TIME = (5*100);
- private Logger log;
-
/** The resources that are currently free */
protected Vector availableResources;
@@ -84,12 +81,6 @@
availableResources.addElement(m_factory.newInstance());
}
- public void setLogger(Logger log) {
- if (this.log == null) {
- this.log = log;
- }
- }
-
/** Allocates a resource when the pool is empty. By default, this method
* returns null, indicating that the requesting thread must wait.
This
* allows a thread pool to expand when necessary, allowing for
spikes in
@@ -100,7 +91,7 @@
throws Exception
{
Poolable poolable = (Poolable)m_factory.newInstance();
- log.debug("Component Pool - creating Overflow Resource:"
+ getLogger().debug("Component Pool - creating Overflow Resource:"
+ " Resource=" + poolable
+ " Available=" + availableResources.size()
+ " Used=" + usedResources.size() );
No revision
No revision
1.1.4.71 +8 -1
xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
retrieving revision 1.1.4.70
retrieving revision 1.1.4.71
diff -u -r1.1.4.70 -r1.1.4.71
--- CocoonServlet.java 2001/03/12 04:39:04 1.1.4.70
+++ CocoonServlet.java 2001/03/19 17:08:44 1.1.4.71
@@ -62,7 +62,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Nicola Ken Barozzi</a> Aisa
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.4.70 $ $Date: 2001/03/12 04:39:04 $
+ * @version CVS $Revision: 1.1.4.71 $ $Date: 2001/03/19 17:08:44 $
*/
public class CocoonServlet extends HttpServlet {
@@ -478,10 +478,17 @@
c.setLogger(this.log);
c.init();
this.creationTime = new Date().getTime();
+
+ if (this.cocoon != null) {
+ this.cocoon.dispose();
+ this.cocoon = null;
+ }
+
this.cocoon = c;
} catch (Exception e) {
log.error("Exception reloading", e);
this.exception = e;
+ this.cocoon.dispose();
this.cocoon = null;
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]