Author: rdonkin
Date: Fri Sep  4 15:48:29 2009
New Revision: 811453

URL: http://svn.apache.org/viewvc?rev=811453&view=rev
Log:
Switch from Avalon to JSR250 initialisation. This will allow injection of 
services.

Modified:
    
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
    
james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapServer.java
    
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
    
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
    
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
    
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
    
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java

Modified: 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
 (original)
+++ 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
 Fri Sep  4 15:48:29 2009
@@ -21,6 +21,16 @@
 
 package org.apache.james.socket;
 
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+import java.security.Provider;
+import java.security.Security;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.PostConstruct;
+
 import 
org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory;
 import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
 import 
org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
@@ -33,7 +43,6 @@
 import org.apache.avalon.excalibur.pool.Pool;
 import org.apache.avalon.excalibur.pool.Poolable;
 import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -45,21 +54,13 @@
 import org.apache.excalibur.thread.ThreadPool;
 import org.apache.james.api.dnsservice.DNSService;
 
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
-import java.security.Provider;
-import java.security.Security;
-import java.util.concurrent.atomic.AtomicLong;
-
 /**
  * Server which creates connection handlers. All new James service must
  * inherit from this abstract implementation.
  *
  */
 public abstract class AbstractJamesService extends AbstractHandlerFactory
-    implements Serviceable, Configurable, Disposable, Initializable, 
ConnectionHandlerFactory, ObjectFactory {
+    implements Serviceable, Configurable, Disposable, 
ConnectionHandlerFactory, ObjectFactory {
 
     /**
      * The default value for the connection timeout.
@@ -446,7 +447,8 @@
     /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
-    public void initialize() throws Exception {
+    @PostConstruct
+    public final void initialize() throws Exception {
         if (!isEnabled()) {
             getLogger().info(getServiceType() + " Disabled");
             System.out.println(getServiceType() + " Disabled");
@@ -472,6 +474,17 @@
 
         theWatchdogFactory = getWatchdogFactory();
 
+        // Allow subclasses to perform initialisation
+        doInit();
+    }
+    
+    /**
+     * Hook for subclasses to perform an required initialisation.
+     * Called after the super class has completed it's initialisation.
+     * @throws Exception
+     */
+    protected void doInit() throws Exception {
+        
     }
 
     private void initializeThreadPool(ThreadManager threadManager) {

Modified: 
james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapServer.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapServer.java
 (original)
+++ 
james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapServer.java
 Fri Sep  4 15:48:29 2009
@@ -72,13 +72,10 @@
         super.dispose();
     }
 
-
-
     @Override
-    public void initialize() throws Exception {
+    protected void doInit() throws Exception {
         getLogger().debug("Initialising...");
         factory.initialize();
-        super.initialize();
     }
 
 

Modified: 
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
 (original)
+++ 
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
 Fri Sep  4 15:48:29 2009
@@ -190,7 +190,7 @@
     private void finishSetUp(SMTPTestConfiguration testConfiguration) throws 
Exception {
         testConfiguration.init();
         ContainerUtil.configure(m_smtpServer, testConfiguration);
-        ContainerUtil.initialize(m_smtpServer);
+        m_smtpServer.initialize();
         
m_mailServer.setMaxMessageSizeBytes(m_testConfiguration.getMaxMessageSize()*1024);
     }
 

Modified: 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
 (original)
+++ 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
 Fri Sep  4 15:48:29 2009
@@ -89,7 +89,7 @@
             throws Exception {
         testConfiguration.init();
         ContainerUtil.configure(m_pop3Server, testConfiguration);
-        ContainerUtil.initialize(m_pop3Server);
+        m_pop3Server.initialize();
     }
 
     private MockServiceManager setUpServiceManager() throws ServiceException {

Modified: 
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
 (original)
+++ 
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
 Fri Sep  4 15:48:29 2009
@@ -99,7 +99,7 @@
         testConfiguration.init();
         try {
             ContainerUtil.configure(m_remoteManager, testConfiguration);
-            ContainerUtil.initialize(m_remoteManager);
+            m_remoteManager.initialize();
         } catch (Exception e) {
             throw new RuntimeException(e);
         }

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=811453&r1=811452&r2=811453&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
 Fri Sep  4 15:48:29 2009
@@ -238,11 +238,8 @@
         }
     }
     
-    /**
-     * @see org.apache.james.core.AbstractJamesService#initialize()
-     */
-    public void initialize() throws Exception {
-        super.initialize();
+    @Override
+    protected void doInit() throws Exception {
         ContainerUtil.initialize(handlerChain);
     }
 

Modified: 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=811453&r1=811452&r2=811453&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 Fri Sep  4 15:48:29 2009
@@ -191,7 +191,7 @@
     private void finishSetUp(SMTPTestConfiguration testConfiguration) throws 
Exception {
         testConfiguration.init();
         ContainerUtil.configure(m_smtpServer, testConfiguration);
-        ContainerUtil.initialize(m_smtpServer);
+        m_smtpServer.initialize();
         
m_mailServer.setMaxMessageSizeBytes(m_testConfiguration.getMaxMessageSize()*1024);
     }
 



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

Reply via email to