Author: rdonkin
Date: Sat Sep 5 07:11:11 2009
New Revision: 811594
URL: http://svn.apache.org/viewvc?rev=811594&view=rev
Log:
Use loader to construct handler chain. This will allow dependencies to be
injected.
Added:
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
(with props)
Modified:
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
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=811594&r1=811593&r2=811594&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
Sat Sep 5 07:11:11 2009
@@ -179,6 +179,7 @@
ContainerUtil.enableLogging(m_smtpServer,new MockLogger());
m_serviceManager = setUpServiceManager();
ContainerUtil.service(m_smtpServer, m_serviceManager);
+ m_smtpServer.setLoader(new FakeLoader());
m_testConfiguration = new SMTPTestConfiguration(m_smtpListenerPort);
}
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java?rev=811594&r1=811593&r2=811594&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
Sat Sep 5 07:11:11 2009
@@ -55,8 +55,9 @@
/**
* The handler chain - SMTPhandlers can lookup handlerchain to obtain
* Command handlers , Message handlers and connection handlers
+ * Constructed during initialisation to allow dependency injection.
*/
- private SMTPHandlerChain handlerChain = new SMTPHandlerChain();
+ private SMTPHandlerChain handlerChain;
/**
* The mailet context - we access it here to set the hello name for the
Mailet API
@@ -250,6 +251,8 @@
}
private void prepareHandlerChain() throws ConfigurationException {
+ handlerChain = loader.load(SMTPHandlerChain.class);
+
//set the logger
ContainerUtil.enableLogging(handlerChain,getLogger());
Added:
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java?rev=811594&view=auto
==============================================================================
---
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
(added)
+++
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
Sat Sep 5 07:11:11 2009
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.smtpserver;
+
+import org.apache.james.api.kernel.LoaderService;
+
+public class FakeLoader implements LoaderService {
+
+ public <T> T load(Class<T> type) {
+ try {
+ return type.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Propchange:
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=811594&r1=811593&r2=811594&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
(original)
+++
james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
Sat Sep 5 07:11:11 2009
@@ -181,6 +181,7 @@
ContainerUtil.enableLogging(m_smtpServer,new MockLogger());
m_serviceManager = setUpServiceManager();
ContainerUtil.service(m_smtpServer, m_serviceManager);
+ m_smtpServer.setLoader(new FakeLoader());
m_testConfiguration = new SMTPTestConfiguration(m_smtpListenerPort);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]