You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/10/24 18:57:27 UTC

svn commit: r467386 - in /james/server/trunk/src: conf/ java/org/apache/james/core/ java/org/apache/james/remotemanager/ java/org/apache/james/services/ java/org/apache/james/smtpserver/core/filter/fastfail/ java/org/apache/james/vut/ test/org/apache/j...

Author: norman
Date: Tue Oct 24 09:57:26 2006
New Revision: 467386

URL: http://svn.apache.org/viewvc?view=rev&rev=467386
Log:
Add a "store" for VirtualUserTable. See JAMES-426
Add a DefaultVirtualUserTable which should be used as default implementation
Create a AbstractAvalonStore and refactor AvalonUserStore to extend it
Remove unused config elements form james-smtphandlerchain.xml
Add javadocs

Added:
    james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java   (with props)
    james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java   (with props)
    james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.xinfo
    james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java   (with props)
    james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.xinfo
    james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java   (with props)
Modified:
    james/server/trunk/src/conf/james-assembly.xml
    james/server/trunk/src/conf/james-config.xml
    james/server/trunk/src/conf/james-smtphandlerchain.xml
    james/server/trunk/src/java/org/apache/james/core/AvalonUsersStore.java
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo
    james/server/trunk/src/java/org/apache/james/services/DomainList.java
    james/server/trunk/src/java/org/apache/james/services/VirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
    james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
    james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java
    james/server/trunk/src/test/org/apache/james/vut/JDBCVirtualUserTableTest.java

Modified: james/server/trunk/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-assembly.xml?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/conf/james-assembly.xml (original)
+++ james/server/trunk/src/conf/james-assembly.xml Tue Oct 24 09:57:26 2006
@@ -89,8 +89,6 @@
     <provide name="bayesiananalyzermanagement"
              role="org.apache.james.services.BayesianAnalyzerManagementService"/>
     <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
-    <provide name="virtualusertable"
-             role="org.apache.james.services.VirtualUserTableManagement" />
   </block>
 
   <!-- The User Management block  -->
@@ -142,7 +140,7 @@
     <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
     <provide name="filesystem" role="org.apache.james.services.FileSystem" />
-    <provide name="virtualusertable"
+    <provide name="defaultvirtualusertable"
              role="org.apache.james.services.VirtualUserTable" />
   </block>
 
@@ -221,22 +219,18 @@
   </block>
   
   
-  <!-- ######################################################################## -->
-  <!-- VirtualUserTable services -->
-  <block name="virtualusertable" class="org.apache.james.vut.JDBCVirtualUserTable">
+  <!-- VirtualUserTable Store -->
+  <block name="virtualusertable-store" class="org.apache.james.core.AvalonVirtualUserTableStore">
     <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"/>
     <provide name="filesystem" role="org.apache.james.services.FileSystem"/>
     <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
   </block>
   
-  <!-- XML implementation of the virtualusertable service -->
-  <!--
-  <block name="virtualusertable" class="org.apache.james.vut.XMLVirtualUserTable">
-      <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
+    <block name="defaultvirtualusertable" class="org.apache.james.core.DefaultVirtualUserTable">
+    <provide name="virtualusertable-store"
+             role="org.apache.james.services.VirtualUserTableStore"/>
   </block>
-  -->
-  <!-- ######################################################################## -->
   
   
   <!-- ######################################################################## -->

Modified: james/server/trunk/src/conf/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-config.xml?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/conf/james-config.xml (original)
+++ james/server/trunk/src/conf/james-config.xml Tue Oct 24 09:57:26 2006
@@ -816,13 +816,7 @@
    <bayesiananalyzermanagement> 
       <repositoryPath> db://maildb </repositoryPath>
    </bayesiananalyzermanagement>  
-   
-   <!-- VirtualUserTable Service-->
-   <virtualusertable> 
-      <repositoryPath> db://maildb </repositoryPath>
-      <sqlFile>file://conf/sqlResources.xml</sqlFile>
-   </virtualusertable>  
-   
+    
 
    <!-- The RemoteManager server is enabled by default -->
    <!-- Disabling blocks will stop them from listening, -->
@@ -1201,7 +1195,7 @@
             </models>
          </repository>
       </repositories>
-
+      
    </mailstore>
 
 
@@ -1260,6 +1254,29 @@
       -->
 
    </users-store>
+   
+   <!-- The VirtualUserTable Store block -->
+   <virtualusertable-store>
+   
+      <!-- The DefaultVirtualUserTable  for storing James' VirtualUserTable mappings. -->
+      <!--
+      <table name="DefaultVirtualUserTable" class="org.apache.james.vut.XMLVirtualUserTable">
+         <mapping> some@domain=someuser </mapping>
+      </table>
+      -->
+
+      <!-- Database backed VirtualUsertable -->
+      <!-- -->
+      <!-- Use these configurations to store the VirtualUserTable in a database. -->
+      <!-- Note: The <data-source> element must refer to a connection configured -->
+      <!--       in the <database-connections> configuration section. -->
+
+      <!-- The DefaultVirtualUserTable  for storing James' VirtualUserTable mappings. -->
+      <!-- TEMPORARY DEFAULT: db using Derby  -->
+      <table name="DefaultVirtualUserTable" class="org.apache.james.vut.JDBCVirtualUserTable" destinationURL="db://maildb/VirtualUserTable">
+         <sqlFile>file://conf/sqlResources.xml</sqlFile>
+      </table>
+   </virtualusertable-store>
 
    <!-- The database-connections block -->
    <database-connections>

Modified: james/server/trunk/src/conf/james-smtphandlerchain.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-smtphandlerchain.xml?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/conf/james-smtphandlerchain.xml (original)
+++ james/server/trunk/src/conf/james-smtphandlerchain.xml Tue Oct 24 09:57:26 2006
@@ -96,30 +96,6 @@
      </handler>
      -->
      
-     <!-- IF you want to use the ValidRcptHandler you can set virtual user which will accepted here.-->
-     <!--
-     <handler class="org.apache.james.smtpserver.core.filter.fastfail.XMLVirtualUserTableHandler" command="RCPT">
-         <!- 1:1 mapping ->
-         <mapping>morgoth@middle-earth=sauron@mordor</mapping>
-         <!- 1:n mapping ->
-         <mapping>istari@middle-earth=saruman@isengard;radigast;gandalf</mapping>
-         <!- regex based mapping ->
-         <mapping>*@osgilliath=regex:(.*)@osgilliath:${1}@minas-tirith</mapping>
-         <!- both standard and regex mapping ->
-         <mapping>ring@*=onering@mordor;regex:ring@(.*):ring@${1}</mapping>
-         <!- conditional regex mapping example ->
-         <mapping>*@listserver=regex:(.*)-on@listserver:${1}-subscribe@listserver;
-                               regex:(.*)-off@listserver:${1}-unsubscribe@listserver
-         </mapping>
-     </handler>
-     -->
-     
-     <!-- IF you want to use the ValidRcptHandler you can set virtual user which will accepted here.-->
-     <!--
-     <handler class="org.apache.james.smtpserver.core.filter.fastfail.JDBCVirtualUserTableHandler" command="RCPT">
-         <table> db://maildb/VirtualUserTable </table>
-     </handler>
-     -->
          
      <!-- If activated all email will get rejected which has no valid user -->
      <!-- You need to add the recipient to the validRecipient list if you want -->

Added: james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java (added)
+++ james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java Tue Oct 24 09:57:26 2006
@@ -0,0 +1,169 @@
+/****************************************************************
+ * 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.core;
+
+import org.apache.avalon.framework.activity.Initializable;
+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 java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Provides a registry of objects
+ *
+ */
+public abstract class AbstractAvalonStore
+    extends AbstractLogEnabled
+    implements Serviceable, Configurable, Initializable {
+
+    private HashMap objects;
+
+    /**
+     * The Avalon configuration used by the instance
+     */
+    protected Configuration          configuration;
+
+    /**
+     * The Avalon component manager used by the instance
+     */
+    protected ServiceManager       manager;
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
+     */
+    public void service( final ServiceManager manager )
+        throws ServiceException {
+        this.manager = manager;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
+     */
+    public void configure( final Configuration configuration )
+        throws ConfigurationException {
+        this.configuration = configuration;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize()
+        throws Exception {
+
+        getLogger().info(getStoreName() + " init...");
+        objects = new HashMap();
+
+        Configuration[] repConfs = getConfigurations(configuration);
+        ClassLoader theClassLoader = null;
+        for ( int i = 0; i < repConfs.length; i++ )
+        {
+            Configuration repConf = repConfs[i];
+            String repName = repConf.getAttribute("name");
+            String repClass = repConf.getAttribute("class");
+
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Starting " + repClass);
+            }
+
+            if (theClassLoader == null) {
+                theClassLoader = Thread.currentThread().getContextClassLoader();
+            }
+
+            Object object = getClassInstance(theClassLoader,repClass);
+
+            setupLogger(object);
+
+            ContainerUtil.service(object,manager);
+
+            ContainerUtil.configure(object,repConf);
+            ContainerUtil.initialize(object);
+            
+            
+            objects.put(repName, object);
+            if (getLogger().isInfoEnabled()) {
+                StringBuffer logBuffer = 
+                    new StringBuffer(64)
+                            .append("Store  ")
+                            .append(repName)
+                            .append(" started.");
+                getLogger().info(logBuffer.toString());
+            }
+        }
+    }
+
+
+    /** 
+     * Get the object, if any, whose name corresponds to
+     * the argument parameter
+     *
+     * @param name the name of the desired object
+     *
+     * @return the Object corresponding to the name parameter
+     */
+    protected Object getObject(String name) {
+        return objects.get(name);
+    }
+
+    /** 
+     * Yield an <code>Iterator</code> over the set of object
+     * names managed internally by this store.
+     *
+     * @return an Iterator over the set of repository names
+     *         for this store
+     */
+    protected Iterator getObjectNames() {
+        return this.objects.keySet().iterator();
+    }
+    
+    /**
+     * Return new Object of the loader classname
+     * 
+     * @param loader the ClassLoader
+     * @param className the classname
+     * @return the loaded Objected
+     * @throws Exception
+     */
+    public abstract Object getClassInstance(ClassLoader loader, String className) throws Exception;
+    
+    /**
+     * Return the Store configurations 
+     * 
+     * @param config the main config
+     * @return configurations
+     */
+    public abstract Configuration[] getConfigurations(Configuration config);
+    
+    /**
+     * Return the Store name which should be used for logging
+     * 
+     * @return the name
+     */
+    public abstract String getStoreName();
+    
+}

Propchange: james/server/trunk/src/java/org/apache/james/core/AbstractAvalonStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/server/trunk/src/java/org/apache/james/core/AvalonUsersStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AvalonUsersStore.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AvalonUsersStore.java (original)
+++ james/server/trunk/src/java/org/apache/james/core/AvalonUsersStore.java Tue Oct 24 09:57:26 2006
@@ -21,19 +21,10 @@
 
 package org.apache.james.core;
 
-import org.apache.avalon.framework.activity.Initializable;
-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.services.UsersRepository;
 import org.apache.james.services.UsersStore;
 
-import java.util.HashMap;
 import java.util.Iterator;
 
 /**
@@ -41,88 +32,8 @@
  *
  */
 public class AvalonUsersStore
-    extends AbstractLogEnabled
-    implements Serviceable, Configurable, Initializable, UsersStore {
-
-    /**
-     * A mapping of respository identifiers to actual repositories
-     * This mapping is obtained from the component configuration
-     */
-    private HashMap repositories;
-
-    /**
-     * The Avalon configuration used by the instance
-     */
-    protected Configuration          configuration;
-
-    /**
-     * The Avalon component manager used by the instance
-     */
-    protected ServiceManager       manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
-     */
-    public void service( final ServiceManager manager )
-        throws ServiceException {
-        this.manager = manager;
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure( final Configuration configuration )
-        throws ConfigurationException {
-        this.configuration = configuration;
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize()
-        throws Exception {
-
-        getLogger().info("AvalonUsersStore init...");
-        repositories = new HashMap();
-
-        Configuration[] repConfs = configuration.getChildren("repository");
-        ClassLoader theClassLoader = null;
-        for ( int i = 0; i < repConfs.length; i++ )
-        {
-            Configuration repConf = repConfs[i];
-            String repName = repConf.getAttribute("name");
-            String repClass = repConf.getAttribute("class");
-
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Starting " + repClass);
-            }
-
-            if (theClassLoader == null) {
-                theClassLoader = Thread.currentThread().getContextClassLoader();
-            }
-
-            UsersRepository rep = (UsersRepository) theClassLoader.loadClass(repClass).newInstance();
-
-            setupLogger(rep);
-
-            ContainerUtil.service(rep,manager);
-
-            ContainerUtil.configure(rep,repConf);
-            ContainerUtil.initialize(rep);
-            
-            repositories.put(repName, rep);
-            if (getLogger().isInfoEnabled()) {
-                StringBuffer logBuffer = 
-                    new StringBuffer(64)
-                            .append("UsersRepository ")
-                            .append(repName)
-                            .append(" started.");
-                getLogger().info(logBuffer.toString());
-            }
-        }
-        getLogger().info("AvalonUsersStore ...init");
-    }
-
+    extends AbstractAvalonStore
+    implements UsersStore {
 
     /** 
      * Get the repository, if any, whose name corresponds to
@@ -133,7 +44,7 @@
      * @return the UsersRepository corresponding to the name parameter
      */
     public UsersRepository getRepository(String name) {
-        UsersRepository response = (UsersRepository) repositories.get(name);
+        UsersRepository response = (UsersRepository) getObject(name);
         if ((response == null) && (getLogger().isWarnEnabled())) {
             getLogger().warn("No users repository called: " + name);
         }
@@ -148,6 +59,27 @@
      *         for this store
      */
     public Iterator getRepositoryNames() {
-        return this.repositories.keySet().iterator();
+        return getObjectNames();
+    }
+    
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getClassInstance(java.lang.ClassLoader, java.lang.String)
+     */
+    public Object getClassInstance(ClassLoader loader, String repClass) throws Exception {
+        return  (UsersRepository) loader.loadClass(repClass).newInstance();
+    }
+
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getConfigurations(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public Configuration[] getConfigurations(Configuration config) {
+        return configuration.getChildren("repository");
+    }
+    
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getStoreName()
+     */
+    public String getStoreName() {
+        return "AvolonUsersStore";
     }
 }

Added: james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java (added)
+++ james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java Tue Oct 24 09:57:26 2006
@@ -0,0 +1,87 @@
+/****************************************************************
+ * 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.core;
+
+import org.apache.avalon.framework.configuration.Configuration;
+
+import org.apache.james.services.VirtualUserTable;
+import org.apache.james.services.VirtualUserTableStore;
+
+import java.util.Iterator;
+
+/**
+ * Provides a registry of VirtualUserTables
+ *
+ */
+public class AvalonVirtualUserTableStore
+    extends AbstractAvalonStore
+    implements VirtualUserTableStore {
+
+   
+    /** 
+     * Get the repository, if any, whose name corresponds to
+     * the argument parameter
+     *
+     * @param name the name of the desired repository
+     *
+     * @return the VirtualUserTable corresponding to the name parameter
+     */
+    public VirtualUserTable getTable(String name) {
+        VirtualUserTable response = (VirtualUserTable) getObject(name);
+        if ((response == null) && (getLogger().isWarnEnabled())) {
+            getLogger().warn("No virtualUserTable called: " + name);
+        }
+        return response;
+    }
+
+    /** 
+     * Yield an <code>Iterator</code> over the set of repository
+     * names managed internally by this store.
+     *
+     * @return an Iterator over the set of repository names
+     *         for this store
+     */
+    public Iterator getTableNames() {
+        return getObjectNames();
+    }
+
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getClassInstance(java.lang.ClassLoader, java.lang.String, org.apache.avalon.framework.configuration.Configuration)
+     */
+    public Object getClassInstance(ClassLoader loader, String repClass) throws Exception {
+        return (VirtualUserTable) loader.loadClass(repClass).newInstance();
+    }
+
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getConfigurations(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public Configuration[] getConfigurations(Configuration config) {
+        return configuration.getChildren("table");
+    }
+
+    /**
+     * @see org.apache.james.core.AbstractAvalonStore#getStoreName()
+     */
+    public String getStoreName() {
+        return "AvalonVirtualUserStore";
+    }
+}

Propchange: james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.xinfo?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.xinfo (added)
+++ james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.xinfo Tue Oct 24 09:57:26 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+
+<blockinfo>
+
+  <!-- section to describe block -->
+  <block>
+    <version>1.0</version>
+  </block>
+
+  <!-- services that are offered by this block -->
+  <services>
+    <service name="org.apache.james.services.VirtualUserTableStore" version="1.0" />
+  </services>
+
+  <dependencies>
+    <dependency>
+      <service name="org.apache.james.services.DNSServer" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.services.FileSystem" version="1.0"/>
+    </dependency>
+  </dependencies>
+
+</blockinfo>

Added: james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java (added)
+++ james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java Tue Oct 24 09:57:26 2006
@@ -0,0 +1,117 @@
+/****************************************************************
+ * 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.core;
+
+import java.util.Collection;
+
+import org.apache.avalon.framework.activity.Initializable;
+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.services.VirtualUserTableManagement;
+import org.apache.james.services.VirtualUserTableStore;
+import org.apache.james.vut.ErrorMappingException;
+import org.apache.james.vut.InvalidMappingException;
+
+/**
+ * Default VirtualUserTable
+ */
+public class DefaultVirtualUserTable implements VirtualUserTableManagement, Serviceable, Initializable {
+
+    VirtualUserTableManagement vut = null;
+    
+    VirtualUserTableStore store = null;
+    
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        vut = (VirtualUserTableManagement) store.getTable("DefaultVirtualUserTable");
+        if (vut == null) {
+            throw new ServiceException("","The VirtualUserTable could not be found.");
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager arg0) throws ServiceException {
+        store = (VirtualUserTableStore) arg0.lookup(VirtualUserTableStore.ROLE);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#addAddressMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addAddressMapping(String user, String domain, String address) throws InvalidMappingException {
+        return vut.addAddressMapping(user, domain, address);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#addErrorMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addErrorMapping(String user, String domain, String error) throws InvalidMappingException {
+        return vut.addErrorMapping(user, domain, error);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#addRegexMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addRegexMapping(String user, String domain, String regex) throws InvalidMappingException {
+        return vut.addRegexMapping(user, domain, regex);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#getUserDomainMappings(java.lang.String, java.lang.String)
+     */
+    public Collection getUserDomainMappings(String user, String domain) throws InvalidMappingException {
+        return vut.getUserDomainMappings(user, domain);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#removeAddressMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeAddressMapping(String user, String domain, String address) throws InvalidMappingException {
+        return vut.removeAddressMapping(user, domain, address);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#removeErrorMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeErrorMapping(String user, String domain, String error) throws InvalidMappingException {
+        return vut.removeErrorMapping(user, domain, error);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTableManagement#removeRegexMapping(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeRegexMapping(String user, String domain, String regex) throws InvalidMappingException {
+        return vut.removeRegexMapping(user, domain, regex);
+    }
+
+    /**
+     * @see org.apache.james.services.VirtualUserTable#getMappings(java.lang.String, java.lang.String)
+     */
+    public Collection getMappings(String user, String domain) throws ErrorMappingException {
+        return vut.getMappings(user, domain);
+    }
+
+}

Propchange: james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.xinfo?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.xinfo (added)
+++ james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.xinfo Tue Oct 24 09:57:26 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+
+<blockinfo>
+
+  <!-- section to describe block -->
+  <block>
+    <version>1.0</version>
+  </block>
+
+  <!-- services that are offered by this block -->
+  <services>
+    <service name="org.apache.james.services.VirtualUserTable" version="1.0" />
+    <service name="org.apache.james.services.VirtualUserTableManagement" version="1.0" />
+  </services>
+
+  <dependencies>
+    <dependency>
+      <service name="org.apache.james.services.VirtualUserTableStore" version="1.0"/>
+    </dependency>
+  </dependencies>
+
+</blockinfo>

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo Tue Oct 24 09:57:26 2006
@@ -43,8 +43,5 @@
     <dependency>
       <service name="org.apache.james.services.DNSServer" version="1.0"/>
     </dependency>
-    <dependency>
-      <service name="org.apache.james.services.VirtualUserTableManagement" version="1.0"/>
-    </dependency>
   </dependencies>
 </blockinfo>

Modified: james/server/trunk/src/java/org/apache/james/services/DomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/DomainList.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/DomainList.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/DomainList.java Tue Oct 24 09:57:26 2006
@@ -29,6 +29,9 @@
  */
 public interface DomainList {
 
+    /**
+     * The component role used by components implementing this service
+     */
     public final static String ROLE ="org.apache.james.services.DomainList";
     
     /**

Modified: james/server/trunk/src/java/org/apache/james/services/VirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/VirtualUserTable.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/VirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/VirtualUserTable.java Tue Oct 24 09:57:26 2006
@@ -25,8 +25,15 @@
 
 import org.apache.james.vut.ErrorMappingException;
 
+/**
+ * Interface which should be implemented of classes which map recipients
+ *
+ */
 public interface VirtualUserTable {
     
+    /**
+     * The component role used by components implementing this service
+     */
     public static final String ROLE = "org.apache.james.services.VirtualUserTable";
     
     /**

Modified: james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java Tue Oct 24 09:57:26 2006
@@ -27,6 +27,9 @@
 
 public interface VirtualUserTableManagement extends VirtualUserTable{
     
+    /**
+     * The component role used by components implementing this service
+     */
     public static final String ROLE = "org.apache.james.services.VirtualUserTableManagement";
     
     /**

Added: james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java?view=auto&rev=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java (added)
+++ james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java Tue Oct 24 09:57:26 2006
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.services;
+
+import java.util.Iterator;
+
+/**
+ * Interface for Phoenix blocks to access a store of VirtualUserTable. A VirtualUserTableStore
+ * contains one or more VirtualUserTables. Multiple VirtualUserTables may or may
+ * not have overlapping membership. 
+ *
+ * @version 1.0.0, 24/04/1999
+ */
+public interface VirtualUserTableStore 
+{
+    /**
+     * The component role used by components implementing this service
+     */
+    String ROLE = "org.apache.james.services.VirtualUserTableStore";
+
+    /** 
+     * Get the table, if any, whose name corresponds to
+     * the argument parameter
+     *
+     * @param name the name of the desired repository
+     *
+     * @return the VirtualUserTable corresponding to the name parameter
+     */
+    VirtualUserTable getTable( String name );
+
+    /** 
+     * Yield an <code>Iterator</code> over the set of repository
+     * names managed internally by this store.
+     *
+     * @return an Iterator over the set of repository names
+     *         for this store
+     */
+    Iterator getTableNames();
+}

Propchange: james/server/trunk/src/java/org/apache/james/services/VirtualUserTableStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java Tue Oct 24 09:57:26 2006
@@ -35,6 +35,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.james.services.VirtualUserTable;
+import org.apache.james.services.VirtualUserTableStore;
 import org.apache.james.smtpserver.CommandHandler;
 import org.apache.james.smtpserver.SMTPSession;
 import org.apache.james.util.mail.dsn.DSNStatus;
@@ -55,12 +56,17 @@
     private Collection regex = new ArrayList();
     private boolean vut = true;
     private VirtualUserTable table;
+    private String tableName = null;
     
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager arg0) throws ServiceException {
-        table = (VirtualUserTable) arg0.lookup(VirtualUserTable.ROLE); 
+        if (tableName == null || tableName.equals("")) {
+            table = (VirtualUserTable) arg0.lookup(VirtualUserTable.ROLE); 
+        } else {
+            table = ((VirtualUserTableStore) arg0.lookup(VirtualUserTableStore.ROLE)).getTable(tableName);
+        }
     }
     
     /**
@@ -90,6 +96,11 @@
         if (vutConfig != null) {
             vut = vutConfig.getValueAsBoolean(true);    
         }
+        Configuration tableConfig = arg0.getChild("table");
+        
+        if (tableConfig != null) {
+            tableName = tableConfig.getValue(null);   
+        }
     }
     
     /**
@@ -145,7 +156,7 @@
     }
     
     public void setVirtualUserTableSupport(boolean vut) {
-    this.vut = vut;
+        this.vut = vut;
     }
 
     /**

Modified: james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java Tue Oct 24 09:57:26 2006
@@ -171,7 +171,6 @@
     }
     
     /**
-     * @throws InvalidMappingException 
      * @see org.apache.james.services.VirtualUserTableManagement#addErrorMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean addErrorMapping(String user, String domain, String error) throws InvalidMappingException {   
@@ -181,7 +180,6 @@
     }
     
     /**
-     * @throws InvalidMappingException 
      * @see org.apache.james.services.VirtualUserTableManagement#removeErrorMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean removeErrorMapping(String user, String domain, String error) throws InvalidMappingException {

Modified: james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java Tue Oct 24 09:57:26 2006
@@ -88,13 +88,12 @@
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
     public void configure(Configuration arg0) throws ConfigurationException {
-        Configuration config = arg0.getChild("repositoryPath");
+        String destination = arg0.getAttribute("destinationURL",null);
     
-        if (config == null) {
-            throw new ConfigurationException("RepositoryPath must configured");
+        if (destination == null) {
+            throw new ConfigurationException("destinationURL must configured");
         }
-        
-        String destination = config.getValue();
+
         // normalize the destination, to simplify processing.
         if ( ! destination.endsWith("/") ) {
             destination += "/";

Modified: james/server/trunk/src/test/org/apache/james/vut/JDBCVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/vut/JDBCVirtualUserTableTest.java?view=diff&rev=467386&r1=467385&r2=467386
==============================================================================
--- james/server/trunk/src/test/org/apache/james/vut/JDBCVirtualUserTableTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/vut/JDBCVirtualUserTableTest.java Tue Oct 24 09:57:26 2006
@@ -52,7 +52,7 @@
 
         mr.enableLogging(new MockLogger());
         DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
-        defaultConfiguration.addChild(new AttrValConfiguration("repositoryPath","db://maildb"));
+        defaultConfiguration.setAttribute("destinationURL","db://maildb/VirtualUserTable");
         defaultConfiguration.addChild(new AttrValConfiguration("sqlFile","file://conf/sqlResources.xml"));
         mr.service(serviceManager);
         mr.configure(defaultConfiguration);



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org