james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r421278 - in /james/server/trunk/src/java/org/apache/james: core/AbstractJamesService.java nntpserver/NNTPServer.java pop3server/POP3Server.java remotemanager/RemoteManager.java smtpserver/SMTPServer.java
Date Wed, 12 Jul 2006 14:38:33 GMT
Author: norman
Date: Wed Jul 12 07:38:32 2006
New Revision: 421278

URL: http://svn.apache.org/viewvc?rev=421278&view=rev
Log:
Extract handler creation to AbstractJamesService. See JAMES-516. This will also give us a
easier and cleaner start in introducing MINA 

Modified:
    james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
    james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java
    james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
    james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java

Modified: james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java?rev=421278&r1=421277&r2=421278&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java (original)
+++ james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java Wed Jul 12
07:38:32 2006
@@ -53,7 +53,7 @@
  *
  */
 public abstract class AbstractJamesService extends AbstractHandlerFactory
-    implements Serviceable, Configurable, Disposable, Initializable, ConnectionHandlerFactory
{
+    implements Serviceable, Configurable, Disposable, Initializable, ConnectionHandlerFactory,
ObjectFactory {
 
     /**
      * The default value for the connection timeout.
@@ -168,11 +168,6 @@
     protected Pool theHandlerPool = null;
 
     /**
-     * The factory used to provide Handler objects
-     */
-    protected ObjectFactory theHandlerFactory = null;
-
-    /**
      * The factory used to generate Watchdog objects
      */
     protected WatchdogFactory theWatchdogFactory = null;
@@ -419,14 +414,14 @@
         getLogger().info(logString);
 
         if (connectionLimit != null) {
-            theHandlerPool = new HardResourceLimitingPool(theHandlerFactory, 5, connectionLimit.intValue());
+            theHandlerPool = new HardResourceLimitingPool((ObjectFactory) this, 5, connectionLimit.intValue());
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Using a bounded pool for "+getServiceType()+" handlers
with upper limit " + connectionLimit.intValue());
             }
         } else {
             // NOTE: The maximum here is not a real maximum.  The handler pool will continue
to
             //       provide handlers beyond this value.
-            theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
+            theHandlerPool = new DefaultPool((ObjectFactory) this, null, 5, 30);
             getLogger().debug("Using an unbounded pool for "+getServiceType()+" handlers.");
         }
     }
@@ -613,6 +608,13 @@
     */  
     public String  getSocketType() {
         return serverSocketType;
+    }
+    
+    /**
+    * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommision(Object)
+    */
+    public void decommission( Object object ) throws Exception {
+        return;
     }
 }
 

Modified: james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java?rev=421278&r1=421277&r2=421278&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java (original)
+++ james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java Wed Jul 12 07:38:32
2006
@@ -17,7 +17,6 @@
 
 package org.apache.james.nntpserver;
 
-import org.apache.avalon.excalibur.pool.ObjectFactory;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceException;
@@ -92,7 +91,6 @@
                 }
             }
         }
-        theHandlerFactory = new NNTPHandlerFactory();
     }
 
     /**
@@ -109,33 +107,21 @@
         return "NNTP Service";
     }
 
+
     /**
-     * The factory for producing handlers.
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
      */
-    private static class NNTPHandlerFactory
-        implements ObjectFactory {
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
-         */
-        public Object newInstance() throws Exception {
-            return new NNTPHandler();
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
-         */
-        public Class getCreatedClass() {
-            return NNTPHandler.class;
-        }
+    public Object newInstance() throws Exception {
+        return new NNTPHandler();
+    }
 
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommission(Object) 
-         */
-        public void decommission( Object object ) throws Exception {
-            return;
-        }
+    /**
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
+     */
+    public Class getCreatedClass() {
+        return NNTPHandler.class;
     }
+          
 
     /**
      * A class to provide NNTP handler configuration to the handlers

Modified: james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java?rev=421278&r1=421277&r2=421278&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java (original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java Wed Jul 12 07:38:32
2006
@@ -17,8 +17,6 @@
 
 package org.apache.james.pop3server;
 
-import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.ObjectFactory;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.container.ContainerUtil;
@@ -116,7 +114,6 @@
             ContainerUtil.configure(handlerChain,handlerConfiguration.getChild("handlerchain"));
 
         }
-        theHandlerFactory = new POP3HandlerFactory();
     }
 
     /**
@@ -135,13 +132,11 @@
 
 
     /**
-     * @see org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory#newHandler()
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
      */
-    protected ConnectionHandler newHandler()
-            throws Exception {
+     public Object newInstance() throws Exception {
+        POP3Handler theHandler = new POP3Handler();
         
-        POP3Handler theHandler = (POP3Handler) super.newHandler();
-
         //pass the handler chain to every POP3handler
         theHandler.setHandlerChain(handlerChain);
 
@@ -149,32 +144,11 @@
     }
 
     /**
-     * The factory for producing handlers.
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
      */
-    private static class POP3HandlerFactory
-        implements ObjectFactory {
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
-         */
-        public Object newInstance() throws Exception {
-            return new POP3Handler();
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
-         */
-        public Class getCreatedClass() {
-            return POP3Handler.class;
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommission(Object) 
-         */
-        public void decommission( Object object ) throws Exception {
-            return;
-        }
-    }
+     public Class getCreatedClass() {
+         return POP3Handler.class;
+     }
 
     /**
      * A class to provide POP3 handler configuration to the handlers

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java?rev=421278&r1=421277&r2=421278&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java Wed Jul
12 07:38:32 2006
@@ -18,7 +18,6 @@
 package org.apache.james.remotemanager;
 
 import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.avalon.excalibur.pool.ObjectFactory;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceException;
@@ -146,7 +145,6 @@
             if (prompt == null) prompt = ""; 
             else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += " ";

         }
-        theHandlerFactory = new RemoteManagerHandlerFactory();
     }
 
     /**
@@ -162,33 +160,19 @@
     public String getServiceType() {
         return "Remote Manager Service";
     }
-
+    
     /**
-     * The factory for producing handlers.
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
      */
-    private static class RemoteManagerHandlerFactory
-        implements ObjectFactory {
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
-         */
-        public Object newInstance() throws Exception {
-            return new RemoteManagerHandler();
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
-         */
-        public Class getCreatedClass() {
-            return RemoteManagerHandler.class;
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommission(Object) 
-         */
-        public void decommission( Object object ) throws Exception {
-            return;
-        }
+    public Object newInstance() throws Exception {
+        return new RemoteManagerHandler();
+    }
+    
+    /**
+    * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
+    */
+    public Class getCreatedClass() {
+        return RemoteManagerHandler.class;
     }
 
     /**

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java?rev=421278&r1=421277&r2=421278&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java Wed Jul 12 07:38:32
2006
@@ -17,8 +17,6 @@
 
 package org.apache.james.smtpserver;
 
-import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.ObjectFactory;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.container.ContainerUtil;
@@ -211,7 +209,6 @@
         } else {
             mailetcontext.setAttribute(Constants.HELLO_NAME, "localhost");
         }
-        theHandlerFactory = new SMTPHandlerFactory();
     }
 
     private void configureAuthorization(Configuration handlerConfiguration) {
@@ -306,45 +303,23 @@
     }
 
     /**
-     * @see org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory#newHandler()
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
      */
-    protected ConnectionHandler newHandler()
-            throws Exception {
-        
-        SMTPHandler theHandler = (SMTPHandler) super.newHandler();
+    public Object newInstance() throws Exception {
+        SMTPHandler theHandler = new SMTPHandler();
 
-        //pass the handler chain to every SMTPhandler
+        // pass the handler chain to every SMTPhandler
         theHandler.setHandlerChain(handlerChain);
 
         return theHandler;
+
     }
 
     /**
-     * The factory for producing handlers.
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
      */
-    private static class SMTPHandlerFactory
-        implements ObjectFactory {
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
-         */
-        public Object newInstance() throws Exception {
-            return new SMTPHandler();
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
-         */
-        public Class getCreatedClass() {
-            return SMTPHandler.class;
-        }
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommission(Object) 
-         */
-        public void decommission( Object object ) throws Exception {
-            return;
-        }
+    public Class getCreatedClass() {
+        return SMTPHandler.class;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message