james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r552543 - in /james/server/trunk: experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ imap-api/src/main/java/org/apache/james/api/imap/process/ imap-codec-library/src/main/java/org/apache/james/imapserver...
Date Mon, 02 Jul 2007 17:00:01 GMT
Author: rdonkin
Date: Mon Jul  2 09:59:58 2007
New Revision: 552543

URL: http://svn.apache.org/viewvc?view=rev&rev=552543
Log:
Phoenix configuration for IMAP

Added:
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/DefaultImapDecoderFactory.java
      - copied, changed from r549545, james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/StandardFactory.java
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoderFactory.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapEncoderFactory.java
    james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/
    james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/
    james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/PhoenixImapProcessorFactory.java
Removed:
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/StandardFactory.java
Modified:
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapServer.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java

Copied: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/DefaultImapDecoderFactory.java
(from r549545, james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/StandardFactory.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/DefaultImapDecoderFactory.java?view=diff&rev=552543&p1=james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/StandardFactory.java&r1=549545&p2=james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/DefaultImapDecoderFactory.java&r2=552543
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/StandardFactory.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/DefaultImapDecoderFactory.java
Mon Jul  2 09:59:58 2007
@@ -25,13 +25,14 @@
 import org.apache.james.imap.message.request.base.BaseImap4Rev1MessageFactory;
 import org.apache.james.imapserver.codec.decode.ImapCommandParserFactory;
 import org.apache.james.imapserver.codec.decode.ImapDecoder;
+import org.apache.james.imapserver.codec.decode.ImapDecoderFactory;
 import org.apache.james.imapserver.codec.decode.imap4rev1.Imap4Rev1CommandParserFactory;
 import org.apache.james.imapserver.codec.decode.main.DefaultImapDecoder;
 
 /**
  * TODO: this is temporary: should let the container do the coupling.
  */
-public class StandardFactory {
+public class DefaultImapDecoderFactory implements ImapDecoderFactory{
     
     public static final ImapDecoder createDecoder() {
         final Imap4Rev1MessageFactory messageFactory = new BaseImap4Rev1MessageFactory();
@@ -42,4 +43,10 @@
                 imapCommands);
         return result;
     }
+
+    public ImapDecoder buildImapDecoder() {
+        return createDecoder();
+    }
+    
+    
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapServer.java?view=diff&rev=552543&r1=552542&r2=552543
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapServer.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapServer.java
Mon Jul  2 09:59:58 2007
@@ -19,15 +19,20 @@
 
 package org.apache.james.experimental.imapserver;
 
+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.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.james.api.imap.process.ImapProcessor;
+import org.apache.james.api.imap.process.ImapProcessorFactory;
 import org.apache.james.core.AbstractJamesService;
 import org.apache.james.imapserver.codec.decode.ImapDecoder;
+import org.apache.james.imapserver.codec.decode.ImapDecoderFactory;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
+import org.apache.james.imapserver.codec.encode.ImapEncoderFactory;
 import org.apache.james.services.MailServer;
 
 /**
@@ -53,20 +58,38 @@
     private ImapHandlerConfigurationDataImpl theConfigData = new ImapHandlerConfigurationDataImpl();
 
     private MailServer mailServer;
+    private ImapDecoderFactory decoderFactory;
+    private ImapEncoderFactory encoderFactory;
+    private ImapProcessorFactory processorFactory;
+    
+    private ImapProcessor imapProcessor;
     private ImapDecoder imapDecoder;
     private ImapEncoder imapEncoder;
-    private ImapProcessor imapProcessor;
-
+    
     public void service( ServiceManager serviceManager ) throws ServiceException
     {
         super.service( serviceManager );
         setMailServer((MailServer) serviceManager.lookup(MailServer.ROLE));
+        setUp(decoderFactory, serviceManager);
+        setUp(encoderFactory, serviceManager);
+        setUp(processorFactory, serviceManager);
+        
+        imapProcessor = processorFactory.buildImapProcessor();
+        imapDecoder = decoderFactory.buildImapDecoder();
+        imapEncoder = encoderFactory.buildImapEncoder();
     }
 
     void setMailServer(MailServer mailServer) {
         this.mailServer = mailServer;
     }
 
+    private void setUp(Object service, ServiceManager serviceManager) throws ServiceException{
+        if (service instanceof Serviceable) {
+            Serviceable serviceable = (Serviceable) service;
+            serviceable.service(serviceManager);
+        }
+    }
+    
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
      */
@@ -77,6 +100,35 @@
             Configuration handlerConfiguration = configuration.getChild( "handler" );
             lengthReset = handlerConfiguration.getChild( "lengthReset" ).getValueAsInteger(
lengthReset );
             getLogger().info( "The idle timeout will be reset every " + lengthReset + " bytes."
);  
+            
+            Configuration encoderConfiguration = configuration.getChild( "encoder-factory"
);
+            encoderFactory = (ImapEncoderFactory) createFactory(encoderConfiguration);
+            
+            Configuration decoderConfiguration = configuration.getChild ( "decoder-factory"
);
+            decoderFactory = (ImapDecoderFactory) createFactory(decoderConfiguration);
+            
+            Configuration processorConfiguration = configuration.getChild( "processor-factory"
);
+            processorFactory = (ImapProcessorFactory) createFactory(processorConfiguration);
+        }
+    }
+    
+    private Object createFactory(Configuration configuration) throws ConfigurationException
+    {
+        try {
+            final String className = configuration.getAttribute("class");
+            final Object result = Class.forName(className).newInstance();
+            if (result instanceof Configurable)
+            {
+                Configurable configurable = (Configurable) result;
+                configurable.configure(configuration);
+            }
+            return result;
+        } catch (ClassNotFoundException e) {
+            throw new ConfigurationException("Cannot load factory class", configuration,
e);
+        } catch (InstantiationException e) {
+            throw new ConfigurationException("Cannot load factory class", configuration,
e);
+        } catch (IllegalAccessException e) {
+            throw new ConfigurationException("Cannot load factory class", configuration,
e);
         }
     }
 

Added: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java?view=auto&rev=552543
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java
(added)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java
Mon Jul  2 09:59:58 2007
@@ -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.api.imap.process;
+
+/**
+ * Builds processors. 
+ */
+public interface ImapProcessorFactory {
+
+    public ImapProcessor buildImapProcessor();
+}

Added: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoderFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoderFactory.java?view=auto&rev=552543
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoderFactory.java
(added)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoderFactory.java
Mon Jul  2 09:59:58 2007
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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.imapserver.codec.decode;
+
+public interface ImapDecoderFactory {
+
+    public ImapDecoder buildImapDecoder();
+}

Added: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapEncoderFactory.java?view=auto&rev=552543
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapEncoderFactory.java
(added)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapEncoderFactory.java
Mon Jul  2 09:59:58 2007
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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.imapserver.codec.encode;
+
+public interface ImapEncoderFactory {
+
+    public ImapEncoder buildImapEncoder();
+}

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java?view=diff&rev=552543&r1=552542&r2=552543
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
Mon Jul  2 09:59:58 2007
@@ -20,6 +20,7 @@
 package org.apache.james.imapserver.codec.encode.main;
 
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
+import org.apache.james.imapserver.codec.encode.ImapEncoderFactory;
 import org.apache.james.imapserver.codec.encode.base.EndImapEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.ExistsResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.ExpungeResponseEncoder;
@@ -43,7 +44,7 @@
 /**
  * TODO: perhaps a POJO would be better
  */
-public class DefaultImapEncoderFactory {
+public class DefaultImapEncoderFactory implements ImapEncoderFactory {
     
     public static final ImapEncoder createDefaultEncoder() {
         final EndImapEncoder endImapEncoder = new EndImapEncoder();
@@ -66,6 +67,10 @@
         final CapabilityResponseEncoder capabilityResponseEncoder = new CapabilityResponseEncoder(closeResponseEncoder);
         final BadResponseEncoder result = new BadResponseEncoder(capabilityResponseEncoder);
         return result;
+    }
+
+    public ImapEncoder buildImapEncoder() {
+        return createDefaultEncoder();
     }
    
 }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java?view=diff&rev=552543&r1=552542&r2=552543
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
(original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
Mon Jul  2 09:59:58 2007
@@ -20,6 +20,7 @@
 package org.apache.james.imapserver.processor.main;
 
 import org.apache.james.api.imap.process.ImapProcessor;
+import org.apache.james.api.imap.process.ImapProcessorFactory;
 import org.apache.james.imapserver.processor.base.ImapResponseMessageProcessor;
 import org.apache.james.imapserver.processor.base.UnknownRequestImapProcessor;
 import org.apache.james.imapserver.processor.imap4rev1.Imap4Rev1ProcessorFactory;
@@ -29,7 +30,7 @@
 /**
  * 
  */
-public class DefaultImapProcessorFactory {
+public class DefaultImapProcessorFactory implements ImapProcessorFactory {
 
     public static final ImapProcessor createDefaultProcessor(final UsersRepository usersRepository,
             final MailboxManagerProvider mailboxManagerProvider) {
@@ -62,5 +63,9 @@
     
     public final void setUsersRepository(UsersRepository usersRepository) {
         this.usersRepository = usersRepository;
+    }
+
+    public ImapProcessor buildImapProcessor() {
+        return createDefaultProcessor(usersRepository, mailboxManagerProvider);
     }
 }

Added: james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/PhoenixImapProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/PhoenixImapProcessorFactory.java?view=auto&rev=552543
==============================================================================
--- james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/PhoenixImapProcessorFactory.java
(added)
+++ james/server/trunk/phoenix-deployment/src/java/org/apache/james/imapserver/phoenix/PhoenixImapProcessorFactory.java
Mon Jul  2 09:59:58 2007
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.imapserver.phoenix;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.james.imapserver.processor.main.DefaultImapProcessorFactory;
+import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
+import org.apache.james.services.UsersRepository;
+
+public class PhoenixImapProcessorFactory extends DefaultImapProcessorFactory implements Serviceable
{
+
+    public void service(ServiceManager serviceManager) throws ServiceException {
+        UsersRepository usersRepository = ( UsersRepository ) serviceManager.
+            lookup( "org.apache.james.services.UsersRepository" );
+        MailboxManagerProvider mailboxManagerProvider = 
+            (MailboxManagerProvider) serviceManager.lookup("org.apache.james.mailboxmanager.manager.MailboxManagerProvider");
+        configure(usersRepository, mailboxManagerProvider);
+    }
+
+}



---------------------------------------------------------------------
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