Author: bago
Date: Sat May 6 09:07:56 2006
New Revision: 400328
URL: http://svn.apache.org/viewcvs?rev=400328&view=rev
Log:
Moved common code from server components to the AbstractJamesService
(inizialize() and 3 fields)
Modified:
james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java
james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java
james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
Modified:
james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java?rev=400328&r1=400327&r2=400328&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
(original)
+++ james/server/trunk/src/java/org/apache/james/core/AbstractJamesService.java
Sat May 6 09:07:56 2006
@@ -17,6 +17,10 @@
package org.apache.james.core;
+import org.apache.avalon.excalibur.pool.DefaultPool;
+import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
+import org.apache.avalon.excalibur.pool.ObjectFactory;
+import org.apache.avalon.excalibur.pool.Pool;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
@@ -158,6 +162,22 @@
*/
private boolean m_disposed = false;
+
+ /**
+ * The pool used to provide POP3 Handler objects
+ */
+ protected Pool theHandlerPool = null;
+
+ /**
+ * The factory used to provide Handler objects
+ */
+ protected ObjectFactory theHandlerFactory = null;
+
+ /**
+ * The factory used to generate Watchdog objects
+ */
+ protected WatchdogFactory theWatchdogFactory = null;
+
/**
* @see
org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
*/
@@ -374,6 +394,23 @@
String logString = logBuffer.toString();
System.out.println(logString);
getLogger().info(logString);
+
+ if (connectionLimit != null) {
+ theHandlerPool = new HardResourceLimitingPool(theHandlerFactory,
5, connectionLimit.intValue());
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Using a bounded pool for
"+getServiceType()+" handlers with upper limit " + connectionLimit.intValue());
+ }
+ } else {
+ // NOTE: The maximum here is not a real maximum. The handler pool
will continue to
+ // provide handlers beyond this value.
+ theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
+ getLogger().debug("Using an unbounded pool for
"+getServiceType()+" handlers.");
+ }
+ ContainerUtil.enableLogging(theHandlerPool, getLogger());
+ ContainerUtil.initialize(theHandlerPool);
+
+ theWatchdogFactory = getWatchdogFactory();
+
}
/**
Modified:
james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java?rev=400328&r1=400327&r2=400328&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java
(original)
+++ james/server/trunk/src/java/org/apache/james/nntpserver/NNTPServer.java Sat
May 6 09:07:56 2006
@@ -18,21 +18,16 @@
package org.apache.james.nntpserver;
import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.DefaultPool;
-import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
import org.apache.avalon.excalibur.pool.ObjectFactory;
-import org.apache.avalon.excalibur.pool.Pool;
import org.apache.avalon.excalibur.pool.Poolable;
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.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.james.core.AbstractJamesService;
import org.apache.james.nntpserver.repository.NNTPRepository;
import org.apache.james.services.UsersRepository;
import org.apache.james.util.watchdog.Watchdog;
-import org.apache.james.util.watchdog.WatchdogFactory;
/**
* NNTP Server
@@ -56,21 +51,6 @@
private UsersRepository userRepository = null;
/**
- * The pool used to provide NNTP Handler objects
- */
- private Pool theHandlerPool = null;
-
- /**
- * The pool used to provide NNTP Handler objects
- */
- private ObjectFactory theHandlerFactory = new NNTPHandlerFactory();
-
- /**
- * The factory used to generate Watchdog objects
- */
- private WatchdogFactory theWatchdogFactory;
-
- /**
* The configuration data to be passed to the handler
*/
private NNTPHandlerConfigurationData theConfigData
@@ -106,30 +86,7 @@
}
}
}
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize() throws Exception {
- super.initialize();
- if (!isEnabled()) {
- return;
- }
-
- if (connectionLimit != null) {
- theHandlerPool = new HardResourceLimitingPool(theHandlerFactory,
5, connectionLimit.intValue());
- getLogger().debug("Using a bounded pool for NNTP handlers with
upper limit " + connectionLimit.intValue());
- } else {
- // NOTE: The maximum here is not a real maximum. The handler pool
will continue to
- // provide handlers beyond this value.
- theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
- getLogger().debug("Using an unbounded pool for NNTP handlers.");
- }
- ContainerUtil.enableLogging(theHandlerPool, getLogger());
- ContainerUtil.initialize(theHandlerPool);
-
- theWatchdogFactory = getWatchdogFactory();
+ theHandlerFactory = new NNTPHandlerFactory();
}
/**
Modified:
james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java?rev=400328&r1=400327&r2=400328&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java
(original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/POP3Server.java Sat
May 6 09:07:56 2006
@@ -18,21 +18,16 @@
package org.apache.james.pop3server;
import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.DefaultPool;
-import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
import org.apache.avalon.excalibur.pool.ObjectFactory;
-import org.apache.avalon.excalibur.pool.Pool;
import org.apache.avalon.excalibur.pool.Poolable;
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.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.james.core.AbstractJamesService;
import org.apache.james.services.MailServer;
import org.apache.james.services.UsersRepository;
import org.apache.james.util.watchdog.Watchdog;
-import org.apache.james.util.watchdog.WatchdogFactory;
/**
* <p>Accepts POP3 connections on a server socket and dispatches them to
POP3Handlers.</p>
@@ -61,21 +56,6 @@
private int lengthReset = 20 * 1024;
/**
- * The pool used to provide POP3 Handler objects
- */
- private Pool theHandlerPool = null;
-
- /**
- * The factory used to provide POP3 Handler objects
- */
- private ObjectFactory theHandlerFactory = new POP3HandlerFactory();
-
- /**
- * The factory used to generate Watchdog objects
- */
- private WatchdogFactory theWatchdogFactory;
-
- /**
* The configuration data to be passed to the handler
*/
private POP3HandlerConfigurationData theConfigData
@@ -103,30 +83,7 @@
getLogger().info("The idle timeout will be reset every " +
lengthReset + " bytes.");
}
}
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize() throws Exception {
- super.initialize();
- if (!isEnabled()) {
- return;
- }
-
- if (connectionLimit != null) {
- theHandlerPool = new HardResourceLimitingPool(theHandlerFactory,
5, connectionLimit.intValue());
- getLogger().debug("Using a bounded pool for POP3 handlers with
upper limit " + connectionLimit.intValue());
- } else {
- // NOTE: The maximum here is not a real maximum. The handler pool
will continue to
- // provide handlers beyond this value.
- theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
- getLogger().debug("Using an unbounded pool for POP3 handlers.");
- }
- ContainerUtil.enableLogging(theHandlerPool, getLogger());
- ContainerUtil.initialize(theHandlerPool);
-
- theWatchdogFactory = getWatchdogFactory();
+ theHandlerFactory = new POP3HandlerFactory();
}
/**
Modified:
james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java?rev=400328&r1=400327&r2=400328&view=diff
==============================================================================
---
james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
(original)
+++
james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
Sat May 6 09:07:56 2006
@@ -18,10 +18,7 @@
package org.apache.james.remotemanager;
import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.DefaultPool;
-import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
import org.apache.avalon.excalibur.pool.ObjectFactory;
-import org.apache.avalon.excalibur.pool.Pool;
import org.apache.avalon.excalibur.pool.Poolable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -33,7 +30,6 @@
import org.apache.james.services.UsersRepository;
import org.apache.james.services.UsersStore;
import org.apache.james.util.watchdog.Watchdog;
-import org.apache.james.util.watchdog.WatchdogFactory;
import java.util.HashMap;
@@ -74,21 +70,6 @@
private MailServer mailServer;
/**
- * The pool used to provide RemoteManager Handler objects
- */
- private Pool theHandlerPool = null;
-
- /**
- * The pool used to provide RemoteManager Handler objects
- */
- private ObjectFactory theHandlerFactory = new
RemoteManagerHandlerFactory();
-
- /**
- * The factory used to generate Watchdog objects
- */
- private WatchdogFactory theWatchdogFactory;
-
- /**
* The configuration data to be passed to the handler
*/
private RemoteManagerHandlerConfigurationData theConfigData
@@ -130,30 +111,7 @@
if (prompt == null) prompt = "";
else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += "
";
}
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize() throws Exception {
- super.initialize();
- if (!isEnabled()) {
- return;
- }
-
- if (connectionLimit != null) {
- theHandlerPool = new HardResourceLimitingPool(theHandlerFactory,
5, connectionLimit.intValue());
- getLogger().debug("Using a bounded pool for RemoteManager handlers
with upper limit " + connectionLimit.intValue());
- } else {
- // NOTE: The maximum here is not a real maximum. The handler pool
will continue to
- // provide handlers beyond this value.
- theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
- getLogger().debug("Using an unbounded pool for RemoteManager
handlers.");
- }
- ContainerUtil.enableLogging(theHandlerPool, getLogger());
- ContainerUtil.initialize(theHandlerPool);
-
- theWatchdogFactory = getWatchdogFactory();
+ theHandlerFactory = new RemoteManagerHandlerFactory();
}
/**
Modified:
james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java?rev=400328&r1=400327&r2=400328&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
(original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java Sat
May 6 09:07:56 2006
@@ -18,10 +18,7 @@
package org.apache.james.smtpserver;
import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
-import org.apache.avalon.excalibur.pool.DefaultPool;
-import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
import org.apache.avalon.excalibur.pool.ObjectFactory;
-import org.apache.avalon.excalibur.pool.Pool;
import org.apache.avalon.excalibur.pool.Poolable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -34,7 +31,6 @@
import org.apache.james.services.UsersRepository;
import org.apache.james.util.NetMatcher;
import org.apache.james.util.watchdog.Watchdog;
-import org.apache.james.util.watchdog.WatchdogFactory;
import org.apache.mailet.MailetContext;
/**
@@ -115,21 +111,6 @@
private int lengthReset = 20 * 1024;
/**
- * The pool used to provide SMTP Handler objects
- */
- private Pool theHandlerPool = null;
-
- /**
- * The pool used to provide SMTP Handler objects
- */
- private ObjectFactory theHandlerFactory = new SMTPHandlerFactory();
-
- /**
- * The factory used to generate Watchdog objects
- */
- private WatchdogFactory theWatchdogFactory;
-
- /**
* The configuration data to be passed to the handler
*/
private SMTPHandlerConfigurationData theConfigData
@@ -243,32 +224,7 @@
} else {
mailetcontext.setAttribute(Constants.HELLO_NAME, "localhost");
}
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Initializable#initialize()
- */
- public void initialize() throws Exception {
- super.initialize();
- if (!isEnabled()) {
- return;
- }
-
- if (connectionLimit != null) {
- theHandlerPool = new HardResourceLimitingPool(theHandlerFactory,
5, connectionLimit.intValue());
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Using a bounded pool for SMTP handlers with
upper limit " + connectionLimit.intValue());
- }
- } else {
- // NOTE: The maximum here is not a real maximum. The handler pool
will continue to
- // provide handlers beyond this value.
- theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
- getLogger().debug("Using an unbounded pool for SMTP handlers.");
- }
- ContainerUtil.enableLogging(theHandlerPool, getLogger());
- ContainerUtil.initialize(theHandlerPool);
-
- theWatchdogFactory = getWatchdogFactory();
+ theHandlerFactory = new SMTPHandlerFactory();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]