james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1050470 - in /james/server/trunk: container-spring/src/main/config/james/ container-spring/src/main/config/james/context/ mail-api/src/main/java/org/apache/james/mailstore/api/ mail-library/src/main/java/org/apache/james/mailstore/lib/ mai...
Date Fri, 17 Dec 2010 19:18:58 GMT
Author: norman
Date: Fri Dec 17 19:18:58 2010
New Revision: 1050470

URL: http://svn.apache.org/viewvc?rev=1050470&view=rev
Log:
Improve MailStore interface.. still work in progress

Removed:
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToMultiRepository.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
    james/server/trunk/container-spring/src/main/config/james/mailstore.xml
    james/server/trunk/mail-api/src/main/java/org/apache/james/mailstore/api/MailStore.java
    james/server/trunk/mail-library/src/main/java/org/apache/james/mailstore/lib/JamesMailStore.java
    james/server/trunk/mail-library/src/test/java/org/apache/james/mailstore/mock/MockMailStore.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java

Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
(original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
Fri Dec 17 19:18:58 2010
@@ -134,8 +134,8 @@
     <bean id="mailProcessor" name="processorRoute" class="org.apache.james.mailetcontainer.camel.CamelMailProcessorList"/>
     <bean id="mailspooler" class="org.apache.james.mailetcontainer.lib.JamesMailSpooler"/>
     <bean id="mailetcontext" class="org.apache.james.mailetcontainer.lib.JamesMailetContext"/>
-    <bean id="mailetloader" class="org.apache.james.container.spring.mailetcontainer.JamesMailetLoader"
/>
-    <bean id="matcherloader" class="org.apache.james.container.spring.mailetcontainer.JamesMatcherLoader"
/>
+    <bean id="mailetloader" class="org.apache.james.container.spring.mailetcontainer.BeanFactoryMailetLoader"
/>
+    <bean id="matcherloader" class="org.apache.james.container.spring.mailetcontainer.BeanFactoryMatcherLoader"
/>
 
     <!-- 
       DNS Service

Modified: james/server/trunk/container-spring/src/main/config/james/mailstore.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/mailstore.xml?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/mailstore.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/mailstore.xml Fri Dec 17 19:18:58
2010
@@ -24,7 +24,14 @@
   <repositories>
       <repository class="org.apache.james.mailrepository.file.FileMailRepository">
           <config FIFO="false" CACHEKEYS="true"/> 
+          <protocols>
+              <protocol>file</protocol>
+          </protocols>
+          <types>
+                <type>MAIL</type>
+           </types>
       </repository>
+      
       <repository class="org.apache.james.mailrepository.jdbc.JDBCMailRepository">
           <protocols>
               <protocol>db</protocol>

Modified: james/server/trunk/mail-api/src/main/java/org/apache/james/mailstore/api/MailStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-api/src/main/java/org/apache/james/mailstore/api/MailStore.java?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/mail-api/src/main/java/org/apache/james/mailstore/api/MailStore.java
(original)
+++ james/server/trunk/mail-api/src/main/java/org/apache/james/mailstore/api/MailStore.java
Fri Dec 17 19:18:58 2010
@@ -19,11 +19,11 @@
 
 package org.apache.james.mailstore.api;
 
-import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.mailrepository.api.MailRepository;
 
 public interface MailStore {
 
-    public Object select(HierarchicalConfiguration config) throws StoreException;
+    public MailRepository select(String url) throws StoreException;
     
     @SuppressWarnings("serial")
     public class StoreException extends Exception {

Modified: james/server/trunk/mail-library/src/main/java/org/apache/james/mailstore/lib/JamesMailStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-library/src/main/java/org/apache/james/mailstore/lib/JamesMailStore.java?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/mail-library/src/main/java/org/apache/james/mailstore/lib/JamesMailStore.java
(original)
+++ james/server/trunk/mail-library/src/main/java/org/apache/james/mailstore/lib/JamesMailStore.java
Fri Dec 17 19:18:58 2010
@@ -35,6 +35,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.logging.Log;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.LogEnabled;
+import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailstore.api.MailStore;
 import org.apache.james.resolver.api.InstanceFactory;
 
@@ -47,7 +48,7 @@ public class JamesMailStore implements M
 
 
     // map of [destinationURL + type]->Repository
-    private Map<String, Object> repositories;
+    private Map<String, MailRepository> repositories;
 
     // map of [protocol(destinationURL) + type ]->classname of repository;
     private Map<String,String> classes;
@@ -181,12 +182,10 @@ public class JamesMailStore implements M
      *                            Configuration or retrieving the 
      *                            MailRepository
      */
-    public synchronized Object select(HierarchicalConfiguration repConf) throws StoreException
{
+    public synchronized MailRepository select(String destination) throws StoreException {
  
-        String destination = null;
         String protocol = null;
 
-        destination = repConf.getString("[@destinationURL]");
         int idx = destination.indexOf(':');
         if ( idx == -1 )
             throw new StoreException("Destination is malformed. Must be a valid URL: "
@@ -194,9 +193,8 @@ public class JamesMailStore implements M
         protocol = destination.substring(0,idx);
         
 
-        String type = repConf.getString("[@type]");
-        String repID = destination + type;
-        Object reply = repositories.get(repID);
+        String repID = destination;
+        MailRepository reply = repositories.get(repID);
         StringBuffer logBuffer = null;
         if (reply != null) {
             if (getLogger().isDebugEnabled()) {
@@ -210,7 +208,7 @@ public class JamesMailStore implements M
             }
             return reply;
         } else {
-            String key = protocol + type;
+            String key = protocol;
             String repClass = (String) classes.get( key );
              if (getLogger().isDebugEnabled()) {
                 logBuffer =
@@ -219,8 +217,6 @@ public class JamesMailStore implements M
                             .append(repClass)
                             .append(" to handle: ")
                             .append(protocol)
-                            .append(",")
-                            .append(type)
                             .append(" with key ")
                             .append(key);
                 getLogger().debug( logBuffer.toString() );
@@ -232,16 +228,12 @@ public class JamesMailStore implements M
             // If no default values, just use the selector.
             final CombinedConfiguration config =  new CombinedConfiguration();
             HierarchicalConfiguration defConf = defaultConfigs.get(key);
-            if ( defConf == null) {
-                config.addConfiguration(repConf);
-            }
-            else {
-                config.addConfiguration(repConf);
+            if ( defConf != null) {
                 config.addConfiguration(defConf);
             }
 
             try {               
-                reply =  factory.newInstance(Thread.currentThread().getContextClassLoader().loadClass(repClass),
logger, config);
+                reply =  (MailRepository) factory.newInstance(Thread.currentThread().getContextClassLoader().loadClass(repClass),
logger, config);
 
                 repositories.put(repID, reply);
                 if (getLogger().isInfoEnabled()) {

Modified: james/server/trunk/mail-library/src/test/java/org/apache/james/mailstore/mock/MockMailStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-library/src/test/java/org/apache/james/mailstore/mock/MockMailStore.java?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/mail-library/src/test/java/org/apache/james/mailstore/mock/MockMailStore.java
(original)
+++ james/server/trunk/mail-library/src/test/java/org/apache/james/mailstore/mock/MockMailStore.java
Fri Dec 17 19:18:58 2010
@@ -21,54 +21,28 @@
 
 package org.apache.james.mailstore.mock;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationUtils;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.mailstore.api.MailStore;
-
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.james.mailrepository.api.MailRepository;
+import org.apache.james.mailstore.api.MailStore;
+
 public class MockMailStore implements MailStore {
 
-    Map m_storedObjectMap = new HashMap();
+    Map<String,MailRepository> m_storedObjectMap = new HashMap<String,MailRepository>();
 
-    public void add(Object key, Object obj) {
-        m_storedObjectMap.put(key, obj);
+    public void add(String url, MailRepository obj) {
+        m_storedObjectMap.put(url, obj);
     }
     
-    public Object select(HierarchicalConfiguration object) throws StoreException {
-        Object result = get(object);
+    public MailRepository select(String url) throws StoreException {
+        MailRepository result = get(url);
         return result;
     }
 
-    private Object get(Object object) {
-        Object key = extractKeyObject(object);
+    private MailRepository get(String key) {
         System.out.println(key);
         return m_storedObjectMap.get(key);
     }
 
-    private Object extractKeyObject(Object object) {
-        if (object instanceof Configuration) {
-            Configuration repConf = (Configuration) object;
-            System.out.println(ConfigurationUtils.toString(repConf));
-
-            String type = repConf.getString("[@type]");
-            String prefix = "";
-            if (!"MAIL".equals(type) && !"SPOOL".equals(type)) {
-                prefix = type + ".";
-            }
-            String attribute = repConf.getString("[@destinationURL]");
-            String[] strings = attribute.split("/");
-            if (strings.length > 0) {
-                return prefix + strings[strings.length - 1];
-            }
-
-        }
-        return object;
-    }
-
-    public boolean isSelectable(Object object) {
-        return get(object) != null;
-    }
 }

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
(original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
Fri Dec 17 19:18:58 2010
@@ -21,7 +21,6 @@
 
 package org.apache.james.transport.mailets;
 
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailstore.api.MailStore;
@@ -76,7 +75,7 @@ public class FromRepository extends Gene
     /**
      * Initialize the mailet, loading configuration information.
      */
-    public void init() {
+    public void init() throws MessagingException{
         repositoryPath = getInitParameter("repositoryPath");
         processor = (getInitParameter("processor") == null) ? Mail.DEFAULT : getInitParameter("processor");
 
@@ -87,13 +86,9 @@ public class FromRepository extends Gene
         }
 
         try {
-            DefaultConfigurationBuilder mailConf
-                = new DefaultConfigurationBuilder();
-            mailConf.addProperty("[@destinationURL]", repositoryPath);
-            mailConf.addProperty("[@type]", "MAIL");
-            repository = (MailRepository) mailStore.select(mailConf);
+            repository = mailStore.select(repositoryPath);
         } catch (Exception e) {
-            log("Failed to retrieve Store component:" + e.getMessage());
+            throw new MessagingException("Failed to retrieve MailRepository for url " + repositoryPath,
e);
         }
     }
 

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java?rev=1050470&r1=1050469&r2=1050470&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
(original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
Fri Dec 17 19:18:58 2010
@@ -22,8 +22,8 @@
 package org.apache.james.transport.mailets;
 
 import javax.annotation.Resource;
+import javax.mail.MessagingException;
 
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailstore.api.MailStore;
 import org.apache.mailet.base.GenericMailet;
@@ -66,7 +66,7 @@ public class ToRepository extends Generi
     /**
      * Initialize the mailet, loading configuration information.
      */
-    public void init() {
+    public void init() throws MessagingException{
         repositoryPath = getInitParameter("repositoryPath");
         try {
             passThrough = new Boolean(getInitParameter("passThrough")).booleanValue();
@@ -75,14 +75,9 @@ public class ToRepository extends Generi
         }
 
         try {
-            DefaultConfigurationBuilder mailConf
-                = new DefaultConfigurationBuilder();
-            mailConf.addProperty("[@destinationURL]", repositoryPath);
-            mailConf.addProperty("[@type]", "MAIL");
-            mailConf.addProperty("[@CACHEKEYS]", getInitParameter("CACHEKEYS","TRUE"));
-            repository = (MailRepository) mailStore.select(mailConf);
+            repository = mailStore.select(repositoryPath);
         } catch (Exception e) {
-            log("Failed to retrieve Store component:" + e.getMessage());
+            throw new MessagingException("Failed to retrieve MailRepository for url " + repositoryPath,
e);
         }
 
     }



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