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 rd...@apache.org on 2009/08/11 22:55:54 UTC
svn commit: r803293 - in
/james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket:
AbstractJamesService.java DelegatingJamesHandler.java
Author: rdonkin
Date: Tue Aug 11 20:55:53 2009
New Revision: 803293
URL: http://svn.apache.org/viewvc?rev=803293&view=rev
Log:
Inject dependency
Modified:
james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/DelegatingJamesHandler.java
Modified: james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java?rev=803293&r1=803292&r2=803293&view=diff
==============================================================================
--- james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java (original)
+++ james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesService.java Tue Aug 11 20:55:53 2009
@@ -796,7 +796,7 @@
* @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
*/
public Object newInstance() throws Exception {
- final DelegatingJamesHandler delegatingJamesHandler = new DelegatingJamesHandler(newProtocolHandlerInstance());
+ final DelegatingJamesHandler delegatingJamesHandler = new DelegatingJamesHandler(newProtocolHandlerInstance(), dnsServer);
delegatingJamesHandler.setName("Handler-" + handlerCount.getAndAdd(1));
return delegatingJamesHandler;
}
Modified: james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/DelegatingJamesHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/DelegatingJamesHandler.java?rev=803293&r1=803292&r2=803293&view=diff
==============================================================================
--- james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/DelegatingJamesHandler.java (original)
+++ james/server/sandbox/container/avalon-socket-library/src/main/java/org/apache/james/socket/DelegatingJamesHandler.java Tue Aug 11 20:55:53 2009
@@ -19,19 +19,6 @@
package org.apache.james.socket;
-import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.Poolable;
-import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-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.api.dnsservice.DNSService;
-import org.apache.james.util.InternetPrintWriter;
-import org.apache.james.util.watchdog.Watchdog;
-import org.apache.james.util.watchdog.WatchdogTarget;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -44,20 +31,21 @@
import java.net.Socket;
import java.net.SocketException;
+import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
+import org.apache.avalon.excalibur.pool.Poolable;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.util.InternetPrintWriter;
+import org.apache.james.util.watchdog.Watchdog;
+import org.apache.james.util.watchdog.WatchdogTarget;
+
/**
* Common Handler code
*/
-public class DelegatingJamesHandler extends AbstractLogEnabled implements ProtocolHandlerHelper, ConnectionHandler, Poolable,Serviceable {
-
- protected ProtocolHandler protocolHandler;
-
-
- public DelegatingJamesHandler(ProtocolHandler delegated) {
- this.protocolHandler = delegated;
- this.protocolHandler.setProtocolHandlerHelper(this);
- }
-
-
+public class DelegatingJamesHandler extends AbstractLogEnabled implements ProtocolHandlerHelper, ConnectionHandler, Poolable {
+
private static final int DEFAULT_OUTPUT_BUFFER_SIZE = 1024;
private static final int DEFAULT_INPUT_BUFFER_SIZE = 1024;
@@ -74,37 +62,37 @@
* The TCP/IP socket over which the service interaction
* is occurring
*/
- protected Socket socket;
+ private Socket socket;
/**
* The writer to which outgoing messages are written.
*/
- protected PrintWriter out;
+ private PrintWriter out;
/**
* The incoming stream of bytes coming from the socket.
*/
- protected InputStream in;
+ private InputStream in;
/**
* The reader associated with incoming characters.
*/
- protected CRLFTerminatedReader inReader;
+ private CRLFTerminatedReader inReader;
/**
* The socket's output stream
*/
- protected OutputStream outs;
+ private OutputStream outs;
/**
* The watchdog being used by this handler to deal with idle timeouts.
*/
- protected Watchdog theWatchdog;
+ private Watchdog theWatchdog;
/**
* The watchdog target that idles out this handler.
*/
- private WatchdogTarget theWatchdogTarget = new JamesWatchdogTarget();
+ private final WatchdogTarget theWatchdogTarget = new JamesWatchdogTarget();
/**
* The remote host name obtained by lookup on the socket.
@@ -117,11 +105,6 @@
private String remoteIP = null;
/**
- * The DNSService
- */
- private DNSService dnsServer = null;
-
- /**
* Used for debug: if not null enable tcp stream dump.
*/
private String tcplogprefix = null;
@@ -134,10 +117,16 @@
/**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ * The DNSService
*/
- public void service(ServiceManager arg0) throws ServiceException {
- setDnsServer((DNSService) arg0.lookup(DNSService.ROLE));
+ private final DNSService dnsServer;
+
+ private final ProtocolHandler protocolHandler;
+
+ public DelegatingJamesHandler(final ProtocolHandler delegated, final DNSService dnsServer) {
+ this.protocolHandler = delegated;
+ this.dnsServer = dnsServer;
+ this.protocolHandler.setProtocolHandlerHelper(this);
}
/**
@@ -441,10 +430,6 @@
}
}
- public void setDnsServer(DNSService dnsServer) {
- this.dnsServer = dnsServer;
- }
-
/**
* The name of this handler.
* Used for context sensitive logging.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org