Author: bago
Date: Sun Oct 18 12:02:34 2009
New Revision: 826417

URL: http://svn.apache.org/viewvc?rev=826417&view=rev
Log:
Trying to move from inheritance to configuration for the protocols 
HandlerChains.

Modified:
    
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java
    
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
    
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServerComposed.java
    
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AsyncSMTPServer.java
    
james/server/trunk/socket-shared-library/src/main/java/org/apache/james/socket/shared/AbstractHandlerChain.java

Modified: 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java
 (original)
+++ 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java
 Sun Oct 18 12:02:34 2009
@@ -29,6 +29,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.commons.logging.impl.AvalonLogger;
 import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.pop3server.core.CoreCmdHandlerLoader;
 import org.apache.james.services.MailServer;
 import org.apache.james.socket.AbstractProtocolServer;
 import org.apache.james.socket.api.ProtocolHandler;
@@ -129,7 +130,10 @@
         handlerChain.setLog(new AvalonLogger(getLogger()));
         
         //read from the XML configuration and create and configure each of the 
handlers
-        handlerChain.configure(new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
+        JamesConfiguration jamesConfiguration = new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain"));
+        if (jamesConfiguration.getProperty("coreHandlersPackage") == null)
+            jamesConfiguration.addProperty("coreHandlersPackage", 
CoreCmdHandlerLoader.class.getName());
+        handlerChain.configure(jamesConfiguration);
     }
 
     @Override

Modified: 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java
 (original)
+++ 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java
 Sun Oct 18 12:02:34 2009
@@ -32,6 +32,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.commons.logging.impl.AvalonLogger;
 import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.remotemanager.core.CoreCmdHandlerLoader;
 import org.apache.james.services.MailServer;
 import org.apache.james.socket.AbstractProtocolServer;
 import org.apache.james.socket.api.ProtocolHandler;
@@ -152,7 +153,10 @@
         handlerChain.setLog(new AvalonLogger(getLogger()));
         
         //read from the XML configuration and create and configure each of the 
handlers
-        handlerChain.configure(new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
+        JamesConfiguration jamesConfiguration = new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain"));
+        if (jamesConfiguration.getProperty("coreHandlersPackage") == null)
+            jamesConfiguration.addProperty("coreHandlersPackage", 
CoreCmdHandlerLoader.class.getName());
+        handlerChain.configure(jamesConfiguration);
     }
     
 

Modified: 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
 Sun Oct 18 12:02:34 2009
@@ -35,6 +35,7 @@
 import org.apache.james.smtpserver.protocol.SMTPConfiguration;
 import org.apache.james.smtpserver.protocol.SMTPHandlerChain;
 import org.apache.james.smtpserver.protocol.SMTPServerMBean;
+import org.apache.james.smtpserver.protocol.core.CoreCmdHandlerLoader;
 import org.apache.james.socket.AbstractProtocolServer;
 import org.apache.james.socket.api.ProtocolHandler;
 import org.apache.james.socket.configuration.JamesConfiguration;
@@ -242,7 +243,10 @@
         handlerChain.setLog(new AvalonLogger(getLogger()));
         
         //read from the XML configuration and create and configure each of the 
handlers
-        handlerChain.configure(new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
+        JamesConfiguration jamesConfiguration = new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain"));
+        if (jamesConfiguration.getProperty("coreHandlersPackage") == null)
+            jamesConfiguration.addProperty("coreHandlersPackage", 
CoreCmdHandlerLoader.class.getName());
+        handlerChain.configure(jamesConfiguration);
     }
 
     @Override

Modified: 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServerComposed.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServerComposed.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServerComposed.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServerComposed.java
 Sun Oct 18 12:02:34 2009
@@ -40,6 +40,7 @@
 import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.protocol.SMTPConfiguration;
 import org.apache.james.smtpserver.protocol.SMTPHandlerChain;
+import org.apache.james.smtpserver.protocol.core.CoreCmdHandlerLoader;
 import org.apache.james.socket.AvalonProtocolServer;
 import org.apache.james.socket.api.ProtocolHandler;
 import org.apache.james.socket.api.ProtocolHandlerFactory;
@@ -268,7 +269,10 @@
         handlerChain.setLog(new AvalonLogger(getLogger()));
         
         //read from the XML configuration and create and configure each of the 
handlers
-        handlerChain.configure(new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
+        JamesConfiguration jamesConfiguration = new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain"));
+        if (jamesConfiguration.getProperty("coreHandlersPackage") == null)
+            jamesConfiguration.addProperty("coreHandlersPackage", 
CoreCmdHandlerLoader.class.getName());
+        handlerChain.configure(jamesConfiguration);
     }
 
     /**

Modified: 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AsyncSMTPServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AsyncSMTPServer.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AsyncSMTPServer.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AsyncSMTPServer.java
 Sun Oct 18 12:02:34 2009
@@ -31,6 +31,7 @@
 import org.apache.james.smtpserver.protocol.SMTPConfiguration;
 import org.apache.james.smtpserver.protocol.SMTPHandlerChain;
 import org.apache.james.smtpserver.protocol.SMTPServerMBean;
+import org.apache.james.smtpserver.protocol.core.CoreCmdHandlerLoader;
 import org.apache.james.socket.configuration.JamesConfiguration;
 import org.apache.james.socket.mina.AbstractAsyncServer;
 import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
@@ -198,7 +199,10 @@
         handlerChain.setLog(new AvalonLogger(getLogger()));
         
         //read from the XML configuration and create and configure each of the 
handlers
-        handlerChain.configure(new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
+        JamesConfiguration jamesConfiguration = new 
JamesConfiguration(handlerConfiguration.getChild("handlerchain"));
+        if (jamesConfiguration.getProperty("coreHandlersPackage") == null)
+            jamesConfiguration.addProperty("coreHandlersPackage", 
CoreCmdHandlerLoader.class.getName());
+        handlerChain.configure(jamesConfiguration);
     }
 
 

Modified: 
james/server/trunk/socket-shared-library/src/main/java/org/apache/james/socket/shared/AbstractHandlerChain.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/main/java/org/apache/james/socket/shared/AbstractHandlerChain.java?rev=826417&r1=826416&r2=826417&view=diff
==============================================================================
--- 
james/server/trunk/socket-shared-library/src/main/java/org/apache/james/socket/shared/AbstractHandlerChain.java
 (original)
+++ 
james/server/trunk/socket-shared-library/src/main/java/org/apache/james/socket/shared/AbstractHandlerChain.java
 Sun Oct 18 12:02:34 2009
@@ -40,7 +40,7 @@
  * 
  *
  */
-public abstract class AbstractHandlerChain implements LogEnabled, Configurable 
{
+public class AbstractHandlerChain implements LogEnabled, Configurable {
     
     /** This log is the fall back shared by all instances */
     private static final Log FALLBACK_LOG = 
LogFactory.getLog(AbstractHandlerChain.class);
@@ -201,17 +201,18 @@
     @SuppressWarnings("unchecked")
     protected void loadHandlers() throws Exception {
         if (commonsConf != null && commonsConf instanceof 
HierarchicalConfiguration) {
+            
             List<org.apache.commons.configuration.Configuration> children = 
((HierarchicalConfiguration) commonsConf).configurationsAt("handler");
             ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
 
+            String coreCmdName = (String) 
commonsConf.getProperty("coreHandlersPackage");
+            // load the core handlers
+            loadClass(classLoader, coreCmdName,
+                    addHandler(coreCmdName));
+
             // load the configured handlers
             if (children != null && children.isEmpty() == false) {
 
-                String coreCmdName = getCoreCmdHandlerLoader().getName();
-                // load the core handlers
-                loadClass(classLoader, coreCmdName,
-                        addHandler(coreCmdName));
-                
                 for (int i = 0; i < children.size(); i++) {
                     org.apache.commons.configuration.Configuration hConf = 
children.get(i);
                     String className = hConf.getString("@class");
@@ -245,11 +246,4 @@
         }    
     }
     
-    /**
-     * Return the Class which lists all core commands
-     * 
-     * @return class
-     */
-    protected abstract Class<?> getCoreCmdHandlerLoader();
-    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to