org.norther.tammi.spray.connector
Class DefaultConnector

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.spray.connector.DefaultConnector
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, Startable, Connector
Direct Known Subclasses:
DefaultExecutableConnector, DefaultServletConnector

public class DefaultConnector
extends Adaptee
implements Connector

A default implementation of Connector. The start and stop methods must be implemented by subclasses.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
protected static InetAddress LOCALHOST
          The default local host.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
  DefaultConnector()
          Constructs a new connector.
protected DefaultConnector(InetAddress addr)
          Constructs a connector with a host address.
 
Method Summary
 String getAddress()
          Gets the address of the server of the connection.
 int getConnectionCount()
          Gets a snapshot of the number of active and idle connections.
 int getConnectionTimeout()
          Gets the timeout to wait for a request from an idle connection.
protected  MBeanReference getFilterMBean()
          Gets a reference to the filter MBean.
 ObjectName getFilterName()
          Gets the filter processing the requests.
protected  InetAddress getInetAddress()
          Gets the inet address of the local host if set.
 String getKeyAlias()
          Gets the certificate key alias of the connection.
protected  MBeanReference getLoggerMBean()
          Gets a reference to the logger MBean.
 ObjectName getLoggerName()
          Gets the the access logger of this connector.
 int getMaxIdleConnections()
          Gets the maximum number of idle connections to keep alive.
 String getName()
          Gets the name of the server of the connection.
 int getPort()
          Gets the port of the connector.
 String getProvider()
          Gets the provider of the connection.
 int getRedirectPort()
          Gets the port of the corresponding secure/non-secure port to redirect requests.
 int getRequestTimeout()
          Gets the timeout for the processing time of one client request.
protected  MBeanReference getTimeoutMBean()
          Gets a reference to the timeout MBean.
 boolean isKeepConnection()
          Checks whether to keep connections alive on idle after processing the corresponding requests if applicable.
 boolean isLoggingDisabled()
          Checks whether access logging of this connector is disabled.
 boolean isSecure()
          Checks the secure connections flag.
 boolean isStarted()
          Checks whether the startable has been started.
 boolean keepConnection(Connection con)
          Keeps the specified connection alive on idle after processing the corresponding request if applicable.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
protected  void setAddress(String addr)
          Sets the address of the server of the connection.
 void setConnectionTimeout(int timeout)
          Sets the timeout to wait for a request in an idle connection.
 void setFilterName(ObjectName filter)
          Sets the filter processing the requests.
protected  void setInetAddress(InetAddress addr)
          Sets the inet address of the local host.
 void setKeyAlias(String alias)
          Sets the certificate key alias of the connection.
 void setKeyPassword(String pswd)
          Sets the certificate key password of the connection.
 void setLoggerName(ObjectName logger)
          Sets the access logger of this connector.
 void setLoggingDisabled(boolean flag)
          Sets whether access logging of this connector is disabled.
 void setMaxIdleConnections(int count)
          Sets the maximum number of idle connections to keep alive.
 void setPort(int port)
          Sets the port of the connector.
 void setProvider(String name)
          Sets the provider of the connection.
 void setRedirectPort(int port)
          Sets the port of the corresponding secure/non-secure port to redirect requests.
 void setRequestTimeout(int timeout)
          Sets the timeout for the processing time of one client request.
 void setSecure(boolean secure)
          Sets the secure connections flag.
 void start()
          Starts the MBean.
 void stop()
          Stops the MBean.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALHOST

protected static final InetAddress LOCALHOST
The default local host.

Constructor Detail

DefaultConnector

public DefaultConnector()
Constructs a new connector.


DefaultConnector

protected DefaultConnector(InetAddress addr)
Constructs a connector with a host address.

Parameters:
addr - the host address.
Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

getName

public String getName()
Description copied from interface: Connector
Gets the name of the server of the connection.

Specified by:
getName in interface Connector
Returns:
the name of the server.

getAddress

public String getAddress()
Description copied from interface: Connector
Gets the address of the server of the connection.

Specified by:
getAddress in interface Connector
Returns:
the address of the server.

getProvider

public String getProvider()
Description copied from interface: Connector
Gets the provider of the connection.

Specified by:
getProvider in interface Connector
Returns:
the name of the provider.

setProvider

public void setProvider(String name)
Description copied from interface: Connector
Sets the provider of the connection.

Specified by:
setProvider in interface Connector
Parameters:
name - the name of the provider.

getKeyAlias

public String getKeyAlias()
Description copied from interface: Connector
Gets the certificate key alias of the connection.

Specified by:
getKeyAlias in interface Connector
Returns:
the key alias.

setKeyAlias

public void setKeyAlias(String alias)
Description copied from interface: Connector
Sets the certificate key alias of the connection.

Specified by:
setKeyAlias in interface Connector
Parameters:
alias - the key alias.

setKeyPassword

public void setKeyPassword(String pswd)
Description copied from interface: Connector
Sets the certificate key password of the connection.

Specified by:
setKeyPassword in interface Connector
Parameters:
pswd - the key pssword.

getPort

public int getPort()
Description copied from interface: Connector
Gets the port of the connector.

Specified by:
getPort in interface Connector
Returns:
the port number.

setPort

public void setPort(int port)
Description copied from interface: Connector
Sets the port of the connector.

Specified by:
setPort in interface Connector
Parameters:
port - the port number.

getRedirectPort

public int getRedirectPort()
Description copied from interface: Connector
Gets the port of the corresponding secure/non-secure port to redirect requests.

Specified by:
getRedirectPort in interface Connector
Returns:
the redirect port number.

setRedirectPort

public void setRedirectPort(int port)
Description copied from interface: Connector
Sets the port of the corresponding secure/non-secure port to redirect requests.

Specified by:
setRedirectPort in interface Connector
Parameters:
port - the redirect port number.

isSecure

public boolean isSecure()
Description copied from interface: Connector
Checks the secure connections flag.

Specified by:
isSecure in interface Connector
Returns:
true if connections are secure.

setSecure

public void setSecure(boolean secure)
Description copied from interface: Connector
Sets the secure connections flag.

Specified by:
setSecure in interface Connector
Parameters:
secure - the secure connections flag.

getFilterName

public ObjectName getFilterName()
Description copied from interface: Connector
Gets the filter processing the requests.

Specified by:
getFilterName in interface Connector
Returns:
the name or pattern of the filter.

setFilterName

public void setFilterName(ObjectName filter)
Description copied from interface: Connector
Sets the filter processing the requests.

Specified by:
setFilterName in interface Connector
Parameters:
filter - the name or pattern of the filter.

getRequestTimeout

public int getRequestTimeout()
Description copied from interface: Connector
Gets the timeout for the processing time of one client request.

Specified by:
getRequestTimeout in interface Connector
Returns:
the timeout for requests in msecs.

setRequestTimeout

public void setRequestTimeout(int timeout)
Description copied from interface: Connector
Sets the timeout for the processing time of one client request. -1 grants endless processing time.

Specified by:
setRequestTimeout in interface Connector
Parameters:
timeout - a new timeout for requests in msecs.

getConnectionTimeout

public int getConnectionTimeout()
Description copied from interface: Connector
Gets the timeout to wait for a request from an idle connection.

Specified by:
getConnectionTimeout in interface Connector
Returns:
the timeout for connections in msecs.

setConnectionTimeout

public void setConnectionTimeout(int timeout)
Description copied from interface: Connector
Sets the timeout to wait for a request in an idle connection. The timeout is used only if connections are to be kept alive after request processing. -1 waits until the client closes the connection, 0 waits only if the next request is already available and other values wait for the specified time.

Specified by:
setConnectionTimeout in interface Connector
Parameters:
timeout - the timeout for connections in msecs.

getMaxIdleConnections

public int getMaxIdleConnections()
Description copied from interface: Connector
Gets the maximum number of idle connections to keep alive.

Specified by:
getMaxIdleConnections in interface Connector
Returns:
the max number of idle connections.

setMaxIdleConnections

public void setMaxIdleConnections(int count)
Description copied from interface: Connector
Sets the maximum number of idle connections to keep alive. -1 indicates an indefinite number of connections.

Note that how to apply the limit to the active number of connections is implementation dependent.

Specified by:
setMaxIdleConnections in interface Connector
Parameters:
count - the max number of idle connections.

getConnectionCount

public int getConnectionCount()
Description copied from interface: Connector
Gets a snapshot of the number of active and idle connections.

Note that the count is implementation dependent and its accuracy may vary.

Specified by:
getConnectionCount in interface Connector
Returns:
the number of connections.

isLoggingDisabled

public boolean isLoggingDisabled()
Description copied from interface: Connector
Checks whether access logging of this connector is disabled.

Specified by:
isLoggingDisabled in interface Connector
Returns:
true if logging is disabled, false otherwise.

setLoggingDisabled

public void setLoggingDisabled(boolean flag)
Description copied from interface: Connector
Sets whether access logging of this connector is disabled.

Specified by:
setLoggingDisabled in interface Connector
Parameters:
flag - true if logging is disabled, false otherwise.

getLoggerName

public ObjectName getLoggerName()
Description copied from interface: Connector
Gets the the access logger of this connector.

Specified by:
getLoggerName in interface Connector
Returns:
the object name of the logger or a query.

setLoggerName

public void setLoggerName(ObjectName logger)
Description copied from interface: Connector
Sets the access logger of this connector. If it is not set, the default one will be used.

Specified by:
setLoggerName in interface Connector
Parameters:
logger - the object name of the logger or a query.

isKeepConnection

public boolean isKeepConnection()
Description copied from interface: Connector
Checks whether to keep connections alive on idle after processing the corresponding requests if applicable.

Specified by:
isKeepConnection in interface Connector
Returns:
true to keep, false otherwise.

keepConnection

public boolean keepConnection(Connection con)
Description copied from interface: Connector
Keeps the specified connection alive on idle after processing the corresponding request if applicable.

Specified by:
keepConnection in interface Connector
Parameters:
con - the connection.
Returns:
true if kept, false otherwise.

isStarted

public boolean isStarted()
Description copied from interface: Startable
Checks whether the startable has been started.

Specified by:
isStarted in interface Startable
Returns:
true if started, otherwise false.

start

public void start()
           throws Exception
Description copied from interface: Startable
Starts the MBean.

Specified by:
start in interface Startable
Throws:
Exception - if start fails.

stop

public void stop()
Description copied from interface: Startable
Stops the MBean.

Specified by:
stop in interface Startable

getFilterMBean

protected MBeanReference getFilterMBean()
Gets a reference to the filter MBean.

Returns:
a reference to the filter MBean.

getLoggerMBean

protected MBeanReference getLoggerMBean()
Gets a reference to the logger MBean.

Returns:
a reference to the logger MBean.

getTimeoutMBean

protected MBeanReference getTimeoutMBean()
Gets a reference to the timeout MBean.

Returns:
a reference to the timeout MBean.

setAddress

protected void setAddress(String addr)
                   throws UnknownHostException
Sets the address of the server of the connection.

Parameters:
addr - the address of the server.
Throws:
UnknownHostException - if not found.

getInetAddress

protected InetAddress getInetAddress()
Gets the inet address of the local host if set.

Returns:
the inet address or null.

setInetAddress

protected void setInetAddress(InetAddress addr)
Sets the inet address of the local host.

Parameters:
addr - the inet address or null.


Copyright © 2004 The Norther Organization. All rights reserved.