Author: norman
Date: Fri Oct 30 16:00:40 2009
New Revision: 831359

URL: http://svn.apache.org/viewvc?rev=831359&view=rev
Log: (empty)

Added:
    
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/AvalonPOP3Server.java
    
james/server/trunk/pop3server-function/src/main/resources/org/apache/james/pop3server/AvalonPOP3Server.xinfo
      - copied unchanged from r829709, 
james/server/trunk/pop3server-function/src/main/resources/org/apache/james/pop3server/POP3Server.xinfo
    
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/AvalonPOP3ServerTest.java
    
james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/AvalonSMTPServer.xinfo
      - copied unchanged from r829709, 
james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo
Removed:
    
james/server/trunk/pop3server-function/src/main/resources/org/apache/james/pop3server/POP3Server.xinfo
    
james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo
Modified:
    james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
    
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Server.java
    
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
    
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/AvalonSMTPServer.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/AsyncSMTPServerTest.java

Modified: james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml?rev=831359&r1=831358&r2=831359&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml Fri Oct 
30 16:00:40 2009
@@ -126,7 +126,7 @@
   </block>
         
   <!-- POP3 Server -->
-  <block name="pop3server" class="org.apache.james.pop3server.POP3Server" >
+  <block name="pop3server" 
class="org.apache.james.pop3server.AvalonPOP3Server" >
     <provide name="localusersrepository" 
role="org.apache.james.api.user.UsersRepository"/>
     <provide name="sockets"
              
role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
@@ -141,7 +141,7 @@
   </block>
 
   <!-- SMTP Server -->
-  <block name="smtpserver" class="org.apache.james.smtpserver.SMTPServer" >
+  <block name="smtpserver" 
class="org.apache.james.smtpserver.AvalonSMTPServer" >
     <provide name="James" role="org.apache.mailet.MailetContext"/>
     <provide name="localusersrepository" 
role="org.apache.james.api.user.UsersRepository"/>
     <provide name="dnsserver" 
role="org.apache.james.api.dnsservice.DNSService"/>

Added: 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/AvalonPOP3Server.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/AvalonPOP3Server.java?rev=831359&view=auto
==============================================================================
--- 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/AvalonPOP3Server.java
 (added)
+++ 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/AvalonPOP3Server.java
 Fri Oct 30 16:00:40 2009
@@ -0,0 +1,164 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.pop3server;
+
+import org.apache.avalon.cornerstone.services.sockets.SocketManager;
+import org.apache.avalon.cornerstone.services.threads.ThreadManager;
+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;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.AvalonLogger;
+import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.bridge.GuiceInjected;
+import org.apache.james.services.FileSystem;
+import org.apache.james.services.MailServer;
+import org.apache.james.socket.JamesConnectionManager;
+import org.apache.james.socket.api.ProtocolHandlerFactory;
+import org.apache.james.util.ConfigurationAdapter;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+import com.google.inject.name.Names;
+
+public class AvalonPOP3Server implements GuiceInjected, Initializable, 
Serviceable, Configurable, LogEnabled, POP3ServerMBean {
+    
+    private FileSystem filesystem;
+    private MailServer mailserver;
+    private DNSService dns;
+    private Log logger;
+    private org.apache.commons.configuration.HierarchicalConfiguration config;
+    private Injector injector;
+    private UsersRepository userRepos;
+    private JamesConnectionManager connectionManager;
+    private SocketManager socketManager;
+    private POP3Server pop3server = new POP3Server();
+    private ThreadManager threadManager;
+    
+    public String getNetworkInterface() {
+        return pop3server.getNetworkInterface();
+    }
+
+    public int getPort() {
+        return pop3server.getPort();
+    }
+
+    public String getSocketType() {
+        return pop3server.getSocketType();
+    }
+
+    public boolean isEnabled() {
+        return pop3server.isEnabled();
+    }
+
+    /**
+     * @see 
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration config) throws ConfigurationException {
+        try {
+            this.config = new ConfigurationAdapter(config);
+        } catch (org.apache.commons.configuration.ConfigurationException e) {
+            throw new ConfigurationException("Unable to convert 
configuration", e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        dns = (DNSService) manager.lookup(DNSService.ROLE);
+        mailserver = (MailServer) manager.lookup(MailServer.ROLE);
+        filesystem = (FileSystem) manager.lookup(FileSystem.ROLE);
+        userRepos = (UsersRepository) manager.lookup(UsersRepository.ROLE);
+        socketManager = (SocketManager) manager.lookup(SocketManager.ROLE);
+        connectionManager = (JamesConnectionManager) 
manager.lookup(JamesConnectionManager.ROLE);     
+        threadManager = (ThreadManager) manager.lookup(ThreadManager.ROLE);
+        
+        // thats needed because of used excalibur socket components
+        pop3server.service(manager);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        injector = Guice.createInjector(new POP3ServerModule(), new 
Jsr250Module());
+        injector.injectMembers(pop3server);
+    }
+                 
+    /**
+     * @see 
org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        this.logger = new AvalonLogger(logger);
+    }
+
+    private final class POP3ServerModule extends AbstractModule {
+
+        @Override
+        protected void configure() {
+            
bind(DNSService.class).annotatedWith(Names.named("org.apache.james.api.dnsservice.DNSService")).toInstance(dns);
+            
bind(MailServer.class).annotatedWith(Names.named("org.apache.james.services.MailServer")).toInstance(mailserver);
+            
bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
+            
bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
+            
bind(FileSystem.class).annotatedWith(Names.named("org.apache.james.services.FileSystem")).toInstance(filesystem);
+            
bind(UsersRepository.class).annotatedWith(Names.named("org.apache.james.api.user.UsersRepository")).toInstance(userRepos);
+            
bind(ProtocolHandlerFactory.class).annotatedWith(Names.named("org.apache.james.socket.api.ProtocolHandlerFactory")).toProvider(new
 Provider<ProtocolHandlerFactory>() {
+
+                public ProtocolHandlerFactory get() {
+                    return pop3server;
+                }
+                
+            });
+            
bind(SocketManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.sockets.SocketManager")).toInstance(socketManager);
+            
bind(JamesConnectionManager.class).annotatedWith(Names.named("org.apache.james.socket.JamesConnectionManager")).toInstance(connectionManager);
+            
bind(ThreadManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.threads.ThreadManager")).toInstance(threadManager);
+            // we bind the LoaderService to an Provider to get sure everything 
is there when the SMTPLoaderService get created.
+            
bind(LoaderService.class).annotatedWith(Names.named("org.apache.james.LoaderService")).toProvider(new
 Provider<LoaderService>() {
+
+                public LoaderService get() {
+                    return new SMTPLoaderService();
+                }
+                
+                // Mimic the loaderservice
+                class SMTPLoaderService implements LoaderService {
+                    Injector injector = Guice.createInjector(new 
POP3ServerModule(), new Jsr250Module());
+
+                    public <T> T load(Class<T> type) {
+                        return injector.getInstance(type);
+                    }
+                    
+                }
+                
+            });
+
+        }
+    }
+}

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=831359&r1=831358&r2=831359&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
 Fri Oct 30 16:00:40 2009
@@ -21,6 +21,7 @@
 
 package org.apache.james.pop3server;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 
 import org.apache.commons.configuration.ConfigurationException;
@@ -93,6 +94,12 @@
         this.loader = loader;
     }
 
+    @PostConstruct
+    @Override
+    public void init() throws Exception {
+        super.init();
+    }
+    
     @Override
     protected void onConfigure(final HierarchicalConfiguration configuration) 
throws ConfigurationException {
         if (isEnabled()) {

Added: 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/AvalonPOP3ServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/AvalonPOP3ServerTest.java?rev=831359&view=auto
==============================================================================
--- 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/AvalonPOP3ServerTest.java
 (added)
+++ 
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/AvalonPOP3ServerTest.java
 Fri Oct 30 16:00:40 2009
@@ -0,0 +1,44 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.pop3server;
+
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.james.test.mock.avalon.MockLogger;
+
+public class AvalonPOP3ServerTest extends POP3ServerTest{
+
+    private AvalonPOP3Server m_pop3Server;
+    @Override
+    protected void setUp() throws Exception {
+        m_pop3Server = new AvalonPOP3Server();
+        setUpServiceManager();
+        ContainerUtil.enableLogging(m_pop3Server, new MockLogger());
+        ContainerUtil.service(m_pop3Server, serviceManager);
+        m_testConfiguration = new POP3TestConfiguration(m_pop3ListenerPort);
+    }
+
+    @Override
+    protected void finishSetUp(POP3TestConfiguration testConfiguration)
+            throws Exception {
+        testConfiguration.init();
+        ContainerUtil.configure(m_pop3Server, testConfiguration);
+        ContainerUtil.initialize(m_pop3Server);
+    }
+
+}

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=831359&r1=831358&r2=831359&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 Oct 30 16:00:40 2009
@@ -65,11 +65,11 @@
  * Tests the org.apache.james.smtpserver.SMTPServer unit
  */
 public class POP3ServerTest extends TestCase {
-    private int m_pop3ListenerPort = Util.getNonPrivilegedPort();
+    protected int m_pop3ListenerPort = Util.getNonPrivilegedPort();
 
     private MockMailServer m_mailServer;
 
-    private POP3TestConfiguration m_testConfiguration;
+    protected POP3TestConfiguration m_testConfiguration;
 
     private POP3Server m_pop3Server;
 
@@ -79,7 +79,7 @@
     private MailImpl testMail1;
 
     private MailImpl testMail2;
-    private FakeLoader serviceManager;
+    protected FakeLoader serviceManager;
 
     private MockThreadManager threadManager;
 
@@ -112,14 +112,14 @@
         m_testConfiguration = new POP3TestConfiguration(m_pop3ListenerPort);
     }
 
-    private void finishSetUp(POP3TestConfiguration testConfiguration)
+    protected void finishSetUp(POP3TestConfiguration testConfiguration)
             throws Exception {
         testConfiguration.init();
         m_pop3Server.setConfiguration(new 
ConfigurationAdapter(testConfiguration));
         m_pop3Server.init();
     }
 
-    private void setUpServiceManager() throws ServiceException {
+    protected void setUpServiceManager() throws ServiceException {
         serviceManager = new FakeLoader();
         connectionManager = new SimpleConnectionManager();
         ContainerUtil.enableLogging(connectionManager, new MockLogger());
@@ -157,7 +157,7 @@
             m_pop3Protocol.sendCommand("quit");
             m_pop3Protocol.disconnect();
         }
-        m_pop3Server.dispose();
+        //m_pop3Server.dispose();
         ContainerUtil.dispose(m_mailServer);
         if (testMail1 != null) testMail1.dispose();
         if (testMail2 != null) testMail2.dispose();

Modified: 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/AvalonSMTPServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/AvalonSMTPServer.java?rev=831359&r1=831358&r2=831359&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/AvalonSMTPServer.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/AvalonSMTPServer.java
 Fri Oct 30 16:00:40 2009
@@ -39,7 +39,6 @@
 import org.apache.james.bridge.GuiceInjected;
 import org.apache.james.services.FileSystem;
 import org.apache.james.services.MailServer;
-import org.apache.james.smtpserver.mina.AsyncSMTPServer;
 import org.apache.james.smtpserver.protocol.SMTPServerMBean;
 import org.apache.james.socket.JamesConnectionManager;
 import org.apache.james.socket.api.ProtocolHandlerFactory;
@@ -51,7 +50,6 @@
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Provider;
-import com.google.inject.Singleton;
 import com.google.inject.name.Names;
 
 public class AvalonSMTPServer implements GuiceInjected, Initializable, 
Serviceable, Configurable, LogEnabled, SMTPServerMBean{
@@ -138,7 +136,6 @@
 
         @Override
         protected void configure() {
-            bind(AsyncSMTPServer.class).in(Singleton.class);
             
bind(DNSService.class).annotatedWith(Names.named("org.apache.james.api.dnsservice.DNSService")).toInstance(dns);
             
bind(org.apache.james.smtpserver.protocol.DNSService.class).annotatedWith(Names.named("org.apache.james.smtpserver.protocol.DNSService")).toInstance(dnsServiceAdapter);
             
bind(MailServer.class).annotatedWith(Names.named("org.apache.james.services.MailServer")).toInstance(mailserver);

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=831359&r1=831358&r2=831359&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 Oct 30 16:00:40 2009
@@ -22,7 +22,6 @@
 package org.apache.james.smtpserver;
 
 import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 
 import org.apache.commons.configuration.ConfigurationException;

Modified: 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java?rev=831359&r1=831358&r2=831359&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
 (original)
+++ 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
 Fri Oct 30 16:00:40 2009
@@ -22,11 +22,9 @@
 import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
 import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.ServiceException;
 import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.kernel.mock.FakeLoader;
 import org.apache.james.api.user.UsersRepository;
-import org.apache.james.api.vut.VirtualUserTable;
 import org.apache.james.api.vut.VirtualUserTableStore;
 import org.apache.james.services.FileSystem;
 import org.apache.james.services.MailServer;



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

Reply via email to