james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r883725 - in /james/server/trunk: phoenix-deployment/src/test/org/apache/james/ spoolmanager-function/src/main/java/org/apache/james/ spoolmanager-function/src/main/java/org/apache/james/transport/mailets/
Date Tue, 24 Nov 2009 15:11:15 GMT
Author: norman
Date: Tue Nov 24 15:11:14 2009
New Revision: 883725

URL: http://svn.apache.org/viewvc?rev=883725&view=rev
Log:
More decoupling of Avalon to move to Guice (JAMES-893)

Modified:
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/AvalonJamesTest.java
    james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/AvalonJames.java
    james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/James.java
    james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
    james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
    james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/VirtualUserTable.java

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/AvalonJamesTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/AvalonJamesTest.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/AvalonJamesTest.java (original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/AvalonJamesTest.java Tue
Nov 24 15:11:14 2009
@@ -27,6 +27,7 @@
 import org.apache.james.api.user.UsersStore;
 import org.apache.james.services.FileSystem;
 import org.apache.james.services.MailServer;
+import org.apache.james.services.SpoolRepository;
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.test.mock.avalon.MockServiceManager;
 import org.apache.james.userrepository.MockUsersRepository;
@@ -53,15 +54,13 @@
     
 
     private MockServiceManager setUpServiceManager() throws Exception {
-        MockServiceManager serviceManager = new MockServiceManager();
-        MockUsersRepository mockUsersRepository = new MockUsersRepository();
-       
+        MockServiceManager serviceManager = new MockServiceManager();       
         
         serviceManager.put(UsersRepository.ROLE, mockUsersRepository);
         serviceManager.put(UsersStore.ROLE, usersStore);
         serviceManager.put(FileSystem.ROLE, fs);
         serviceManager.put(DomainList.ROLE, domList);
-
+        serviceManager.put(SpoolRepository.ROLE, mockMailRepository);
         serviceManager.put(Store.ROLE, mockStore);
         serviceManager.put(DNSService.ROLE, dns);
         return serviceManager;

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/AvalonJames.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/AvalonJames.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/AvalonJames.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/AvalonJames.java
Tue Nov 24 15:11:14 2009
@@ -227,7 +227,7 @@
                 bind(DNSService.class).annotatedWith(Names.named("org.apache.james.api.dnsservice.DNSService")).toInstance(dns);
                 bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
                 bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
-                bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log@MailetLogger")).toInstance(mailetLogger);
+                bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log@MailetLog")).toInstance(mailetLogger);
                 bind(Store.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.store.Store")).toInstance(store);
                 bind(FileSystem.class).annotatedWith(Names.named("org.apache.james.services.FileSystem")).toInstance(fs);
                 bind(UsersRepository.class).annotatedWith(Names.named("org.apache.james.api.user.UsersRepository")).toInstance(userRepos);

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/James.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/James.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/James.java (original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/James.java Tue
Nov 24 15:11:14 2009
@@ -277,8 +277,8 @@
         
         logger.info("Defaultdomain: " + defaultDomain);
         
-        HierarchicalConfiguration helloNameConfig = conf.configurationAt("helloName");
-        if (helloNameConfig != null) {
+        if (conf.getKeys("helloName").hasNext()) {
+            HierarchicalConfiguration helloNameConfig = conf.configurationAt("helloName");
             boolean autodetect = helloNameConfig.getBoolean("[@autodetect]", true);
             if (autodetect) {
                 try {

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
Tue Nov 24 15:11:14 2009
@@ -105,9 +105,9 @@
             /**
              * @see org.apache.mailet.MailetConfig#getInitParameterNames()
              */
-            public Iterator getInitParameterNames() {
+            public Iterator<String> getInitParameterNames() {
                 IteratorChain c = new IteratorChain();
-                Collection h = new ArrayList();
+                Collection<String> h = new ArrayList<String>();
                 h.add("addDeliveryHeader");
                 h.add("resetReturnPath");
                 c.addIterator(getMailetConfig().getInitParameterNames());

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
Tue Nov 24 15:11:14 2009
@@ -24,12 +24,10 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.annotation.Resource;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.api.user.UsersStore;
 import org.apache.james.api.vut.ErrorMappingException;
@@ -58,6 +56,7 @@
      * inboxes on this server.
      */
     private UsersRepository usersRepository;
+    private UsersStore usersStore;
 
     /**
      * Return a string describing this mailet.
@@ -68,6 +67,16 @@
         return "Local User Aliasing and Forwarding Mailet";
     }
 
+    @Resource(name="org.apache.james.api.user.UsersRepository")
+    public void setUsersRepository(UsersRepository usersRepository) {
+        this.usersRepository = usersRepository;
+    }
+    
+    @Resource(name="org.apache.james.api.user.UsersStore")
+    public void setUsersStore(UsersStore usersStore) {
+        this.usersStore = usersStore;
+    }
+    
     /**
      * Return null when the mail should be GHOSTed, the username string when it
      * should be changed due to the ignoreUser configuration.
@@ -77,7 +86,7 @@
      * @param message
      * @throws MessagingException
      */
-    public Collection processMail(MailAddress sender, MailAddress recipient,
+    public Collection<MailAddress> processMail(MailAddress sender, MailAddress recipient,
             MimeMessage message) throws MessagingException {
         if (recipient == null) {
             throw new IllegalArgumentException(
@@ -91,7 +100,7 @@
         if (usersRepository instanceof VirtualUserTable) {
             Collection<String> mappings;
             try {
-                mappings = ((VirtualUserTable) usersRepository).getMappings(recipient.getUser(),
recipient.getHost());
+                mappings = ((VirtualUserTable) usersRepository).getMappings(recipient.getLocalPart(),
recipient.getDomain());
             } catch (ErrorMappingException e) {
                 StringBuilder errorBuffer = new StringBuilder(128)
                     .append("A problem as occoured trying to alias and forward user ")
@@ -111,43 +120,27 @@
                 .append(" does not implement VirtualUserTable interface).");
             getMailetContext().log(errorBuffer.toString());
         }
-        String realName = usersRepository.getRealName(recipient.getUser());
+        String realName = usersRepository.getRealName(recipient.getLocalPart());
+      
+        ArrayList<MailAddress> ret = new ArrayList<MailAddress>();
         if (realName != null) {
-            ArrayList ret = new ArrayList();
-            ret.add(new MailAddress(realName, recipient.getHost()));
+            ret.add(new MailAddress(realName, recipient.getDomain()));
             return ret;
         } else {
-            ArrayList ret = new ArrayList();
             ret.add(recipient);
             return ret;
         }
     }
 
+    
     /**
      * @see org.apache.mailet.GenericMailet#init()
      */
     public void init() throws MessagingException {
         super.init();
-        ServiceManager compMgr = (ServiceManager) getMailetContext()
-                .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
-        try {
-            String userRep = getInitParameter("usersRepository");
-            if (userRep == null || userRep.length() == 0) {
-                try {
-                    usersRepository = (UsersRepository) compMgr
-                            .lookup(UsersRepository.ROLE);
-                } catch (ServiceException e) {
-                    log("Failed to retrieve UsersRepository component:"
-                            + e.getMessage());
-                }
-            } else {
-                UsersStore usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
-                usersRepository = usersStore.getRepository(userRep);
-            }
-
-        } catch (ServiceException cnfe) {
-            log("Failed to retrieve UsersStore component:" + cnfe.getMessage());
+        String userRep = getInitParameter("usersRepository");
+        if (userRep != null && userRep.length() > 0) {
+            usersRepository = usersStore.getRepository(userRep);
         }
 
     }

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/VirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/VirtualUserTable.java?rev=883725&r1=883724&r2=883725&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/VirtualUserTable.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/mailets/VirtualUserTable.java
Tue Nov 24 15:11:14 2009
@@ -59,7 +59,7 @@
      * Sets the virtual user table.
      * @param vut the vut to set
      */
-    @Resource(name="defaultvirtualusertable")
+    @Resource(name="org.apache.james.api.vut.VirtualUserTable")
     public final void setVut(org.apache.james.api.vut.VirtualUserTable vut) {
         this.vut = vut;
     }
@@ -76,7 +76,7 @@
      * Sets the virtual table store.
      * @param vutStore the vutStore to set, possibly null
      */
-    @Resource(name="virtualusertable-store")
+    @Resource(name="org.apache.james.api.vut.VirtualUserTable")
     public final void setVutStore(VirtualUserTableStore vutStore) {
         this.vutStore = vutStore;
     }



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