cziegeler 02/05/29 08:05:59 Modified: src/java/org/apache/cocoon/webapps/authentication/components HandlerManager.java Log: More HandlerManager Revision Changes Path 1.2 +40 -17 xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java Index: HandlerManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HandlerManager.java 29 May 2002 14:39:20 -0000 1.1 +++ HandlerManager.java 29 May 2002 15:05:59 -0000 1.2 @@ -51,6 +51,10 @@ package org.apache.cocoon.webapps.authentication.components; import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.SourceResolver; import java.util.*; @@ -58,31 +62,25 @@ * This is a utility class managing the authentication handlers * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: HandlerManager.java,v 1.1 2002/05/29 14:39:20 cziegeler Exp $ + * @version CVS $Id: HandlerManager.java,v 1.2 2002/05/29 15:05:59 cziegeler Exp $ */ public final class HandlerManager { - /** Protect constructor */ - private HandlerManager() {} - - /** The singleton */ - private static HandlerManager manager; + public HandlerManager() {} /** All configured configurations */ - protected List configuredConfigurations = new ArrayList(3); + protected static List configuredConfigurations = new ArrayList(3); - /**Get Singleton instance */ - public static HandlerManager getHandlerManager() { - if ( null == manager ) { - manager = new HandlerManager(); - } - return manager; - } + /** All configured handlers */ + protected static Map configuredHandlers = new HashMap(4); /** * Add new configurations to the pool */ - public void addConfiguration(Configuration conf) { + public void addConfiguration(Configuration conf, + SourceResolver resolver, + Request request) + throws ConfigurationException, ProcessingException { if (null != conf && !this.configuredConfigurations.contains(conf)) { synchronized (this.configuredConfigurations) { @@ -95,7 +93,7 @@ Configuration[] handlers = handlersWrapper.getChildren("handler"); if ( null != handlers ) { for(int i=0; i<handlers.length;i++) - this.addHandler( handlers[i]); + this.addHandler( handlers[i], resolver, request); } } } @@ -106,7 +104,31 @@ /** * Add one handler configuration */ - protected void addHandler(Configuration handler) { + protected void addHandler(Configuration configuration, + SourceResolver resolver, + Request request) + throws ConfigurationException, ProcessingException { + // get handler name + final String name = configuration.getAttribute("name"); + + // test if handler is unique + if (this.configuredHandlers.get(name) != null) { + throw new ConfigurationException("Handler names must be unique: " + name); + } + + // create handler + Handler currentHandler = new Handler(name); + + // store handler + this.configuredHandlers.put(name, currentHandler); + + try { + currentHandler.configure(resolver,request, configuration); + } catch (org.xml.sax.SAXException se) { + throw new ProcessingException("Exception during configuration of handler: " + name, se); + } catch (java.io.IOException se) { + throw new ProcessingException("Exception during configuration of handler: " + name, se); + } } /** @@ -114,5 +136,6 @@ */ public void clearConfigurations() { this.configuredConfigurations.clear(); + this.configuredHandlers.clear(); } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]