org.apache.james.core
Class AbstractJamesService

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
              |
              +--org.apache.james.core.AbstractJamesService
All Implemented Interfaces:
Component, Composable, Configurable, ConnectionHandlerFactory, Contextualizable, Disposable, Initializable, LogEnabled
Direct Known Subclasses:
NNTPServer, POP3Server, RemoteManager, SMTPServer

public abstract class AbstractJamesService
extends AbstractHandlerFactory
implements Component, Composable, Configurable, Disposable, Initializable, ConnectionHandlerFactory

Server which creates connection handlers. All new James service must inherit from this abstract implementation.

Author:
Andrei Ivanov, Peter M. Goldstein

Field Summary
protected  InetAddress bindTo
          Network interface to which the service will bind.
protected  Integer connectionLimit
          The maximum number of connections allowed for this service.
protected  String connectionName
          The name of the connection used by this service.
protected static int DEFAULT_TIMEOUT
          The default value for the connection timeout.
static String HELLO_NAME
          The name of the parameter defining the service hello name.
protected  String helloName
          The hello name for the service.
protected  int port
          The port on which this service will be made available.
protected  ServerSocket serverSocket
           
protected  String serverSocketType
          The server socket type used to generate connections for this server.
protected  String threadGroup
          The name of the thread group to be used by this service for generating connections
protected  org.apache.avalon.excalibur.thread.ThreadPool threadPool
          The thread pool used by this service that holds the threads that service the client connections.
protected  int timeout
          The connection idle timeout.
protected static String TIMEOUT_NAME
          The name of the parameter defining the connection timeout.
 
Fields inherited from class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
m_componentManager, m_configuration, m_context
 
Constructor Summary
AbstractJamesService()
           
 
Method Summary
 void compose(ComponentManager comp)
           
 void configure(Configuration conf)
           
 void dispose()
           
protected  int getDefaultPort()
          Get the default port for this server type.
 String getServiceType()
          This method returns the type of service provided by this server.
protected  WatchdogFactory getWatchdogFactory()
          This constructs the WatchdogFactory that will be used to guard against runaway or stuck behavior.
 void initialize()
           
protected  boolean isDefaultTLSEnabled()
          Get whether TLS is enabled for this server's socket by default.
protected  boolean isEnabled()
          Describes whether this service is enabled by configuration.
protected abstract  ConnectionHandler newHandler()
          Overide this method to create actual instance of connection handler.
 
Methods inherited from class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
contextualize, createConnectionHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory
createConnectionHandler, releaseConnectionHandler
 

Field Detail

DEFAULT_TIMEOUT

protected static final int DEFAULT_TIMEOUT
The default value for the connection timeout.

See Also:
Constant Field Values

TIMEOUT_NAME

protected static final String TIMEOUT_NAME
The name of the parameter defining the connection timeout.

See Also:
Constant Field Values

HELLO_NAME

public static final String HELLO_NAME
The name of the parameter defining the service hello name.

See Also:
Constant Field Values

threadGroup

protected String threadGroup
The name of the thread group to be used by this service for generating connections


threadPool

protected org.apache.avalon.excalibur.thread.ThreadPool threadPool
The thread pool used by this service that holds the threads that service the client connections.


serverSocketType

protected String serverSocketType
The server socket type used to generate connections for this server.


port

protected int port
The port on which this service will be made available.


bindTo

protected InetAddress bindTo
Network interface to which the service will bind. If not set, the server binds to all available interfaces.


serverSocket

protected ServerSocket serverSocket

connectionName

protected String connectionName
The name of the connection used by this service. We need to track this so we can tell the ConnectionManager which service to disconnect upon shutdown.


connectionLimit

protected Integer connectionLimit
The maximum number of connections allowed for this service.


timeout

protected int timeout
The connection idle timeout. Used primarily to prevent server problems from hanging a connection.


helloName

protected String helloName
The hello name for the service.

Constructor Detail

AbstractJamesService

public AbstractJamesService()
Method Detail

compose

public void compose(ComponentManager comp)
             throws ComponentException
Specified by:
compose in interface Composable
Overrides:
compose in class AbstractHandlerFactory
ComponentException
See Also:
Composable.compose(ComponentManager)

configure

public void configure(Configuration conf)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractHandlerFactory
ConfigurationException
See Also:
Configurable.configure(Configuration)

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Exception
See Also:
Initializable.initialize()

dispose

public void dispose()
Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

getWatchdogFactory

protected WatchdogFactory getWatchdogFactory()
This constructs the WatchdogFactory that will be used to guard against runaway or stuck behavior. Should only be called once by a subclass in its initialize() method.

Returns:
the WatchdogFactory to be employed by subclasses.

isEnabled

protected final boolean isEnabled()
Describes whether this service is enabled by configuration.

Returns:
is the service enabled.

newHandler

protected abstract ConnectionHandler newHandler()
                                         throws Exception
Overide this method to create actual instance of connection handler.

Specified by:
newHandler in class AbstractHandlerFactory
Returns:
the new ConnectionHandler
Throws:
Exception - if an error occurs

getDefaultPort

protected int getDefaultPort()
Get the default port for this server type. It is strongly recommended that subclasses of this class override this method to specify the default port for their specific server type.

Returns:
the default port

isDefaultTLSEnabled

protected boolean isDefaultTLSEnabled()
Get whether TLS is enabled for this server's socket by default.

Returns:
the default port

getServiceType

public String getServiceType()
This method returns the type of service provided by this server. This should be invariant over the life of the class. Subclasses may override this implementation. This implementation parses the complete class name and returns the undecorated class name.

Returns:
description of this server


"Copyright © 1999-2002 Apache Jakarta Project. All Rights Reserved."