james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1050464 - in /james/server/trunk: container-spring/src/main/config/examples/ container-spring/src/main/config/james/ mail-file/src/main/java/org/apache/james/mailrepository/file/ mail-file/src/test/java/org/apache/james/mailrepository/ mai...
Date Fri, 17 Dec 2010 18:38:33 GMT
Author: norman
Date: Fri Dec 17 18:38:33 2010
New Revision: 1050464

URL: http://svn.apache.org/viewvc?rev=1050464&view=rev
Log:
File repository implementations are now instanced directly and not load via MailStore. This
is the first step to get rid of InstanceFactory in MailStore and make MailStore interface
easier to use

Modified:
    james/server/trunk/container-spring/src/main/config/examples/mailstore.xml
    james/server/trunk/container-spring/src/main/config/james/mailstore.xml
    james/server/trunk/mail-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
    james/server/trunk/mail-file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java
    james/server/trunk/mail-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
    james/server/trunk/mail-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
    james/server/trunk/mail-library/src/main/java/org/apache/james/mailrepository/lib/AbstractMailRepository.java

Modified: james/server/trunk/container-spring/src/main/config/examples/mailstore.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/examples/mailstore.xml?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/examples/mailstore.xml (original)
+++ james/server/trunk/container-spring/src/main/config/examples/mailstore.xml Fri Dec 17
18:38:33 2010
@@ -30,7 +30,7 @@
                 <type>MAIL</type>
             </types>
             <!-- Set if the messages should be listed sorted. False by default -->
-            <config FIFO="false"/> 
+          <config FIFO="false" CACHEKEYS="true"/> 
         </repository>
 
         <!-- JDBC based repositories.  These repositories store all message data -->
@@ -80,33 +80,6 @@
             <config FIFO="false"/> 
         </repository>
         
-        <repository class="org.apache.james.filepair.FilePersistentObjectRepository">
-            <protocols>
-                <protocol>file</protocol>
-            </protocols>
-            <types>
-                <type>OBJECT</type>
-            </types>
-            <models>
-                <model>SYNCHRONOUS</model>
-                <model>ASYNCHRONOUS</model>
-                <model>CACHE</model>
-            </models>
-        </repository>
-
-        <repository class="org.apache.james.filepair.FilePersistentStreamRepository">
-            <protocols>
-                <protocol>file</protocol>
-            </protocols>
-            <types>
-                <type>STREAM</type>
-            </types>
-            <models>
-                <model>SYNCHRONOUS</model>
-                <model>ASYNCHRONOUS</model>
-                <model>CACHE</model>
-            </models>
-        </repository>
         
         <!-- If you enable this you need to make sure that embedded Jackrabbit instance
is started as well. Check the container configuration -->  
         <!--

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=1050464&r1=1050463&r2=1050464&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 18:38:33
2010
@@ -23,13 +23,7 @@
 <mailstore>
   <repositories>
       <repository class="org.apache.james.mailrepository.file.FileMailRepository">
-          <protocols>
-              <protocol>file</protocol>
-          </protocols>
-          <types>
-              <type>MAIL</type>
-          </types>
-          <config FIFO="false"/> 
+          <config FIFO="false" CACHEKEYS="true"/> 
       </repository>
       <repository class="org.apache.james.mailrepository.jdbc.JDBCMailRepository">
           <protocols>
@@ -63,31 +57,5 @@
           </types>
           <config FIFO="false"/> 
       </repository>
-      <repository class="org.apache.james.repository.file.FilePersistentObjectRepository">
-          <protocols>
-              <protocol>file</protocol>
-          </protocols>
-          <types>
-              <type>OBJECT</type>
-          </types>
-          <models>
-              <model>SYNCHRONOUS</model>
-              <model>ASYNCHRONOUS</model>
-              <model>CACHE</model>
-          </models>
-      </repository>
-      <repository class="org.apache.james.repository.file.FilePersistentStreamRepository">
-          <protocols>
-              <protocol>file</protocol>
-          </protocols>
-          <types>
-              <type>STREAM</type>
-          </types>
-          <models>
-              <model>SYNCHRONOUS</model>
-              <model>ASYNCHRONOUS</model>
-              <model>CACHE</model>
-          </models>
-      </repository>
   </repositories>
 </mailstore>

Modified: james/server/trunk/mail-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/mail-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
(original)
+++ james/server/trunk/mail-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
Fri Dec 17 18:38:33 2010
@@ -21,21 +21,6 @@
 
 package org.apache.james.mailrepository.file;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageWrapper;
-import org.apache.james.mailrepository.lib.AbstractMailRepository;
-import org.apache.james.mailstore.api.MailStore;
-import org.apache.james.repository.api.ObjectRepository;
-import org.apache.james.repository.api.StreamRepository;
-import org.apache.mailet.Mail;
-
-import javax.annotation.PostConstruct;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -45,6 +30,21 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.mailrepository.lib.AbstractMailRepository;
+import org.apache.james.repository.file.FilePersistentObjectRepository;
+import org.apache.james.repository.file.FilePersistentStreamRepository;
+import org.apache.james.resolver.api.FileSystem;
+import org.apache.mailet.Mail;
+
 /**
  * Implementation of a MailRepository on a FileSystem.
  *
@@ -59,13 +59,18 @@ import java.util.Set;
 public class FileMailRepository
     extends AbstractMailRepository {
 
-    private StreamRepository streamRepository;
-    private ObjectRepository objectRepository;
+    private FilePersistentStreamRepository streamRepository;
+    private FilePersistentObjectRepository objectRepository;
     private String destination;
     private Set keys;
     private boolean fifo;
     private boolean cacheKeys; // experimental: for use with write mostly repositories such
as spam and error
+    private FileSystem fs;
 
+    @Resource(name="filesystem")
+    public void setFileSystem(FileSystem fs) {
+        this.fs = fs;
+    }
     
     @Override
     protected void doConfigure(HierarchicalConfiguration config)
@@ -73,16 +78,7 @@ public class FileMailRepository
         super.doConfigure(config);
         destination = config.getString("[@destinationURL]");
         if (getLogger().isDebugEnabled()) {
-            getLogger().debug("AvalonMailRepository.destinationURL: " + destination);
-        }
-        String checkType = config.getString("[@type]");
-        if (! (checkType.equals("MAIL") || checkType.equals("SPOOL")) ) {
-            String exceptionString = "Attempt to configure AvalonMailRepository as " +
-                                     checkType;
-            if (getLogger().isWarnEnabled()) {
-                getLogger().warn(exceptionString);
-            }
-            throw new ConfigurationException(exceptionString);
+            getLogger().debug("FileMailRepository.destinationURL: " + destination);
         }
         fifo = config.getBoolean("[@FIFO]", false);
         cacheKeys = config.getBoolean("[@CACHEKEYS]", true);
@@ -94,9 +90,21 @@ public class FileMailRepository
     public void init()
             throws Exception {
         try {
-            objectRepository = (ObjectRepository) selectRepository(store, "OBJECT");
-            streamRepository = (StreamRepository) selectRepository(store, "STREAM");
+            DefaultConfigurationBuilder reposConfiguration = new DefaultConfigurationBuilder();
 
+            reposConfiguration.addProperty("[@destinationURL]", destination);
+            objectRepository = new FilePersistentObjectRepository();
+            objectRepository.setLog(getLogger());
+            objectRepository.setFileSystem(fs);
+            objectRepository.configure(reposConfiguration);
+            objectRepository.init();
+            
+            streamRepository = new FilePersistentStreamRepository();
+            streamRepository.setLog(getLogger());
+            streamRepository.setFileSystem(fs);
+            streamRepository.configure(reposConfiguration);
+            streamRepository.init();
+            
             if (cacheKeys) keys = Collections.synchronizedSet(new HashSet());
 
             //Finds non-matching pairs and deletes the extra files
@@ -146,16 +154,6 @@ public class FileMailRepository
         }
     }
 
-    private Object selectRepository(MailStore store, String type) throws Exception {
-        DefaultConfigurationBuilder objectConfiguration
-            = new DefaultConfigurationBuilder();
-
-        objectConfiguration.addProperty("[@destinationURL]", destination);
-        objectConfiguration.addProperty("[@type]", type);
-        objectConfiguration.addProperty("[@model]", "SYNCHRONOUS");
-        return store.select(objectConfiguration);
-    }
-
     /**
      * @see org.apache.james.mailrepository.lib.AbstractMailRepository#internalStore(Mail)
      */

Modified: james/server/trunk/mail-file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/mail-file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java
(original)
+++ james/server/trunk/mail-file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java
Fri Dec 17 18:38:33 2010
@@ -24,9 +24,6 @@ import org.apache.commons.configuration.
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.file.FileMailRepository;
-import org.apache.james.mailstore.mock.MockMailStore;
-import org.apache.james.repository.file.FilePersistentObjectRepository;
-import org.apache.james.repository.file.FilePersistentStreamRepository;
 import org.apache.james.resolver.api.mock.MockFileSystem;
 
 public class FileMailRepositoryTest extends AbstractMailRepositoryTest {
@@ -40,27 +37,7 @@ public class FileMailRepositoryTest exte
     protected MailRepository getMailRepository() throws Exception {
         MockFileSystem fs =  new MockFileSystem();
         FileMailRepository mr = new FileMailRepository();
-        MockMailStore mockStore = new MockMailStore();
-        FilePersistentStreamRepository file_Persistent_Stream_Repository = new FilePersistentStreamRepository();
-        file_Persistent_Stream_Repository.setFileSystem(fs);
-        file_Persistent_Stream_Repository.setLog(new SimpleLog("MockLog"));
-        
-        DefaultConfigurationBuilder defaultConfiguration2 = new DefaultConfigurationBuilder();
-        defaultConfiguration2.addProperty( "[@destinationURL]", "file://target/var/mr");
-        file_Persistent_Stream_Repository.configure(defaultConfiguration2);
-        file_Persistent_Stream_Repository.init();
-        
-        mockStore.add("STREAM.mr", file_Persistent_Stream_Repository);
-        FilePersistentObjectRepository file_Persistent_Object_Repository = new FilePersistentObjectRepository();
-        file_Persistent_Object_Repository.setFileSystem(fs);
-        file_Persistent_Object_Repository.setLog(new SimpleLog("MockLog"));
-        DefaultConfigurationBuilder defaultConfiguration22 = new DefaultConfigurationBuilder();
-        defaultConfiguration22.addProperty( "[@destinationURL]", "file://target/var/mr");
-        file_Persistent_Object_Repository.configure(defaultConfiguration22);
-        file_Persistent_Object_Repository.init();
-        mockStore.add("OBJECT.mr", file_Persistent_Object_Repository);
-        mr.setStore(mockStore);
-
+        mr.setFileSystem(fs);
         mr.setLog(new SimpleLog("MockLog"));
         DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
         defaultConfiguration.addProperty( "[@destinationURL]","file://target/var/mr");

Modified: james/server/trunk/mail-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/mail-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
(original)
+++ james/server/trunk/mail-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
Fri Dec 17 18:38:33 2010
@@ -28,7 +28,7 @@ import org.apache.james.core.MailImpl;
 import org.apache.james.core.MimeMessageCopyOnWriteProxy;
 import org.apache.james.core.MimeMessageWrapper;
 import org.apache.james.mailrepository.lib.AbstractMailRepository;
-import org.apache.james.repository.api.StreamRepository;
+import org.apache.james.repository.file.FilePersistentStreamRepository;
 import org.apache.james.resolver.api.FileSystem;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
@@ -100,7 +100,7 @@ public class JDBCMailRepository
     /**
      * The stream repository used in dbfile mode
      */
-    private StreamRepository sr = null;
+    private FilePersistentStreamRepository sr = null;
 
 
     /**
@@ -248,10 +248,13 @@ public class JDBCMailRepository
                     = new DefaultConfigurationBuilder();
 
                 streamConfiguration.addProperty( "[@destinationURL]", filestore );
-                streamConfiguration.addProperty( "[@type]", "STREAM" );
-                streamConfiguration.addProperty( "[@model]", "SYNCHRONOUS" );
-                sr = (StreamRepository) store.select(streamConfiguration);
-
+              
+                sr = new FilePersistentStreamRepository();
+                sr.setLog(getLogger());
+                sr.setFileSystem(fileSystem);
+                sr.configure(streamConfiguration);
+                sr.init();
+                
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Got filestore for JdbcMailRepository: " + filestore);
                 }

Modified: james/server/trunk/mail-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/mail-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
(original)
+++ james/server/trunk/mail-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
Fri Dec 17 18:38:33 2010
@@ -29,8 +29,6 @@ import org.apache.derby.jdbc.EmbeddedDri
 import org.apache.james.mailrepository.AbstractMailRepositoryTest;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.jdbc.JDBCMailRepository;
-import org.apache.james.mailstore.mock.MockMailStore;
-import org.apache.james.repository.file.FilePersistentStreamRepository;
 import org.apache.james.resolver.api.mock.MockFileSystem;
 
 public class JDBCMailRepositoryTest extends AbstractMailRepositoryTest {
@@ -46,23 +44,11 @@ public class JDBCMailRepositoryTest exte
         DataSource datasource = getDataSource();
         JDBCMailRepository mr = new JDBCMailRepository();
         
-        // only used for dbfile
-        MockMailStore mockStore = new MockMailStore();
-        FilePersistentStreamRepository file_Persistent_Stream_Repository = new FilePersistentStreamRepository();
-        file_Persistent_Stream_Repository.setFileSystem(fs);
-        file_Persistent_Stream_Repository.setLog(new SimpleLog("MockLog"));
-        DefaultConfigurationBuilder defaultConfiguration2 = new DefaultConfigurationBuilder();
-        defaultConfiguration2.addProperty("[@destinationURL]", "file://target/var/mr/testrepo");
-        file_Persistent_Stream_Repository.configure(defaultConfiguration2);
-        file_Persistent_Stream_Repository.init();
-        mockStore.add("STREAM.mr", file_Persistent_Stream_Repository);
-        
         DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
         defaultConfiguration.addProperty("[@destinationURL]","db://maildb/mr/testrepo");
         defaultConfiguration.addProperty("sqlFile","file://conf/sqlResources.xml");
         defaultConfiguration.addProperty("[@type]","MAIL");
         mr.setFileSystem(fs);
-        mr.setStore(mockStore);
         mr.setDatasource(datasource);
         mr.setLog(new SimpleLog("MockLog"));
         mr.configure(defaultConfiguration);

Modified: james/server/trunk/mail-library/src/main/java/org/apache/james/mailrepository/lib/AbstractMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-library/src/main/java/org/apache/james/mailrepository/lib/AbstractMailRepository.java?rev=1050464&r1=1050463&r2=1050464&view=diff
==============================================================================
--- james/server/trunk/mail-library/src/main/java/org/apache/james/mailrepository/lib/AbstractMailRepository.java
(original)
+++ james/server/trunk/mail-library/src/main/java/org/apache/james/mailrepository/lib/AbstractMailRepository.java
Fri Dec 17 18:38:33 2010
@@ -27,11 +27,9 @@ 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.util.Lock;
 import org.apache.mailet.Mail;
 
-import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
 import java.io.IOException;
@@ -53,8 +51,6 @@ public abstract class AbstractMailReposi
      * based on the key 
      */
     private final Lock lock = new Lock();;
-
-    protected MailStore store; // variable is not used beyond initialization
     
     private Log logger;
 
@@ -70,16 +66,7 @@ public abstract class AbstractMailReposi
     public void configure(HierarchicalConfiguration configuration) throws ConfigurationException{
         doConfigure(configuration);
     }
-    
-    /**
-     * Set the Store to use
-     * 
-     * @param store the Store
-     */
-    @Resource(name="mailstore")
-    public void setStore(MailStore store) {
-        this.store = store;
-    }
+
     
     protected void doConfigure(HierarchicalConfiguration config) throws ConfigurationException
{
         



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