org.apache.james.core
Class AbstractJamesService

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
          extended by org.apache.james.core.AbstractJamesService
All Implemented Interfaces:
org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable
Direct Known Subclasses:
NNTPServer, POP3Server, RemoteManager, SMTPServer

public abstract class AbstractJamesService
extends org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
implements org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory

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


Field Summary
protected  int backlog
          The connection backlog.
protected static java.lang.String BACKLOG_NAME
          The name of the parameter defining the connection backlog.
protected  java.net.InetAddress bindTo
          Network interface to which the service will bind.
protected  java.lang.Integer connectionLimit
          The maximum number of connections allowed for this service.
protected  java.lang.String connectionName
          The name of the connection used by this service.
protected static int DEFAULT_BACKLOG
          The default value for the connection backlog.
protected static int DEFAULT_TIMEOUT
          The default value for the connection timeout.
static java.lang.String HELLO_NAME
          The name of the parameter defining the service hello name.
protected  java.lang.String helloName
          The hello name for the service.
protected  int port
          The port on which this service will be made available.
protected  java.net.ServerSocket serverSocket
           
protected  java.lang.String serverSocketType
          The server socket type used to generate connections for this server.
protected  java.lang.String threadGroup
          The name of the thread group to be used by this service for generating connections
protected  org.apache.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 java.lang.String TIMEOUT_NAME
          The name of the parameter defining the connection timeout.
 
Constructor Summary
AbstractJamesService()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
           
 void dispose()
           
protected  int getDefaultPort()
          Get the default port for this server type.
 java.lang.String getNetworkInterface()
          Returns the address if the network interface the socket is bound to
 int getPort()
          Returns the port that the service is bound to
 java.lang.String getServiceType()
          This method returns the type of service provided by this server.
 java.lang.String getSocketType()
          Returns the server socket type, plain or SSL
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.
 boolean isEnabled()
          Describes whether this service is enabled by configuration.
protected abstract  org.apache.avalon.cornerstone.services.connection.ConnectionHandler newHandler()
          Overide this method to create actual instance of connection handler.
 void service(org.apache.avalon.framework.service.ServiceManager comp)
           
 
Methods inherited from class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
contextualize, createConnectionHandler, releaseConnectionHandler
 
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 java.lang.String TIMEOUT_NAME
The name of the parameter defining the connection timeout.

See Also:
Constant Field Values

DEFAULT_BACKLOG

protected static final int DEFAULT_BACKLOG
The default value for the connection backlog.

See Also:
Constant Field Values

BACKLOG_NAME

protected static final java.lang.String BACKLOG_NAME
The name of the parameter defining the connection backlog.

See Also:
Constant Field Values

HELLO_NAME

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

See Also:
Constant Field Values

threadGroup

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


threadPool

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


serverSocketType

protected java.lang.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 java.net.InetAddress bindTo
Network interface to which the service will bind. If not set, the server binds to all available interfaces.


serverSocket

protected java.net.ServerSocket serverSocket

connectionName

protected java.lang.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 java.lang.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.


backlog

protected int backlog
The connection backlog.


helloName

protected java.lang.String helloName
The hello name for the service.

Constructor Detail

AbstractJamesService

public AbstractJamesService()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager comp)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Overrides:
service in class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(ServiceManager)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(Configuration)

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception
See Also:
Initializable.initialize()

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.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

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

Returns:
is the service enabled.

newHandler

protected abstract org.apache.avalon.cornerstone.services.connection.ConnectionHandler newHandler()
                                                                                           throws java.lang.Exception
Overide this method to create actual instance of connection handler.

Specified by:
newHandler in class org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory
Returns:
the new ConnectionHandler
Throws:
java.lang.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 java.lang.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

getPort

public int getPort()
Returns the port that the service is bound to

Returns:
int The port number

getNetworkInterface

public java.lang.String getNetworkInterface()
Returns the address if the network interface the socket is bound to

Returns:
String The network interface name

getSocketType

public java.lang.String getSocketType()
Returns the server socket type, plain or SSL

Returns:
String The scoekt type, plain or SSL


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.