Author: norman
Date: Sun Oct  4 15:10:49 2009
New Revision: 821546

URL: http://svn.apache.org/viewvc?rev=821546&view=rev
Log:
Heavy rewrite of RemoteManager to follow the same pattern as SMTPServer and 
POP3Server (JAMES-929). Only the HELP command is missing 

Added:
    
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabledSession.java
    james/server/trunk/core-api/src/test/java/org/
    james/server/trunk/core-api/src/test/java/org/apache/
    james/server/trunk/core-api/src/test/java/org/apache/james/
    james/server/trunk/core-api/src/test/java/org/apache/james/api/
    james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/
    james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/
    
james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java
      - copied, changed from r812224, 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
    james/server/trunk/nntpserver-function/src/test/java/org/
    james/server/trunk/nntpserver-function/src/test/java/org/apache/
    james/server/trunk/nntpserver-function/src/test/java/org/apache/james/
    
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/
    
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPServerTest.java
    
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPTestConfiguration.java
    
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/
    
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/MockNNTPRepository.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHelp.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/ConnectHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/LineHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerHandlerChain.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerResponse.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerSession.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AbstractMappingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AddHamCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AddMappingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AddSpamCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/CoreCmdLoaderService.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/CountUsersCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/DelUserCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/DeleteSpoolCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ExportBayesianDataCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/FlushSpoolCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ImportBayesianDataCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListAllMappingsCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListMailetsCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListMappingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListMatchersCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListProcessorsCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListSpoolCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ListUsersCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/MemStatCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/MoveMailsCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/QuitCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/RemoteManagerCommandDispatcherLineHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/RemoveMappingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ResetBayesianDataCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/SetAliasCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/SetForwardingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/SetPasswordCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShowAliasCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShowForwardingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShowMailetInfoCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShowMatcherInfoCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShutdownCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnknownCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetAliasCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetForwardingCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UserCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/VerifyCmdHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/WelcomeHandler.java
Removed:
    
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/FakeLoader.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/Command.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandRegistry.java
    
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
Modified:
    
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractCommandDispatcher.java
    
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/TLSSupportedSession.java
    
james/server/trunk/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPRepositoryImpl.java
    james/server/trunk/phoenix-deployment/src/conf/james-config.xml
    
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
    
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Handler.java
    
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManager.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerHandler.java
    
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java
    
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
    
james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTestConfiguration.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/AbstractCommandDispatcher.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractCommandDispatcher.java?rev=821546&r1=821545&r2=821546&view=diff
==============================================================================
--- 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractCommandDispatcher.java
 (original)
+++ 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractCommandDispatcher.java
 Sun Oct  4 15:10:49 2009
@@ -62,7 +62,7 @@
      * @param session not null
      * @return List of CommandHandlers
      */
-    protected List<CommandHandler> getCommandHandlers(String command, 
TLSSupportedSession session) {
+    protected List<CommandHandler> getCommandHandlers(String command, 
LogEnabledSession session) {
         if (command == null) {
             return null;
         }

Added: 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabledSession.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabledSession.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabledSession.java
 (added)
+++ 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabledSession.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.socket;
+
+import org.apache.commons.logging.Log;
+
+public interface LogEnabledSession {
+    /**
+     * Gets the context sensitive log for this session.
+     * @return log, not null
+     */
+    public Log getLogger();
+}

Modified: 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/TLSSupportedSession.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/TLSSupportedSession.java?rev=821546&r1=821545&r2=821546&view=diff
==============================================================================
--- 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/TLSSupportedSession.java
 (original)
+++ 
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/TLSSupportedSession.java
 Sun Oct  4 15:10:49 2009
@@ -22,14 +22,12 @@
 
 import java.io.IOException;
 
-import org.apache.commons.logging.Log;
-
 /**
  * Session which supports TLS 
  * 
  *
  */
-public interface TLSSupportedSession {
+public interface TLSSupportedSession extends LogEnabledSession{
     /**
      * Returns the user name associated with this interaction.
      *
@@ -79,9 +77,4 @@
      */
     void startTLS() throws IOException;
     
-    /**
-     * Gets the context sensitive log for this session.
-     * @return log, not null
-     */
-    Log getLogger();
 }

Copied: 
james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java
 (from r812224, 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java)
URL: 
http://svn.apache.org/viewvc/james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java?p2=james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java&p1=james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java&r1=812224&r2=821546&rev=821546&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
 (original)
+++ 
james/server/trunk/core-api/src/test/java/org/apache/james/api/kernel/mock/FakeLoader.java
 Sun Oct  4 15:10:49 2009
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.smtpserver;
+package org.apache.james.api.kernel.mock;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;

Modified: 
james/server/trunk/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPRepositoryImpl.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPRepositoryImpl.java?rev=821546&r1=821545&r2=821546&view=diff
==============================================================================
--- 
james/server/trunk/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPRepositoryImpl.java
 (original)
+++ 
james/server/trunk/nntpserver-function/src/main/java/org/apache/james/nntpserver/repository/NNTPRepositoryImpl.java
 Sun Oct  4 15:10:49 2009
@@ -211,7 +211,7 @@
         }
 
         articleIDRepo = new ArticleIDRepository(articleIDPath, 
articleIDDomainSuffix);
-        spool = (NNTPSpooler)createSpooler();
+        spool = createSpooler();
         spool.setRepository(this);
         spool.setArticleIDRepository(articleIDRepo);
         if (getLogger().isDebugEnabled()) {
@@ -283,7 +283,7 @@
         File groupFile = new File(rootPath,groupName);
         NNTPGroup groupToReturn = null;
         synchronized(this) {
-            groupToReturn = (NNTPGroup)repositoryGroups.get(groupName);
+            groupToReturn = repositoryGroups.get(groupName);
             if ((groupToReturn == null) && groupFile.exists() && 
groupFile.isDirectory() ) {
                 try {
                     groupToReturn = new NNTPGroupImpl(groupFile);
@@ -446,9 +446,10 @@
 
     /**
      * Setter for the FileSystem dependency
+     * 
      * @param system filesystem service
      */
-    private void setFileSystem(FileSystem system) {
+    public void setFileSystem(FileSystem system) {
         this.fileSystem = system;
     }
 

Added: 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPServerTest.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPServerTest.java
 (added)
+++ 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPServerTest.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,158 @@
+/****************************************************************
+ * 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.nntpserver;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import junit.framework.TestCase;
+
+import org.apache.avalon.cornerstone.services.sockets.SocketManager;
+import org.apache.avalon.cornerstone.services.threads.ThreadManager;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.commons.net.nntp.NNTPClient;
+import org.apache.james.api.dnsservice.AbstractDNSServer;
+import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.nntpserver.mock.MockNNTPRepository;
+import org.apache.james.nntpserver.repository.NNTPRepository;
+import org.apache.james.nntpserver.repository.NNTPRepositoryImpl;
+import org.apache.james.services.FileSystem;
+import org.apache.james.services.MailServer;
+import org.apache.james.socket.JamesConnectionManager;
+import org.apache.james.socket.SimpleConnectionManager;
+import org.apache.james.test.mock.avalon.MockLogger;
+import org.apache.james.test.mock.avalon.MockServiceManager;
+import org.apache.james.test.mock.avalon.MockSocketManager;
+import org.apache.james.test.mock.avalon.MockThreadManager;
+import org.apache.james.test.mock.james.MockMailServer;
+import org.apache.james.test.util.Util;
+import org.apache.james.userrepository.MockUsersRepository;
+
+public class NNTPServerTest extends TestCase {
+       private int m_nntpListenerPort = Util.getNonPrivilegedPort();
+
+       private NNTPServer m_nntpServer;
+       private MockServiceManager serviceManager;
+
+       private MockUsersRepository m_usersRepository;
+       private NNTPTestConfiguration m_testConfiguration;
+       private NNTPRepositoryImpl m_nntpRepos;
+       
+       private MockMailServer m_mailServer;
+       private NNTPClient m_nntpProtocol;
+
+       protected void setUp() throws Exception {
+               m_nntpServer = new NNTPServer();
+               setUpServiceManager();
+
+               ContainerUtil.enableLogging(m_nntpServer, new MockLogger());
+               ContainerUtil.service(m_nntpServer, serviceManager);
+
+               m_testConfiguration = new 
NNTPTestConfiguration(m_nntpListenerPort);
+       }
+
+       private void finishSetUp(NNTPTestConfiguration testConfiguration)
+                       throws Exception {
+               testConfiguration.init();
+               ContainerUtil.configure(m_nntpServer, testConfiguration);
+               m_nntpServer.initialize();
+       }
+
+       private void setUpServiceManager() throws ServiceException {
+               serviceManager = new MockServiceManager();
+               m_usersRepository = new MockUsersRepository();
+               m_mailServer = new MockMailServer(m_usersRepository);
+               m_nntpRepos = new NNTPRepositoryImpl();
+               m_nntpRepos.setFileSystem(new FileSystem() {
+                       private File base = new 
File(System.getProperty("java.io.tmpdir"));
+                       public File getBasedir() throws FileNotFoundException {
+                               return base;
+                       }
+
+                       public File getFile(String fileURL) throws 
FileNotFoundException {
+                               return null;
+                       }
+
+                       public InputStream getResource(String url) throws 
IOException {
+                               return null;
+                       }
+                       
+               });
+
+               SimpleConnectionManager connectionManager = new 
SimpleConnectionManager();
+               ContainerUtil.enableLogging(connectionManager, new 
MockLogger());
+               ContainerUtil.service(connectionManager, serviceManager);
+               serviceManager.put(JamesConnectionManager.ROLE, 
connectionManager);
+
+               serviceManager.put(MailServer.ROLE, m_mailServer);
+               serviceManager.put(UsersRepository.ROLE, m_usersRepository);
+               serviceManager.put(SocketManager.ROLE, new MockSocketManager(
+                               m_nntpListenerPort));
+               serviceManager.put(ThreadManager.ROLE, new MockThreadManager());
+               serviceManager.put(NNTPRepository.ROLE, new 
MockNNTPRepository());
+               serviceManager.put(DNSService.ROLE, setUpDNSServer());
+       }
+
+       private DNSService setUpDNSServer() {
+               DNSService dns = new AbstractDNSServer() {
+                       public String getHostName(InetAddress addr) {
+                               return "localhost";
+                       }
+
+                       public InetAddress getLocalHost() throws 
UnknownHostException {
+                               return InetAddress.getLocalHost();
+                       }
+
+               };
+               return dns;
+       }
+
+       protected void tearDown() throws Exception {
+               if (m_nntpProtocol != null) {
+                       m_nntpProtocol.sendCommand("quit");
+                       m_nntpProtocol.disconnect();
+               }
+               m_nntpServer.dispose();
+               ContainerUtil.dispose(m_mailServer);
+
+               super.tearDown();
+       }
+
+       public void testLoginAuthRequired() throws Exception {
+               m_testConfiguration.setUseAuthRequired();
+               finishSetUp(m_testConfiguration);
+               m_nntpProtocol = new NNTPClient();
+               m_usersRepository.addUser("valid", "user");
+
+               m_nntpProtocol.connect("127.0.0.1", m_nntpListenerPort);
+               assertFalse("Reject invalid user", m_nntpProtocol.authenticate(
+                               "invalid", "user"));
+
+               assertTrue("Login successful", 
m_nntpProtocol.authenticate("valid",
+                               "user"));
+       }
+
+}

Added: 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPTestConfiguration.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPTestConfiguration.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPTestConfiguration.java
 (added)
+++ 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/NNTPTestConfiguration.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.nntpserver;
+
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.james.test.util.Util;
+
+public class NNTPTestConfiguration extends DefaultConfiguration {
+
+       private int m_nntpListenerPort;
+       private boolean m_authRequired = false;
+
+       public NNTPTestConfiguration(int m_nntpListenerPort) {
+               super("nntpserver");
+               this.m_nntpListenerPort = m_nntpListenerPort;
+       }
+
+       public void setUseAuthRequired() {
+               m_authRequired = true;
+       }
+
+       public void init() {
+               setAttribute("enabled", true);
+               addChild(Util.getValuedConfiguration("port", "" + 
m_nntpListenerPort));
+               DefaultConfiguration handlerConfig = new 
DefaultConfiguration("handler");
+               handlerConfig.addChild(Util.getValuedConfiguration("helloName",
+                               "myMailServer"));
+               
handlerConfig.addChild(Util.getValuedConfiguration("connectiontimeout",
+                               "360000"));
+               
handlerConfig.addChild(Util.getValuedConfiguration("authRequired",
+                               m_authRequired + ""));
+
+               addChild(handlerConfig);
+       }
+
+}

Added: 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/MockNNTPRepository.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/MockNNTPRepository.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/MockNNTPRepository.java
 (added)
+++ 
james/server/trunk/nntpserver-function/src/test/java/org/apache/james/nntpserver/mock/MockNNTPRepository.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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.nntpserver.mock;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.james.nntpserver.repository.NNTPArticle;
+import org.apache.james.nntpserver.repository.NNTPGroup;
+import org.apache.james.nntpserver.repository.NNTPRepository;
+
+public class MockNNTPRepository implements NNTPRepository{
+
+       private boolean readOnly;
+       private final Map<String,NNTPGroup> groups = new 
HashMap<String,NNTPGroup>();
+       private final Map<Date,NNTPGroup> dates = new HashMap<Date, 
NNTPGroup>();
+       
+       public void createArticle(InputStream in) {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public NNTPArticle getArticleFromID(String id) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Iterator<NNTPArticle> getArticlesSince(Date dt) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public NNTPGroup getGroup(String groupName) {
+               return groups.get(groupName);
+       }
+
+       public Iterator<NNTPGroup> getGroupsSince(Date dt) {
+               List<NNTPGroup> gList = new ArrayList<NNTPGroup>();
+               Iterator<Date> dIt = dates.keySet().iterator();
+               while (dIt.hasNext()) {
+                       Date d = dIt.next();
+                       if (dt != null && dt.after(d)) {
+                               gList.add(dates.get(d));
+                       }
+               }
+               
+               return gList.iterator();
+       }
+
+       public Iterator<NNTPGroup> getMatchedGroups(String wildmat) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public String[] getOverviewFormat() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public boolean isReadOnly() {
+               return readOnly;
+       }
+
+       public void setReadOnly(boolean readOnly) {
+           this.readOnly = readOnly;   
+       }
+       
+       public void addGroup(Date date, NNTPGroup group) {
+               groups.put(group.getName(),group);
+               dates.put(date,group);
+       }
+}

Modified: james/server/trunk/phoenix-deployment/src/conf/james-config.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-config.xml?rev=821546&r1=821545&r2=821546&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-config.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-config.xml Sun Oct  4 
15:10:49 2009
@@ -896,6 +896,11 @@
          <!-- 
          <prompt>james&gt;</prompt>
          -->
+         <handlerchain>
+             <!-- This loads the core CommandHandlers. Only remove this if you 
really -->
+             <!-- know what you are doing -->
+             <handler 
class="org.apache.james.remotemanager.core.CoreCmdHandlerLoader"/>
+         </handlerchain>
       </handler>
    </remotemanager>
       

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=821546&r1=821545&r2=821546&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
 Sun Oct  4 15:10:49 2009
@@ -43,6 +43,7 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.james.Constants;
 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.core.MailImpl;
 import org.apache.james.services.MailServer;

Modified: 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Handler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Handler.java?rev=821546&r1=821545&r2=821546&view=diff
==============================================================================
--- 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Handler.java
 (original)
+++ 
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/POP3Handler.java
 Sun Oct  4 15:10:49 2009
@@ -341,8 +341,9 @@
         }
     }
 
-
-    @Override
+    /**
+     * @see org.apache.james.pop3server.POP3Session#getState()
+     */
     public Map<Object, Object> getState() {
         return stateMap;
     }

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=821546&r1=821545&r2=821546&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
 Sun Oct  4 15:10:49 2009
@@ -28,6 +28,7 @@
 import org.apache.commons.net.pop3.POP3Reply;
 import org.apache.james.api.dnsservice.AbstractDNSServer;
 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.core.MailImpl;
 import org.apache.james.services.MailRepository;

Added: 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHandler.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHandler.java
 (added)
+++ 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHandler.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,28 @@
+/****************************************************************
+ * 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.remotemanager;
+
+import org.apache.james.socket.CommonCommandHandler;
+
+public interface CommandHandler extends CommonCommandHandler{
+       
+       public RemoteManagerResponse onCommand(RemoteManagerSession session, 
String command, String parameters);
+       public CommandHelp getHelp();
+}

Added: 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHelp.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHelp.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHelp.java
 (added)
+++ 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/CommandHelp.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.remotemanager;
+
+public class CommandHelp {
+
+    private String syntax;
+    private String desc;
+    
+    public CommandHelp(String syntax) {
+        setSyntax(syntax);
+    }
+    
+    public CommandHelp(String syntax, String desc) {
+        this(syntax);
+        setDescription(desc);
+    }
+    
+    public void setSyntax(String syntax) {
+        this.syntax = syntax;
+    }
+    
+    public String getSyntax() {
+        return syntax;
+    }
+    
+    public String getDescription() {
+        return desc;
+    }
+    
+    public void setDescription(String desc) {
+        this.desc = desc;
+    }
+}

Added: 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/ConnectHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/ConnectHandler.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/ConnectHandler.java
 (added)
+++ 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/ConnectHandler.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.remotemanager;
+
+
+public interface ConnectHandler {
+    /**
+     * Handle connection
+    **/
+    void onConnect(RemoteManagerSession session);
+
+}

Added: 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/LineHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/LineHandler.java?rev=821546&view=auto
==============================================================================
--- 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/LineHandler.java
 (added)
+++ 
james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/LineHandler.java
 Sun Oct  4 15:10:49 2009
@@ -0,0 +1,31 @@
+/****************************************************************
+ * 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.remotemanager;
+
+public interface LineHandler {
+
+    /**
+     * Handle the command.
+     * @param session not null
+     * @param line not null 
+     */
+    void onLine(RemoteManagerSession session, String line);
+    
+}

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=821546&r1=821545&r2=821546&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  4 15:10:49 2009
@@ -21,27 +21,21 @@
 
 package org.apache.james.remotemanager;
 
-import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.avalon.framework.configuration.Configurable;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.api.user.UsersRepository;
-import org.apache.james.api.user.UsersStore;
-import org.apache.james.api.vut.management.VirtualUserTableManagementService;
-import org.apache.james.management.BayesianAnalyzerManagementService;
-import org.apache.james.management.DomainListManagementService;
-import org.apache.james.management.ProcessorManagementService;
-import org.apache.james.management.SpoolManagementService;
+import org.apache.commons.logging.impl.AvalonLogger;
+import org.apache.james.api.kernel.LoaderService;
 import org.apache.james.services.MailServer;
 import org.apache.james.socket.AbstractProtocolServer;
 import org.apache.james.socket.ProtocolHandler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
+import org.apache.james.socket.configuration.JamesConfiguration;
 
 /**
  * Provides a really rude network interface to administer James.
@@ -55,24 +49,10 @@
     extends AbstractProtocolServer implements RemoteManagerMBean {
 
     /**
-     * A HashMap of (user id, passwords) for James administrators
+     * A Map of (user id, passwords) for James administrators
      */
-    private HashMap adminAccounts = new HashMap();
+    private Map<String,String> adminAccounts = new HashMap<String,String>();
 
-    /**
-     * The UsersStore that contains all UsersRepositories managed by this 
RemoteManager
-     */
-    private UsersStore usersStore;
-
-    /**
-     * The current UsersRepository being managed/viewed/modified
-     */
-    private UsersRepository users;
-
-    /**
-     * The reference to the spool management service
-     */
-    private SpoolManagementService spoolManagement;
 
     /**
      * The service prompt to be displayed when waiting for input.
@@ -84,53 +64,6 @@
      */
     private MailServer mailServer;
 
-    /**
-     * The reference to the Store
-     */
-    private Store store;
-    
-    private Command[] commands = {};
-    
-    /**
-     * reference to administration of Bayesian analyzer
-     */
-    private BayesianAnalyzerManagementService bayesianAnalyzerManagement;
-    
-    /**
-     * reference to administration of Processors
-     */
-    private ProcessorManagementService processorManagementService;
-
-    private VirtualUserTableManagementService vutManagemenet;
-    
-    private DomainListManagementService domListManagement;
-    
-    /**
-     * Set the UserStore 
-     * 
-     * @param usersStore the UserStore
-     */
-    public void setUsersStore(UsersStore usersStore) {
-        this.usersStore = usersStore;
-    }
-
-    /**
-     * Set the UsersRepository
-     * 
-     * @param users the UsersRepository
-     */
-    public void setUsers(UsersRepository users) {
-        this.users = users;
-    }
-
-    /**
-     * Set the SpoolManagementService
-     * 
-     * @param spoolManagement the SpoolManagementService
-     */
-    public void setSpoolManagement(SpoolManagementService spoolManagement) {
-        this.spoolManagement = spoolManagement;
-    }
 
     /**
      * Set the MailServer 
@@ -142,55 +75,36 @@
     }
 
     /**
-     * Set the Store
-     * 
-     * @param store the Store
-     */
-    public void setStore(Store store) {
-        this.store = store;
-    }
-    
-    /**
-     * Set the BayesianAnalyzerManagementService
-     * 
-     * @param bayesianAnalyzerManagement the BayesianAnalyzerManagementService
-     */
-    public void 
setBayesianAnalyzerManagement(BayesianAnalyzerManagementService 
bayesianAnalyzerManagement) {
-        this.bayesianAnalyzerManagement = bayesianAnalyzerManagement;
-    }
-    
-    /**
-     * Set the ProcessorManagementService
-     * 
-     * @param processorManagement the ProcessorManagementService
+     * The configuration data to be passed to the handler
      */
-    public void setProcessorManagement(ProcessorManagementService 
processorManagement) {
-        this.processorManagementService = processorManagement;
-    }
+    private RemoteManagerHandlerConfigurationData theConfigData
+        = new RemoteManagerHandlerConfigurationDataImpl();
+
+
+    private RemoteManagerHandlerChain handlerChain;
+
+
+    private LoaderService loader;
+
+
+    private Configuration handlerConfiguration;
     
     /**
-     * Set the VirtualUserTableManagementService
-     * 
-     * @param vutManagement the VirtualUserTableManagementService 
+     * Gets the current instance loader.
+     * @return the loader
      */
-    public void 
setVirtualUserTableManagement(VirtualUserTableManagementService vutManagement) {
-        this.vutManagemenet = vutManagement;
+    public final LoaderService getLoader() {
+        return loader;
     }
-    
+
     /**
-     * Set the DomainListManagementService
-     * 
-     * @param domListManagement the DomainListManagementService 
+     * Sets the loader to be used for instances.
+     * @param loader the loader to set, not null
      */
-    public void setDomainListManagement(DomainListManagementService 
domListManagement) {
-        this.domListManagement = domListManagement;
+    @Resource(name="org.apache.james.LoaderService")
+    public final void setLoader(LoaderService loader) {
+        this.loader = loader;
     }
-    
-    /**
-     * The configuration data to be passed to the handler
-     */
-    private RemoteManagerHandlerConfigurationData theConfigData
-        = new RemoteManagerHandlerConfigurationDataImpl();
 
     /**
      * @see 
org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
@@ -200,24 +114,6 @@
         super.service(componentManager);
         MailServer mailServer = 
(MailServer)componentManager.lookup(MailServer.ROLE );
         setMailServer(mailServer);
-        Store store = (Store)componentManager.
-            lookup( Store.ROLE );
-        setStore(store);
-        UsersStore usersStore = (UsersStore)componentManager. 
lookup(UsersStore.ROLE );
-        setUsersStore(usersStore);
-        UsersRepository users = (UsersRepository) 
componentManager.lookup(UsersRepository.ROLE);
-        if (users == null) {
-            throw new ServiceException("","The user repository could not be 
found.");
-        }
-        setUsers(users);
-        SpoolManagementService spoolManagement = 
-            (SpoolManagementService) 
componentManager.lookup(SpoolManagementService.ROLE);
-        setSpoolManagement(spoolManagement);
-        
-        setBayesianAnalyzerManagement((BayesianAnalyzerManagementService) 
componentManager.lookup(BayesianAnalyzerManagementService.ROLE));     
-        setProcessorManagement((ProcessorManagementService) 
componentManager.lookup(ProcessorManagementService.ROLE)); 
-        setVirtualUserTableManagement((VirtualUserTableManagementService) 
componentManager.lookup(VirtualUserTableManagementService.ROLE));
-        setDomainListManagement((DomainListManagementService) 
componentManager.lookup(DomainListManagementService.ROLE));
     }
 
     /**
@@ -239,38 +135,26 @@
             if (promtConfiguration != null) prompt = 
promtConfiguration.getValue();
             if (prompt == null) prompt = ""; 
             else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += " 
"; 
-            configureCommands(configuration);
+           
+            this.handlerConfiguration = handlerConfiguration;
         }
     }
-  
-    private void configureCommands(final Configuration configuration) throws 
ConfigurationException {
-        Collection commands = new ArrayList();
-        Configuration[] commandConfigurations = configuration.getChildren( 
"command" );
-        if (commandConfigurations != null) {
-            for(int i=0;i<commandConfigurations.length;i++) {
-                final Configuration commandConfiguration = 
commandConfigurations[i];
-                Configuration classConfiguration 
-                = commandConfiguration.getChild( "class-name" );
-                String className = classConfiguration.getValue();
-                if (className != null) {
-                    try {
-                        Command command 
-                        = (Command) Class.forName(className).newInstance();
-                        if (command instanceof Configurable) {
-                            Configurable configurable = (Configurable) command;
-                            configurable.configure(commandConfiguration);
-                        }
-                        commands.add(command);
-                    } catch (Exception e) {
-                        final Logger logger = getLogger();
-                        if (logger != null) {
-                            logger.error("Failed to load custom command", e);
-                        }
-                    }
-                }
-            }
-        }
-        this.commands = (Command[]) commands.toArray(this.commands);
+    
+    private void prepareHandlerChain() throws Exception {
+
+        handlerChain = loader.load(RemoteManagerHandlerChain.class);
+        
+        //set the logger
+        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")));
+    }
+    
+
+    @Override
+    protected void prepareInit() throws Exception {
+        prepareHandlerChain();
     }
     
     /**
@@ -291,7 +175,7 @@
      * @see 
org.apache.james.socket.AbstractProtocolServer#newProtocolHandlerInstance()
      */
     public ProtocolHandler newProtocolHandlerInstance() {
-        return new RemoteManagerHandler(theConfigData);
+        return new RemoteManagerHandler(theConfigData, handlerChain);
     }
 
     /**
@@ -310,44 +194,11 @@
                 return RemoteManager.this.helloName;
             }
         }
-
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getMailServer()
-         */
-        public MailServer getMailServer() {
-            return RemoteManager.this.mailServer;
-        }
-        
-        /**
-         * 
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getStore()
-         */
-        public Store getStore() {
-            return RemoteManager.this.store;
-        }
         
         /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getUsersRepository()
-         */
-        public UsersRepository getUsersRepository() {
-            return RemoteManager.this.users;
-        }
-
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getUserStore()
 
-         */
-        public UsersStore getUserStore() {
-            return RemoteManager.this.usersStore;
-        }
-
-        public SpoolManagementService getSpoolManagement() {
-            return RemoteManager.this.spoolManagement;
-        }
-
-        /**
          * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getAdministrativeAccountData()
          */
-        public HashMap getAdministrativeAccountData() {
+        public Map<String,String> getAdministrativeAccountData() {
             return RemoteManager.this.adminAccounts;
         }
 
@@ -358,39 +209,5 @@
             return RemoteManager.this.prompt;
         }
         
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getBayesianAnalyzerManagement()
-         */
-        public BayesianAnalyzerManagementService 
getBayesianAnalyzerManagement() {
-            return RemoteManager.this.bayesianAnalyzerManagement;
-        }
-
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getProcessorManagement()
-         */
-        public ProcessorManagementService getProcessorManagement() {
-            return RemoteManager.this.processorManagementService;
-        }
-
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getVirtualUserTableManagement()
-         */
-        public VirtualUserTableManagementService 
getVirtualUserTableManagement() {
-            return RemoteManager.this.vutManagemenet;
-        }
-
-        /**
-         * @see 
org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getDomainListManagement()
-         */
-        public DomainListManagementService getDomainListManagement() {
-            return RemoteManager.this.domListManagement;
-        }
-        
-        /**
-         * @see 
org.apache.james.neo.remotemanager.RemoteManagerHandlerConfigurationData#getCommands()
-         */
-        public Command[] getCommands() {
-            return RemoteManager.this.commands;
-        }
     }
 }



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

Reply via email to