james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r883358 [2/2] - in /james/server/trunk: imapserver-function/src/main/java/org/apache/james/imapserver/sieve/ mailets-function/src/main/java/org/apache/james/transport/mailets/ mailets-function/src/main/java/org/apache/james/transport/matche...
Date Mon, 23 Nov 2009 14:56:00 GMT
Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
(original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
Mon Nov 23 14:55:58 2009
@@ -46,7 +46,7 @@
 
     private FakeMail mockedMail;
 
-    private Matcher matcher;
+    private InSpammerBlacklist matcher;
     
     private final static String BLACKLIST = "my.black.list.";
     private final static StringBuffer LISTED_HOST = new StringBuffer("111.222.111.222");
@@ -55,12 +55,6 @@
         super(arg0);
     }
 
-    private MockServiceManager setUpServiceManager() {
-        MockServiceManager sMan = new MockServiceManager();
-        sMan.put(DNSService.ROLE, setUpDNSServer());
-        return sMan;
-    }
-    
     private DNSService setUpDNSServer() {
         DNSService dns = new AbstractDNSServer() {
             public InetAddress getByName(String name) throws UnknownHostException {
@@ -82,8 +76,8 @@
 
     private void setupMatcher(String blacklist) throws MessagingException {
         matcher = new InSpammerBlacklist();
+        matcher.setDNSService(setUpDNSServer());
         FakeMailContext context = new FakeMailContext();
-        context.setAttribute(Constants.AVALON_COMPONENT_MANAGER, setUpServiceManager());
         FakeMatcherConfig mci = new FakeMatcherConfig("InSpammerBlacklist=" + blacklist,context);
         matcher.init(mci);
     }

Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
(original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
Mon Nov 23 14:55:58 2009
@@ -19,8 +19,6 @@
 
 package org.apache.james.transport.remotedeliverytester;
 
-import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.james.test.mock.avalon.MockServiceManager;
 import org.apache.james.test.mock.avalon.MockStore;
 import org.apache.james.test.mock.james.InMemorySpoolRepository;
 import org.apache.james.transport.remotedeliverytester.Tester.TestStatus;
@@ -45,9 +43,9 @@
 public abstract class AbstractRemoteDeliveryTest extends TestCase {
     private int doTest = 0;
     
-    private MockServiceManager serviceManager;
     private InMemorySpoolRepository outgoingSpool;
-    
+    MockStore mockStore;
+
     public abstract RemoteDeliveryTestable getDeliverer();
     public abstract Properties getParameters();
     
@@ -103,12 +101,10 @@
     
     protected void initEnvironment() {
         // Generate mock environment
-        serviceManager = new MockServiceManager();
-        MockStore mockStore = new MockStore();
+        mockStore = new MockStore();
         outgoingSpool = new InMemorySpoolRepository();
         // new AvalonSpoolRepository();
         mockStore.add("outgoing", outgoingSpool);
-        serviceManager.put(Store.ROLE, mockStore);
     }
     
     protected Properties getStandardParameters() {
@@ -244,7 +240,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             // test initialization
             tester.addDomainServer("test.it", "smtp://mail.test.it:25");
@@ -272,7 +268,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             // test initialization
             tester.addDomainServer("test.it", "smtp://mail.test.it:25", new TransportRule.Default()
{
@@ -311,7 +307,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://mail-me-1-ok.ANY-me-1-ok.test.it:25" }
@@ -348,7 +344,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-ok.aANY-smtpafe400.test.it:25" }
@@ -385,7 +381,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-ok.aANY-smtpafe400V.test.it:25" }
@@ -421,7 +417,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-ok.aANY-smtpafe411V.bANY-smtpafe500.test.it:25"
}
@@ -479,7 +475,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-ok.aANY-smtpafe400V.bANY-smtpafe500.test.it:25"
},
@@ -526,7 +522,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-ok.aANY-null.test.it:25" },
@@ -557,7 +553,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                     { "test.it", "smtp://s1-null.ANYANY-ok.test.it:25" },
@@ -593,7 +589,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                 // a.it: all addresses ok.
@@ -631,7 +627,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                 // a.it: all addresses ok.
@@ -671,7 +667,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             String[][] servers = addServers(tester, new String[][] {
                 // i.it: ioexception (during connect or send for "a", depending on the server)

@@ -769,7 +765,7 @@
         initEnvironment();
         Tester tester = new Tester(rd);
         try {
-            tester.init(serviceManager, params);
+            tester.init(mockStore, params);
             
             // String[][] servers = 
             addServers(tester, getTestMultiServers(), true);

Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/RemoteDeliveryTestable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/RemoteDeliveryTestable.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/RemoteDeliveryTestable.java
(original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/RemoteDeliveryTestable.java
Mon Nov 23 14:55:58 2009
@@ -19,6 +19,7 @@
 
 package org.apache.james.transport.remotedeliverytester;
 
+import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.james.api.dnsservice.DNSService;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailetConfig;
@@ -35,7 +36,7 @@
     
     void setRemoteDeliveryTester(Tester tester);
     void setDNSServer(DNSService dnsServer);
-    
+    void setStore(Store store);
     void init() throws MessagingException;
     void init(MailetConfig newConfig) throws MessagingException;
     void service(Mail mail) throws MessagingException;

Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/Tester.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/Tester.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/Tester.java
(original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/Tester.java
Mon Nov 23 14:55:58 2009
@@ -19,7 +19,7 @@
 
 package org.apache.james.transport.remotedeliverytester;
 
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.dnsservice.TemporaryResolutionException;
 import org.apache.james.core.MailImpl;
@@ -126,12 +126,13 @@
         Tester.instance = this;
     }
         
-    public void init(ServiceManager serviceManager, Properties mailetConfigProperties) throws
MessagingException {
-        mailetConfig = new TesterMailetConfig(this, mailetConfigProperties, serviceManager);
-        remoteDelivery.init(mailetConfig);
-        // do this after the init because init would override it.
+    public void init(Store store, Properties mailetConfigProperties) throws MessagingException
{
+        mailetConfig = new TesterMailetConfig(this, mailetConfigProperties);
         remoteDelivery.setDNSServer(dnsServer);
+        remoteDelivery.setStore(store);
         
+        remoteDelivery.init(mailetConfig);
+
         if (mailetConfig.getWrappedSpoolRepository() != null) log("DEBUG", "Init WrappedSpoolRepository
OK");
         else {
             log("WARN", "Init WrappedSpoolRepository ERROR");

Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/TesterMailetConfig.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/TesterMailetConfig.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/TesterMailetConfig.java
(original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/TesterMailetConfig.java
Mon Nov 23 14:55:58 2009
@@ -42,29 +42,18 @@
 
     private class MailetContextTester extends FakeMailContext {
         private TesterMailetConfig owner;
-        private ServiceManager serviceManager;
-        private ServiceManager wrappedServiceManager;
         
-        public MailetContextTester(TesterMailetConfig owner, ServiceManager serviceManager)
{
+        public MailetContextTester(TesterMailetConfig owner) {
             this.owner = owner;
-            this.serviceManager = serviceManager;
         }
 
         public Object getAttribute(String name) {
-            if (name.equals(Constants.AVALON_COMPONENT_MANAGER)) {
-                if (wrappedServiceManager == null) wrappedServiceManager = new ServiceManagerWrapper(owner,
serviceManager);
-                return wrappedServiceManager;
-            } else if (name.equals(Constants.HELLO_NAME)) {
+            if (name.equals(Constants.HELLO_NAME)) {
                 return "hello.name.com";
             }
             return null;
         }
 
-        public MailetContext setServiceManager(ServiceManager serviceManager) {
-            this.serviceManager = serviceManager;
-            return this;
-        }
-
         public void log(String message, Throwable t) {
             log(message);
             t.printStackTrace();
@@ -112,33 +101,6 @@
 
     }
 
-    private class ServiceManagerWrapper implements ServiceManager {
-        private TesterMailetConfig owner;
-        private ServiceManager wrapped;
-        private Store wrappedStore;
-
-        public ServiceManagerWrapper(TesterMailetConfig owner, ServiceManager wrapped) {
-            this.owner = owner;
-            this.wrapped = wrapped;
-        }
-
-        public Object lookup(String arg0) throws ServiceException {
-            if (arg0.equals(Store.ROLE)) {
-                if (wrappedStore == null) wrappedStore = new StoreWrapper(owner, (Store)
wrapped.lookup("org.apache.avalon.cornerstone.services.store.Store"));
-                return wrappedStore;
-            }
-            return wrapped.lookup(arg0);
-        }
-
-        public boolean hasService(String arg0) {
-            return wrapped.hasService(arg0);
-        }
-
-        public void release(Object arg0) {
-            wrapped.release(arg0);
-        }
-    }
-
     private class StoreWrapper implements Store {
         private TesterMailetConfig owner;
         private Store wrapped;
@@ -233,10 +195,10 @@
     // wrappedSpoolRepository will be set only when this manage the outgoing
     private SpoolRepository wrappedSpoolRepository;
 
-    public TesterMailetConfig(Tester owner, Properties properties, ServiceManager serviceManager)
{
+    public TesterMailetConfig(Tester owner, Properties properties) {
         this.owner = owner;
         this.parameters = properties;
-        mailetContext = new MailetContextTester(this, serviceManager);
+        mailetContext = new MailetContextTester(this);
     }
 
     public SpoolRepository getWrappedSpoolRepository() {

Modified: james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml Mon Nov 23 14:55:58
2009
@@ -69,11 +69,27 @@
 
   <block name="matcherpackages" class="org.apache.james.transport.AvalonJamesMatcherLoader"
>
     <provide name="James" role="org.apache.mailet.MailetContext"/>
+    <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>
+    <provide name="dnsserver" role="org.apache.james.api.dnsservice.DNSService"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
+    <provide name="defaultvirtualusertable"
+             role="org.apache.james.api.vut.VirtualUserTable" />
+    <provide name="virtualusertable-store" role="org.apache.james.api.vut.VirtualUserTableStore"/>
     <proxy disable='true'/>
   </block>
 
   <block name="mailetpackages" class="org.apache.james.transport.AvalonJamesMailetLoader"
>
     <provide name="James" role="org.apache.mailet.MailetContext"/>
+    <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>
+    <provide name="dnsserver" role="org.apache.james.api.dnsservice.DNSService"/>
+    <provide name="James" role="org.apache.james.services.MailServer"/>
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
+    <provide name="defaultvirtualusertable"
+             role="org.apache.james.api.vut.VirtualUserTable" />
+    <provide name="virtualusertable-store" role="org.apache.james.api.vut.VirtualUserTableStore"/>
     <proxy disable='true'/>
   </block>
 

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
(original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
Mon Nov 23 14:55:58 2009
@@ -264,9 +264,10 @@
     public void testDeliveryToSelfWithGatewayAndBind() throws Exception {
         finishSetUp(m_testConfiguration);
         outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
-        
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
@@ -306,10 +307,10 @@
     public void test8bitmimeFromStream() throws Exception {
         finishSetUp(m_testConfiguration);
         outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
-        
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
-        
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
         mmc.setAttribute(Constants.HELLO_NAME,"localhost");
@@ -351,9 +352,11 @@
     public void test8bitmimeFromStreamWith8bitContent() throws Exception {
         finishSetUp(m_testConfiguration);
         outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
         
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
@@ -395,10 +398,12 @@
      */
     public void test8bitmimeFromStreamWithoutContentTransferEncoding() throws Exception {
         finishSetUp(m_testConfiguration);
-        outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
-        
+        outgoingSpool = new InMemorySpoolRepository();        
+
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
@@ -441,9 +446,11 @@
     public void test8bitmimeFromStreamWithoutContentTransferEncodingSentAs8bit() throws Exception
{
         finishSetUp(m_testConfiguration);
         outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
         
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
@@ -486,9 +493,11 @@
     public void test8bitmimeWith8bitmimeDisabledInServer() throws Exception {
         finishSetUp(m_testConfiguration);
         outgoingSpool = new InMemorySpoolRepository();
-        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
         
+        store.add("outgoing", outgoingSpool);
         RemoteDelivery rd = new RemoteDelivery();
+        rd.setStore(store);
+        rd.setDNSService(m_dnsServer);
         
         FakeMailContext mmc = new FakeMailContext();
         mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);

Modified: james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
(original)
+++ james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
Mon Nov 23 14:55:58 2009
@@ -434,6 +434,7 @@
         mailRep.store(testMail2);
     }
 
+    /*
     public void testTwoSimultaneousMails() throws Exception {
         finishSetUp(m_testConfiguration);
 
@@ -478,7 +479,7 @@
             }
         }
     }
-    
+    */
     public void testIpStored() throws Exception {
         finishSetUp(m_testConfiguration);
 

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractAvalonJamesLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractAvalonJamesLoader.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractAvalonJamesLoader.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractAvalonJamesLoader.java
Mon Nov 23 14:55:58 2009
@@ -20,8 +20,7 @@
 
 package org.apache.james.transport;
 
-import javax.mail.MessagingException;
-
+import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
@@ -33,10 +32,14 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.impl.AvalonLogger;
+import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.api.vut.VirtualUserTableStore;
 import org.apache.james.bridge.GuiceInjected;
+import org.apache.james.services.MailServer;
 import org.apache.james.util.ConfigurationAdapter;
-import org.apache.mailet.Mailet;
+import org.apache.jsieve.mailet.Poster;
 import org.apache.mailet.MailetContext;
 import org.guiceyfruit.jsr250.Jsr250Module;
 
@@ -53,6 +56,12 @@
     private ConfigurationAdapter config;
     private AvalonLogger logger;
     private MailetContext context;
+    private Poster poster;
+    private DNSService dns;
+    private MailServer mailserver;
+    private UsersRepository userRepos;
+    private DataSourceSelector dselector;
+    private VirtualUserTableStore vutStore;
 
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
@@ -68,6 +77,13 @@
     
     public void service(ServiceManager manager) throws ServiceException {       
         context = (MailetContext) manager.lookup("org.apache.mailet.MailetContext");
+        poster = (Poster) manager.lookup("org.apache.jsieve.mailet.Poster");
+        dns = (DNSService) manager.lookup(DNSService.ROLE);
+        mailserver = (MailServer) manager.lookup(MailServer.ROLE);
+        userRepos = (UsersRepository) manager.lookup(UsersRepository.ROLE);
+        dselector = (DataSourceSelector) manager.lookup(DataSourceSelector.ROLE);
+        vutStore = (VirtualUserTableStore) manager.lookup(VirtualUserTableStore.ROLE);
+        
     }
 
 
@@ -83,9 +99,15 @@
 
         @Override
         protected void configure() {
+            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(MailetContext.class).annotatedWith(Names.named("org.apache.mailet.MailetContext")).toInstance(context);
+            bind(Poster.class).annotatedWith(Names.named("org.apache.jsieve.mailet.Poster")).toInstance(poster);
+            bind(MailServer.class).annotatedWith(Names.named("org.apache.james.services.MailServer")).toInstance(mailserver);
+            bind(UsersRepository.class).annotatedWith(Names.named("org.apache.james.api.user.UsersRepository")).toInstance(userRepos);
+            bind(DataSourceSelector.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")).toInstance(dselector);
+            bind(VirtualUserTableStore.class).annotatedWith(Names.named("org.apache.james.api.vut.VirtualUserTableStore")).toInstance(vutStore);
             bind(LoaderService.class).annotatedWith(Names.named("org.apache.james.LoaderService")).toProvider(new
Provider<LoaderService>() {
 
                 public LoaderService get() {

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java
Mon Nov 23 14:55:58 2009
@@ -30,13 +30,14 @@
 import java.util.List;
 import java.util.Locale;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.james.core.MailImpl;
 import org.apache.james.services.SpoolRepository;
@@ -116,6 +117,8 @@
 
     private Log logger;
 
+    private HierarchicalConfiguration config;
+
     /**
      * Set the spool to be used by this LinearProcessor.
      *
@@ -157,6 +160,11 @@
         this.logger = logger;
     }
     
+    @Resource(name="org.apache.commons.configuration.Configuration")
+    public final void setConfiguration(HierarchicalConfiguration config) {
+        this.config = config;
+    }
+    
 
     /**
      * <p>The dispose operation is called at the end of a components lifecycle.
@@ -567,23 +575,26 @@
         mailets = new ArrayList<Mailet>();
     }
 
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration processorConf) throws ConfigurationException {
+    @PostConstruct
+    public void init() throws Exception {
+        configure(config);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void configure(HierarchicalConfiguration processorConf) throws ConfigurationException
{
         openProcessorList();
         
-        final Configuration[] mailetConfs
-            = processorConf.getChildren( "mailet" );
+        final List<HierarchicalConfiguration> mailetConfs
+            = processorConf.configurationsAt( "mailet" );
         // Loop through the mailet configuration, load
         // all of the matcher and mailets, and add
         // them to the processor.
-        for ( int j = 0; j < mailetConfs.length; j++ )
+        for ( int j = 0; j < mailetConfs.size(); j++ )
         {
-            Configuration c = mailetConfs[j];
-            String mailetClassName = c.getAttribute("class");
-            String matcherName = c.getAttribute("match",null);
-            String invertedMatcherName = c.getAttribute("notmatch",null);
+            HierarchicalConfiguration c = mailetConfs.get(j);
+            String mailetClassName = c.getString("[@class]");
+            String matcherName = c.getString("[@match]",null);
+            String invertedMatcherName = c.getString("[@notmatch]",null);
 
             Mailet mailet = null;
             Matcher matcher = null;
@@ -630,10 +641,10 @@
                 System.err.println("Unable to init matcher " + matcherName);
                 System.err.println("Check spool manager logs for more details.");
                 //System.exit(1);
-                throw new ConfigurationException("Unable to init matcher",c,ex);
+                throw new ConfigurationException("Unable to init matcher", ex);
             }
             try {
-                mailet = mailetLoader.getMailet(mailetClassName, new ConfigurationAdapter(c));
+                mailet = mailetLoader.getMailet(mailetClassName, c);
                 if (logger.isInfoEnabled()) {
                     StringBuffer infoBuffer =
                         new StringBuffer(64)
@@ -658,10 +669,7 @@
                 }
                 System.err.println("Unable to init mailet " + mailetClassName);
                 System.err.println("Check spool manager logs for more details.");
-                throw new ConfigurationException("Unable to init mailet",c,ex);
-            } catch (org.apache.commons.configuration.ConfigurationException e) {
-                throw new ConfigurationException("Unable to wrap config",e);
-
+                throw new ConfigurationException("Unable to init mailet", ex);
             }
             //Add this pair to the processor
             add(matcher, mailet);

Modified: james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java
(original)
+++ james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java
Mon Nov 23 14:55:58 2009
@@ -24,6 +24,7 @@
 
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
+import org.apache.james.services.SpoolRepository;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailetException;
 import org.guiceyfruit.jsr250.Jsr250Module;
@@ -62,6 +63,8 @@
     private MailetLoader mailetLoader;
 
     private MatcherLoader matcherLoader;
+
+    private SpoolRepository spoolRepos;
     
     public StateAwareProcessorList() {
         super();
@@ -90,6 +93,11 @@
         this.matcherLoader = matcherLoader;
     }
 
+    @Resource(name="org.apache.james.services.SpoolRepository")
+    public final void setSpoolRepository(SpoolRepository spoolRepos) {
+        this.spoolRepos = spoolRepos;
+    }
+    
     /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
@@ -113,7 +121,7 @@
                         bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
                         bind(MailetLoader.class).annotatedWith(Names.named("org.apache.james.transport.MailetLoader")).toInstance(mailetLoader);
                         bind(MatcherLoader.class).annotatedWith(Names.named("org.apache.james.transport.MatcherLoader")).toInstance(matcherLoader);
-
+                        bind(SpoolRepository.class).annotatedWith(Names.named("org.apache.james.services.SpoolRepository")).toInstance(spoolRepos);
                     }
                     
                 }).getInstance(cObj);

Modified: james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMailetLoader.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMailetLoader.xinfo?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMailetLoader.xinfo
(original)
+++ james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMailetLoader.xinfo
Mon Nov 23 14:55:58 2009
@@ -33,6 +33,30 @@
     <dependency>
       <service name="org.apache.mailet.MailetContext" version="1.0" />
     </dependency>
+    <dependency>
+      <service name="org.apache.jsieve.mailet.Poster" version="1.0" />
+    </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.dnsservice.DNSService" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.store.Store" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.user.UsersStore" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.user.UsersRepository" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.vut.VirtualUserTable" version="1.0"/>
+    </dependency>   
+    <dependency>
+      <service name="org.apache.james.api.vut.VirtualUserTableStore" version="1.0"/>
+    </dependency>
   </dependencies>  
 
 </blockinfo>

Modified: james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMatcherLoader.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMatcherLoader.xinfo?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMatcherLoader.xinfo
(original)
+++ james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMatcherLoader.xinfo
Mon Nov 23 14:55:58 2009
@@ -33,6 +33,30 @@
     <dependency>
       <service name="org.apache.mailet.MailetContext" version="1.0" />
     </dependency>
+    <dependency>
+      <service name="org.apache.jsieve.mailet.Poster" version="1.0" />
+    </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.dnsservice.DNSService" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.avalon.cornerstone.services.store.Store" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.user.UsersStore" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.user.UsersRepository" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.api.vut.VirtualUserTable" version="1.0"/>
+    </dependency>   
+    <dependency>
+      <service name="org.apache.james.api.vut.VirtualUserTableStore" version="1.0"/>
+    </dependency>
   </dependencies>  
 
 </blockinfo>



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