bloritsch 01/10/31 12:18:39
Modified: src/org/apache/cocoon/components/source
SourceHandlerImpl.java
Log:
Make SourceHandlerImpl ThreadSafe
Revision Changes Path
1.10 +10 -6
xml-cocoon2/src/org/apache/cocoon/components/source/SourceHandlerImpl.java
Index: SourceHandlerImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/SourceHandlerImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SourceHandlerImpl.java 2001/10/16 15:33:38 1.9
+++ SourceHandlerImpl.java 2001/10/31 20:18:39 1.10
@@ -20,6 +20,7 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.logger.Loggable;
+import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.url.URLFactory;
import org.apache.cocoon.environment.Environment;
@@ -35,11 +36,12 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version $Id: SourceHandlerImpl.java,v 1.9 2001/10/16 15:33:38 cziegeler Exp $
+ * @version $Id: SourceHandlerImpl.java,v 1.10 2001/10/31 20:18:39 bloritsch Exp $
*/
public final class SourceHandlerImpl
extends AbstractLoggable
-implements Configurable, Disposable, Composable, Contextualizable, SourceHandler {
+implements Configurable, Disposable, Composable, Contextualizable, SourceHandler,
+ ThreadSafe {
/** The component manager */
private ComponentManager manager;
@@ -60,21 +62,23 @@
throws ConfigurationException {
try {
getLogger().debug("Getting the SourceFactories");
- this.sourceFactories = new HashMap();
+ HashMap factories = new HashMap();
Configuration[] configs = conf.getChildren("protocol");
SourceFactory sourceFactory = null;
String protocol = null;
for (int i = 0; i < configs.length; i++) {
protocol = configs[i].getAttribute("name");
- if (this.sourceFactories.containsKey(protocol) == true) {
+ if (factories.containsKey(protocol) == true) {
throw new ConfigurationException("SourceFactory defined twice
for protocol: " + protocol);
}
getLogger().debug("\tfor protocol: " + protocol + " " +
configs[i].getAttribute("class"));
sourceFactory = (SourceFactory)
ClassUtils.newInstance(configs[i].getAttribute("class"));
this.init(sourceFactory, configs[i]);
- this.sourceFactories.put(protocol, sourceFactory);
+ factories.put(protocol, sourceFactory);
}
+
+ this.sourceFactories = java.util.Collections.synchronizedMap(factories);
} catch (ConfigurationException e) {
throw e;
} catch (Exception e) {
@@ -157,8 +161,8 @@
public void addFactory(String protocol, SourceFactory factory)
throws ProcessingException {
try {
- this.sourceFactories.put(protocol, factory);
this.init(factory, null);
+ this.sourceFactories.put(protocol, factory);
} catch (ComponentException e) {
throw new ProcessingException("cannot initialize factory: " + factory,
e);
} catch (ContextException e) {
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]