james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joac...@apache.org
Subject svn commit: r481735 - in /james/server/sandbox/mailbox-namespaces/src: conf/ java/org/apache/james/core/ java/org/apache/james/mailboxmanager/impl/ java/org/apache/james/mailboxmanager/mailstore/ java/org/apache/james/mailboxmanager/repository/ test/or...
Date Sun, 03 Dec 2006 08:25:29 GMT
Author: joachim
Date: Sun Dec  3 00:25:28 2006
New Revision: 481735

URL: http://svn.apache.org/viewvc?view=rev&rev=481735
Log:
 - virtual mailstores working now
 - introduced mailboxmanager-mailstore block to avoid circular dependencies
 - extended debugging

Added:
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java   (contents, props changed)
      - copied, changed from r471674, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo   (contents, props changed)
      - copied, changed from r471674, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml
Removed:
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/AvalonMailStore.xinfo
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo
Modified:
    james/server/sandbox/mailbox-namespaces/src/conf/james-assembly.xml
    james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/core/AvalonMailStore.xinfo
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java

Modified: james/server/sandbox/mailbox-namespaces/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/conf/james-assembly.xml?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/conf/james-assembly.xml (original)
+++ james/server/sandbox/mailbox-namespaces/src/conf/james-assembly.xml Sun Dec  3 00:25:28 2006
@@ -43,12 +43,20 @@
   <block name="mailboxmanager" class="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerProvider">
     <provide name="filesystem" role="org.apache.james.services.FileSystem" />
   </block>  
-  -->   
+-->    
     
   <block name="mailboxmanager" class="org.apache.james.mailboxmanager.impl.DefaultMailboxManagerProvider">
       <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+      <provide name="mailboxmanager-mailstore" role="org.apache.avalon.cornerstone.services.store.Store" />      
   </block>  
 
+  <block name="mailboxmanager-mailstore" class="org.apache.james.mailboxmanager.mailstore.MyAvalonMailStore" >
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />     
+  </block>      
+ 
+    
     
   <!-- The James Spool Manager block  -->
   <block name="spoolmanager" class="org.apache.james.transport.JamesSpoolManager" >
@@ -184,15 +192,9 @@
     <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
   </block>
 
-  <!-- The High Level Storage block 
-  <block name="mailstore" class="org.apache.james.core.AvalonMailStore" >
-    <provide name="database-connections"
-             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
-    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
-  </block>
-  -->
+  <!-- The High Level Storage block -->
     
-  <block name="mailstore" class="org.apache.james.mailboxmanager.repository.MyAvalonMailStore" >
+  <block name="mailstore" class="org.apache.james.core.AvalonMailStore" >
     <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
     <provide name="mailboxmanager"

Modified: james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml (original)
+++ james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml Sun Dec  3 00:25:28 2006
@@ -70,10 +70,11 @@
 
       <!-- Alternative inbox repository definition for DB use. -->
       <!-- Stores message body in file system, rest in database -->
-      <!-- TEMPORARY DEFAULT: dbfile using Derby  -->
+      <!-- TEMPORARY DEFAULT: dbfile using Derby  
       <inboxRepository>
          <repository destinationURL="dbfile://maildb/inbox/" type="MAIL"/>
       </inboxRepository>
+      -->		  
       <!-- TEMPORARY DEFAULT: dbfile using Derby  -->
 
       <!-- Alternative inbox repository definition for mbox use. -->
@@ -87,11 +88,10 @@
          <repository destinationURL="mbox:///var/mail/" type="MAIL"/>
       </inboxRepository>
       -->
-      <!-- Experimental IMAP support
+      <!-- Experimental IMAP support -->
       <inboxRepository>
          <repository destinationURL="mailboxmanager://users/" type="MAIL" />
       </inboxRepository>
-      -->
    </James>
 
 
@@ -133,6 +133,14 @@
                     </target>
                 </mount>
                 <mount>
+                    <point point="#system"/>
+                    <target
+                        class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+                        <repository destinationURL="file://var/mail/system/"
+                            type="MAIL"/>
+                    </target>
+                </mount>  				
+                <mount>
                     <point point="#mail.user1"/>
                     <target
                         class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
@@ -144,16 +152,16 @@
                     <point point="#mail.user2"/>
                     <target
                         class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
-                        <repository destinationURL="mbox://var/mail/inboxes/user2_extra"
+                        <repository destinationURL="file://var/mail/inboxes/user2"
                             type="MAIL"/>
                     </target>
                 </mount>            
             </mounts>
         </factory>
     </mailboxmanager>
-	
+    
   <!-- Experimental IMAP support -->
-	
+    
    <imapserver enabled="true">
       <!-- port 993 is the well-known/IANA registered port for IMAPs ie over SSL/TLS -->
       <!-- port 143 is the well-known/IANA registered port for Standard IMAP4 -->
@@ -1248,6 +1256,148 @@
    </mailstore>
 
 
+   <!-- The Mailstore block used by mailboxmanager --> 	
+	
+   <mailboxmanager-mailstore>
+      <repositories>
+        <repository class="org.apache.james.mailboxmanager.repository.MailboxManagerMailRepository">
+            <protocols>
+               <protocol>mailboxmanager</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/mailboxManagerSqlResources.xml</sqlFile>
+            </config>
+         </repository>
+         <!-- File based repositories.  These repositories store all message data -->
+         <!-- in the file system. -->
+         <repository class="org.apache.james.mailrepository.AvalonMailRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+         <repository class="org.apache.james.mailrepository.AvalonSpoolRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+         </repository>
+
+         <!-- JDBC based repositories.  These repositories store all message data -->
+         <!-- in the database. -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <!-- Set the size threshold for in memory handling of storing operations -->
+               <!-- Default is currently 409600000 due to a bug with mysql and binary stream -->
+               <!-- currently under investigation. Please change this only if you know what -->
+               <!-- you do. -->
+               <!--
+               <inMemorySizeLimit>4096</inMemorySizeLimit>
+                -->
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- These repositories store message delivery and headers in the DB, and the body to the filesystem -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- The mbox repository is designed for MAIL only; SPOOL performance would be less than ideal-->
+         <repository class="org.apache.james.mailrepository.MBoxMailRepository">
+            <protocols>
+               <protocol>mbox</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository">
+            <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.mailrepository.filepair.File_Persistent_Stream_Repository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>STREAM</type>
+            </types>
+            <models>
+               <model>SYNCHRONOUS</model>
+               <model>ASYNCHRONOUS</model>
+               <model>CACHE</model>
+            </models>
+         </repository>
+      </repositories>
+      
+   </mailboxmanager-mailstore>
+
+	
    <!-- The User Storage block -->
    <users-store>
       <!-- Configure User Repositories here. -->

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/core/AvalonMailStore.xinfo
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/core/AvalonMailStore.xinfo?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/core/AvalonMailStore.xinfo (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/core/AvalonMailStore.xinfo Sun Dec  3 00:25:28 2006
@@ -19,6 +19,9 @@
     <dependency>
       <service name="org.apache.james.services.FileSystem" version="1.0"/>
     </dependency>
+    <dependency>
+      <service name="org.apache.james.mailboxmanager.manager.MailboxManagerProvider" version="1.0"/>
+    </dependency>    
   </dependencies>
 
 </blockinfo>

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo Sun Dec  3 00:25:28 2006
@@ -16,6 +16,9 @@
     <dependency>
       <service name="org.apache.james.services.FileSystem" version="1.0"/>
     </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.store.Store" version="1.0"/>
+    </dependency>    
   </dependencies>
 
 </blockinfo>

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java Sun Dec  3 00:25:28 2006
@@ -21,16 +21,22 @@
 
 import java.util.Map;
 
+import org.apache.avalon.cornerstone.services.store.Store;
+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.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
+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.mailboxmanager.MailboxManagerException;
 import org.apache.james.mailboxmanager.manager.MailboxManager;
 import org.apache.james.mailboxmanager.manager.MailboxManagerFactory;
 import org.apache.james.services.User;
 
-public class MailStoreMailboxManagerFactory extends AbstractLogEnabled implements MailboxManagerFactory  {
+public class MailStoreMailboxManagerFactory extends AbstractLogEnabled
+        implements MailboxManagerFactory, Configurable, Serviceable {
     
     private MailstoreMailboxCache mailstoreMailboxCache;
 
@@ -46,7 +52,8 @@
     
     
     public void configure(Configuration conf) throws ConfigurationException {
-        getMailstoreMailboxCache().setRepositoryConf(conf.getChild("target").getChild("repository"));
+        getMailstoreMailboxCache().setRepositoryConf(
+                conf.getChild("repository", false));
         String destinationURL = conf.getChild("repository").getAttribute(
                 "destinationURL");
         getLogger().info("destinationURL:" + destinationURL);
@@ -75,5 +82,13 @@
     public Map getOpenMailboxSessionCountMap() {
         // TODO Auto-generated method stub
         return null;
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        setMailStore((Store) manager.lookup(Store.ROLE));
+    }
+    
+    public void setMailStore(Store mailStore) {
+       getMailstoreMailboxCache().setMailStore(mailStore);
     }
 }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java Sun Dec  3 00:25:28 2006
@@ -28,6 +28,7 @@
 import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.mailboxmanager.MailboxManagerException;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
@@ -60,10 +61,13 @@
                 repository = (MailRepository) getMailStore().select(conf);
                 repositoryCash.put(url, repository);
                 sessionCash.put(url, new HashSet());
+                getLogger().debug("Added MailRepository "+url+ "to the cache");
             } catch (Exception e) {
                 getLogger().error("Error optaining repository " + url);
                 throw new MailboxManagerException(e);
             }
+        } else {
+            getLogger().debug("Optained MailRepository "+url+ "from the cache");
         }
         if (repository == null) {
             throw new MailboxManagerException("could not optain repository "
@@ -72,6 +76,7 @@
         HashSet sessions = (HashSet) sessionCash.get(url);
         MailRepositoryMailboxSession mailboxSession = new MailRepositoryMailboxSession(
                 this, repository, mailboxName);
+        ContainerUtil.enableLogging(mailboxSession, getLogger().getChildLogger("session"));
         sessions.add(mailboxSession);
 
         return mailboxSession;
@@ -83,8 +88,10 @@
         String url = buildUrl(mailboxName);
         Set sessions = (Set) sessionCash.get(url);
         if (sessions != null && sessions.remove(session)) {
+            getLogger().debug("session closed for MailRepository "+url);
             if (sessions.isEmpty()) {
                 repositoryCash.remove(url);
+                getLogger().debug("MailRepository "+url+ " removed from cache");
             }
         } else {
             throw new MailboxManagerException("session not open");
@@ -110,8 +117,12 @@
 
         // TODO maybe INBOX treatment should only be done when in user
         // namespace
-        if (url.toUpperCase().endsWith(".INBOX")) {
-            url = url.substring(0, url.length() - 6);
+        if (url.toUpperCase().endsWith("INBOX")) {
+            url = url.substring(0, url.length() - 5);
+        }
+        
+        if (url.endsWith(".")) {
+            url = url.substring(0, url.length() - 1);
         }
 
         return url;

Copied: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java (from r471674, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java?view=diff&rev=481735&p1=james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java&r1=471674&p2=james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java Sun Dec  3 00:25:28 2006
@@ -1,4 +1,23 @@
-package org.apache.james.mailboxmanager.repository;
+/****************************************************************
+ * 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.mailboxmanager.mailstore;
 
 import org.apache.james.core.AvalonMailStore;
 

Propchange: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo (from r471674, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo)
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo?view=diff&rev=481735&p1=james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo&r1=471674&p2=james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo Sun Dec  3 00:25:28 2006
@@ -17,9 +17,6 @@
       <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" version="1.0"/>
     </dependency>
     <dependency>
-      <service name="org.apache.james.mailboxmanager.manager.MailboxManagerProvider" version="1.0"/>
-    </dependency>
-    <dependency>
       <service name="org.apache.james.services.FileSystem" version="1.0"/>
     </dependency>    
   </dependencies>

Propchange: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java Sun Dec  3 00:25:28 2006
@@ -26,15 +26,15 @@
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.core.MailImpl;
 import org.apache.james.mailboxmanager.MailboxManagerException;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
-import org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManager;
 import org.apache.james.mailboxmanager.mailstore.MailstoreMailboxCache;
 import org.apache.james.services.MailRepository;
 import org.apache.mailet.Mail;
 
-public class MailRepositoryMailboxSession implements MailboxSession {
+public class MailRepositoryMailboxSession extends AbstractLogEnabled implements MailboxSession {
 
     private MailRepository target;
 
@@ -68,6 +68,7 @@
     }
 
     public Collection list() throws MailboxManagerException {
+        getLogger().debug("list()");
         try {
             ArrayList list = new ArrayList();
             for (Iterator iter = target.list(); iter.hasNext();) {
@@ -80,6 +81,7 @@
     }
 
     public void remove(String key) throws MailboxManagerException {
+        getLogger().debug("remove() "+key);
         try {
             target.remove(key);
         } catch (MessagingException e) {
@@ -88,6 +90,7 @@
     }
 
     public MimeMessage retrieve(String key) throws MailboxManagerException {
+        getLogger().debug("retrieve() "+key);
         try {
             return target.retrieve(key).getMessage();
         } catch (MessagingException e) {
@@ -99,7 +102,9 @@
         try {
             Mail mail=new MailImpl(message);
             target.store(mail);
-            return mail.getName();
+            String key=mail.getName();
+            getLogger().debug("store() "+key);
+            return key;
         } catch (MessagingException e) {
             throw new MailboxManagerException(e);
         }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java Sun Dec  3 00:25:28 2006
@@ -37,10 +37,8 @@
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.core.MailImpl;
 import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.Namespace;
 import org.apache.james.mailboxmanager.mailbox.Mailbox;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
-import org.apache.james.mailboxmanager.manager.MailboxManager;
 import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
 import org.apache.james.services.User;
 import org.apache.james.userrepository.DefaultJamesUser;
@@ -60,8 +58,6 @@
      */
     private KeyBidiMap keyBidiMap = null;
 
-    private MailboxManager mailboxManager;
-
     private MailboxGateKeeper mailboxGateKeeper;
 
     private MailboxManagerProvider mailboxManagerProvider;
@@ -342,33 +338,10 @@
                 throw new RuntimeException("use<1 !");
             }
             if (mailboxSession == null) {
-                Namespace ns = mailboxManagerProvider.getPersonalDefaultNamespace(
-                        user);
-
-                String inbox = ns.getName() + ns.getHierarchyDelimter()
-                        + "INBOX";
-                mailboxSession = getMailboxManager().getImapMailboxSession(
-                        inbox);
+                mailboxSession = getMailboxManagerProvider().getInboxSession(user);
             }
             return mailboxSession;
         }
-    }
-
-    /**
-     * lazy loads a MailboxManager from MailboxManagerProvider
-     * 
-     */
-
-    protected MailboxManager getMailboxManager() throws MessagingException,
-            MailboxManagerException {
-        if (mailboxManager == null) {
-            if (user == null) {
-                throw new MessagingException("user is null");
-            }
-            mailboxManager = getMailboxManagerProvider()
-                    .getMailboxManagerInstance(user);
-        }
-        return mailboxManager;
     }
 
     protected MailboxManagerProvider getMailboxManagerProvider() {

Modified: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java Sun Dec  3 00:25:28 2006
@@ -27,6 +27,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
@@ -67,15 +68,12 @@
                                 "/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml"));
         Configuration conf = confFile.getChild("mailboxmanager", false).getChild("factory",false);
 
-        Mock mockService = mock(ServiceManager.class);
-        mockService.expects(once()).method("lookup").with(eq(FileSystem.ROLE))
-                .will(returnValue(new MockFileSystem()));
+
 
         VirtualMailboxManagerFactory virtualMailboxManagerFactory = new VirtualMailboxManagerFactory();
         virtualMailboxManagerFactory.enableLogging(new MockLogger());
         virtualMailboxManagerFactory.configure(conf);
-        virtualMailboxManagerFactory.service((ServiceManager) mockService
-                .proxy());
+        virtualMailboxManagerFactory.service(getMockService());
 //        virtualMailboxManagerFactory.initialize();
 
         String[] expected = { "#system", "#user1", "#user2", "#user3", "#mail",
@@ -128,7 +126,7 @@
         VirtualMailboxManagerFactory virtualMailboxManagerFactory = new VirtualMailboxManagerFactory();
         virtualMailboxManagerFactory.enableLogging(new MockLogger());
         virtualMailboxManagerFactory.configure(conf);
-        virtualMailboxManagerFactory.service(null);
+        virtualMailboxManagerFactory.service(getMockService());
         virtualMailboxManagerFactory.initialize();
 
         String[] expected = { "#system", "#user1", "#user2", "#user3", "#mail",
@@ -189,6 +187,15 @@
 
     protected static Set toSet(Object[] o) {
         return new HashSet(Arrays.asList(o));
+    }
+    
+    protected ServiceManager getMockService() {
+        Mock mockService = mock(ServiceManager.class);
+        mockService.expects(atMostOnce()).method("lookup").with(eq(FileSystem.ROLE))
+                .will(returnValue(new MockFileSystem()));
+        mockService.expects(atMostOnce()).method("lookup").with(eq(Store.ROLE)).will(
+                returnValue(null));
+        return (ServiceManager) mockService.proxy();
     }
 
 }

Added: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java?view=auto&rev=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java (added)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java Sun Dec  3 00:25:28 2006
@@ -0,0 +1,111 @@
+/****************************************************************
+ * 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.mailboxmanager.impl;
+
+import java.io.IOException;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.james.core.AvalonMailStore;
+import org.apache.james.imapserver.util.MessageGenerator;
+import org.apache.james.mailboxmanager.TestUtil;
+import org.apache.james.mailboxmanager.mailbox.MailboxSession;
+import org.apache.james.services.FileSystem;
+import org.apache.james.test.mock.avalon.MockLogger;
+import org.apache.james.test.mock.james.MockFileSystem;
+import org.apache.james.userrepository.DefaultJamesUser;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.xml.sax.SAXException;
+
+public class VirtualMailboxManagerIntegrationTest extends MockObjectTestCase {
+
+    Configuration confFile;
+
+    public void testMixedMailstores() throws Exception {
+        Mock mockService = mock(ServiceManager.class);
+        mockService.expects(exactly(2)).method("lookup").with(eq(Store.ROLE))
+                .will(returnValue(getMailStore()));
+
+        DefaultMailboxManagerProvider mailboxManagerProvider = new DefaultMailboxManagerProvider();
+        mailboxManagerProvider.enableLogging(new MockLogger());
+        mailboxManagerProvider.configure(getConfFile().getChild(
+                "mailboxmanager", false));
+        mailboxManagerProvider.service((ServiceManager) mockService.proxy());
+        mailboxManagerProvider.initialize();
+
+        MailboxSession session;
+
+        session = mailboxManagerProvider.getInboxSession(new DefaultJamesUser(
+                "user1", "none"));
+        doMiniTestOnSession(session);
+        session = mailboxManagerProvider.getInboxSession(new DefaultJamesUser(
+                "user2", "none"));
+        doMiniTestOnSession(session);
+    }
+
+    protected void doMiniTestOnSession(MailboxSession session)
+            throws MessagingException, IOException {
+        MimeMessage origMessage = MessageGenerator.generateSimpleMessage();
+        String key = session.store(origMessage);
+        System.out.println("Key: " + key);
+        assertNotNull(key);
+        assertEquals(key, session.list().iterator().next());
+
+        MimeMessage fetchedMessage = session.retrieve(key);
+        assertTrue(TestUtil.contentEquals(origMessage, fetchedMessage, true));
+
+        session.remove(key);
+
+        assertEquals(0, session.list().size());
+        session.close();
+    }
+
+    protected Store getMailStore() throws Exception {
+        Mock mockService = mock(ServiceManager.class);
+        mockService.expects(atLeastOnce()).method("lookup").with(
+                eq(FileSystem.ROLE)).will(returnValue(new MockFileSystem()));
+
+        AvalonMailStore mailStore = new AvalonMailStore();
+        mailStore.enableLogging(new MockLogger());
+        mailStore.configure(getConfFile().getChild("mailstore", false));
+        mailStore.service((ServiceManager) mockService.proxy());
+        mailStore.initialize();
+        return mailStore;
+    }
+
+    protected Configuration getConfFile() throws ConfigurationException,
+            SAXException, IOException {
+        if (confFile == null) {
+            confFile = new DefaultConfigurationBuilder()
+                    .build(getClass()
+                            .getResourceAsStream(
+                                    "/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml"));
+        }
+        return confFile;
+    }
+
+}

Modified: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java?view=diff&rev=481735&r1=481734&r2=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java (original)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java Sun Dec  3 00:25:28 2006
@@ -51,6 +51,8 @@
     }
 
     public void testBuildUrlInbox() {
+        assertEquals("file://var/mail/inboxes/", mailstoreMailboxCache
+                .buildUrl("#mail.INBOX"));
         assertEquals("file://var/mail/inboxes/t1", mailstoreMailboxCache
                 .buildUrl("#mail.t1.INBOX"));
         assertEquals("file://var/mail/inboxes/t1.t2", mailstoreMailboxCache

Added: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml?view=auto&rev=481735
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml (added)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml Sun Dec  3 00:25:28 2006
@@ -0,0 +1,167 @@
+<config>
+    <mailboxmanager>
+        <namespaces>
+            <usernamespace name="#mail" delimiter="."/>
+        </namespaces>
+        <factory
+            class="org.apache.james.mailboxmanager.impl.VirtualMailboxManagerFactory">
+            <mounts>
+                <mount>
+                    <point point="#mail.user1"/>
+                    <target
+                        class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+                        <repository destinationURL="file://target/var/vm/user1"
+                            type="MAIL"/>
+                    </target>
+                </mount>     
+                <mount>
+                    <point point="#mail.user2"/>
+                    <target
+                        class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+                        <repository destinationURL="file://target/var/vm/user2_test"
+                            type="MAIL"/>
+                    </target>
+                </mount>    				   
+            </mounts>
+        </factory>
+    </mailboxmanager>
+   <mailstore>
+      <repositories>
+        <repository class="org.apache.james.mailboxmanager.repository.MailboxManagerMailRepository">
+            <protocols>
+               <protocol>mailboxmanager</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/mailboxManagerSqlResources.xml</sqlFile>
+            </config>
+         </repository>
+         <!-- File based repositories.  These repositories store all message data -->
+         <!-- in the file system. -->
+         <repository class="org.apache.james.mailrepository.AvalonMailRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+         <repository class="org.apache.james.mailrepository.AvalonSpoolRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+         </repository>
+
+         <!-- JDBC based repositories.  These repositories store all message data -->
+         <!-- in the database. -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <!-- Set the size threshold for in memory handling of storing operations -->
+               <!-- Default is currently 409600000 due to a bug with mysql and binary stream -->
+               <!-- currently under investigation. Please change this only if you know what -->
+               <!-- you do. -->
+               <!--
+               <inMemorySizeLimit>4096</inMemorySizeLimit>
+                -->
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- These repositories store message delivery and headers in the DB, and the body to the filesystem -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- The mbox repository is designed for MAIL only; SPOOL performance would be less than ideal-->
+         <repository class="org.apache.james.mailrepository.MBoxMailRepository">
+            <protocols>
+               <protocol>mbox</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository">
+            <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.mailrepository.filepair.File_Persistent_Stream_Repository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>STREAM</type>
+            </types>
+            <models>
+               <model>SYNCHRONOUS</model>
+               <model>ASYNCHRONOUS</model>
+               <model>CACHE</model>
+            </models>
+         </repository>
+      </repositories>
+      
+   </mailstore>
+</config>
+



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