org.enhydra.servlet.connectionMethods.EnhydraDirector
Class EnhydraListener

java.lang.Object
  extended byorg.mortbay.util.ThreadPool
      extended byorg.mortbay.util.ThreadedServer
          extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraListener
All Implemented Interfaces:
org.mortbay.http.HttpListener, org.mortbay.util.LifeCycle, java.io.Serializable

public class EnhydraListener
extends org.mortbay.util.ThreadedServer
implements org.mortbay.http.HttpListener

Author:
Milin Radivoj TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.mortbay.util.ThreadPool
org.mortbay.util.ThreadPool.PoolThread
 
Field Summary
protected  java.lang.String authKey
           
protected  java.lang.String bindAddress
           
protected  int clientTimeout
           
protected static java.lang.String DEFAULT_AUTH_KEY
           
static int DEFAULT_CLIENT_TIMEOUT
           
static java.lang.String SESSION_AFFINITY
           
protected  boolean sessionAffinity
           
 
Fields inherited from class org.mortbay.util.ThreadPool
__DAEMON, __PRIORITY
 
Fields inherited from interface org.mortbay.http.HttpListener
ATTRIBUTE
 
Constructor Summary
EnhydraListener()
           
EnhydraListener(org.mortbay.util.InetAddrPort address)
           
 
Method Summary
protected  EnhydraConnection createConnection(java.net.Socket socket)
           
 void customizeRequest(org.mortbay.http.HttpConnection connection, org.mortbay.http.HttpRequest request)
          Customize the request from connection.
protected  void customizeRequest(java.net.Socket socket, org.mortbay.http.HttpRequest request)
          Customize request from socket.
 int getAcceptCount()
           
 java.lang.String getAuthKey()
          Get the authentication key for this connection.
 java.lang.String getBindAddress()
          Gets the current Bind address, if any.
 int getBufferReserve()
           
 int getBufferSize()
           
 int getClientTimeout()
          Gets the client timeout associated with this connection method.
 int getConfidentialPort()
           
 java.lang.String getConfidentialScheme()
           
 java.lang.String getDefaultScheme()
           
 boolean getEnableLookups()
           
 org.mortbay.http.HttpHandler getHttpHandler()
           
 org.mortbay.http.HttpServer getHttpServer()
           
 boolean getIdentifyListener()
           
 int getIntegralPort()
           
 java.lang.String getIntegralScheme()
           
 boolean getSessionAffinity()
          getSessionAffinity() and setSessionAffinity().
 int getThreadTimeout()
           
 java.lang.String getURIEncoding()
           
 boolean getUseBodyEncodingForURI()
           
 void handleConnection(java.net.Socket socket)
           
 boolean isConfidential(org.mortbay.http.HttpConnection connection)
           
 boolean isIntegral(org.mortbay.http.HttpConnection connection)
           
 boolean isLowOnResources()
          Get the lowOnResource state of the listener.
 boolean isOutOfResources()
          Get the outOfResource state of the listener.
 void manageServerId(java.net.Socket socket)
           
 void persistConnection(org.mortbay.http.HttpConnection connection)
          Persist the connection.
 void setAcceptCount(int i)
           
 void setAuthKey(java.lang.String authKey)
          Set the authentication key for this connection.
 void setBindAddress(java.lang.String addr)
          Sets the current Bind address, if any.
 void setBufferReserve(int size)
           
 void setBufferSize(int size)
           
 void setClientTimeout(int clientTimeout)
           
 void setConfidentialPort(int confidentialPort)
           
 void setConfidentialScheme(java.lang.String confidentialScheme)
           
 void setEnableLookups(boolean enable)
           
 void setHttpHandler(org.mortbay.http.HttpHandler handler)
           
 void setHttpServer(org.mortbay.http.HttpServer server)
           
 void setIdentifyListener(boolean identifyListener)
           
 void setIntegralPort(int integralPort)
           
 void setIntegralScheme(java.lang.String integralScheme)
           
 void setSessionAffinity(java.lang.String sessionAffinity)
           
 void setThreadTimeout(int threadTimeout)
           
 void setURIEncoding(java.lang.String enc)
           
 void setUseBodyEncodingForURI(boolean use)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.mortbay.util.ThreadedServer
acceptSocket, acceptSocket, getAcceptorThreads, getAcceptQueueSize, getHost, getInetAddress, getInetAddrPort, getLingerTimeSecs, getMaxReadTimeMs, getPort, getServerSocket, getTcpNoDelay, handle, handleConnection, newServerSocket, open, setAcceptorThreads, setAcceptQueueSize, setHost, setInetAddress, setInetAddrPort, setLingerTimeSecs, setMaxReadTimeMs, setPort, setTcpNoDelay, stopJob, toString
 
Methods inherited from class org.mortbay.util.ThreadPool
getIdleThreads, getMaxIdleTimeMs, getMaxThreads, getMinThreads, getName, getPoolName, getThreads, getThreadsPriority, isDaemon, isStarted, join, run, setDaemon, setMaxIdleTimeMs, setMaxStopTimeMs, setMaxThreads, setMinThreads, setName, setPoolName, setThreadsPriority, shrink
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.http.HttpListener
getHost, getPort, setHost, setPort
 
Methods inherited from interface org.mortbay.util.LifeCycle
isStarted
 

Field Detail

SESSION_AFFINITY

public static final java.lang.String SESSION_AFFINITY
See Also:
Constant Field Values

sessionAffinity

protected boolean sessionAffinity

DEFAULT_AUTH_KEY

protected static final java.lang.String DEFAULT_AUTH_KEY
See Also:
Constant Field Values

DEFAULT_CLIENT_TIMEOUT

public static final int DEFAULT_CLIENT_TIMEOUT
See Also:
Constant Field Values

clientTimeout

protected int clientTimeout

bindAddress

protected java.lang.String bindAddress

authKey

protected java.lang.String authKey
Constructor Detail

EnhydraListener

public EnhydraListener()

EnhydraListener

public EnhydraListener(org.mortbay.util.InetAddrPort address)
Method Detail

setHttpServer

public void setHttpServer(org.mortbay.http.HttpServer server)
Specified by:
setHttpServer in interface org.mortbay.http.HttpListener

getHttpServer

public org.mortbay.http.HttpServer getHttpServer()
Specified by:
getHttpServer in interface org.mortbay.http.HttpListener

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface org.mortbay.http.HttpListener

setBufferSize

public void setBufferSize(int size)

getBufferReserve

public int getBufferReserve()
Specified by:
getBufferReserve in interface org.mortbay.http.HttpListener

setBufferReserve

public void setBufferReserve(int size)

getIdentifyListener

public boolean getIdentifyListener()

setIdentifyListener

public void setIdentifyListener(boolean identifyListener)
Parameters:
identifyListener - If true, the listener name is added to all requests as the org.mortbay.http.HttListener attribute

getDefaultScheme

public java.lang.String getDefaultScheme()
Specified by:
getDefaultScheme in interface org.mortbay.http.HttpListener

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface org.mortbay.util.LifeCycle
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.InterruptedException
Specified by:
stop in interface org.mortbay.util.LifeCycle
Throws:
java.lang.InterruptedException

getSessionAffinity

public boolean getSessionAffinity()
getSessionAffinity() and setSessionAffinity().

Returns:
session affinity flag

setSessionAffinity

public void setSessionAffinity(java.lang.String sessionAffinity)

getBindAddress

public java.lang.String getBindAddress()
Gets the current Bind address, if any.


setBindAddress

public void setBindAddress(java.lang.String addr)
Sets the current Bind address, if any.


getUseBodyEncodingForURI

public boolean getUseBodyEncodingForURI()

setUseBodyEncodingForURI

public void setUseBodyEncodingForURI(boolean use)

getURIEncoding

public java.lang.String getURIEncoding()

setURIEncoding

public void setURIEncoding(java.lang.String enc)

getAcceptCount

public int getAcceptCount()

setAcceptCount

public void setAcceptCount(int i)

getEnableLookups

public boolean getEnableLookups()

setEnableLookups

public void setEnableLookups(boolean enable)

getThreadTimeout

public int getThreadTimeout()

setThreadTimeout

public void setThreadTimeout(int threadTimeout)

getAuthKey

public java.lang.String getAuthKey()
Get the authentication key for this connection.

Returns null if authentication is not required of clients.

Returns:
The authentication Key, or null if none.

setAuthKey

public void setAuthKey(java.lang.String authKey)
Set the authentication key for this connection.

Set to null if authentication with clients is not needed.

We don't allow auth key of all whitespace because it is most likely the result of accidental data entry in an otherwise blank 'key' field.

Parameters:
authKey - The new authtication key, or null if authentication is not needed.

getClientTimeout

public int getClientTimeout()
Gets the client timeout associated with this connection method.

Returns:
clientTimeout.

setClientTimeout

public void setClientTimeout(int clientTimeout)

manageServerId

public void manageServerId(java.net.Socket socket)

handleConnection

public void handleConnection(java.net.Socket socket)
                      throws java.io.IOException
Throws:
java.io.IOException

createConnection

protected EnhydraConnection createConnection(java.net.Socket socket)
                                      throws java.io.IOException
Throws:
java.io.IOException

customizeRequest

public void customizeRequest(org.mortbay.http.HttpConnection connection,
                             org.mortbay.http.HttpRequest request)
Customize the request from connection. This method extracts the socket from the connection and calls the customizeRequest(Socket,HttpRequest) method.

Specified by:
customizeRequest in interface org.mortbay.http.HttpListener
Parameters:
request -

customizeRequest

protected void customizeRequest(java.net.Socket socket,
                                org.mortbay.http.HttpRequest request)
Customize request from socket. Derived versions of SocketListener may specialize this method to customize the request with attributes of the socket used (eg SSL session ids).

Parameters:
request -

persistConnection

public void persistConnection(org.mortbay.http.HttpConnection connection)
Persist the connection.

Specified by:
persistConnection in interface org.mortbay.http.HttpListener
Parameters:
connection -

isLowOnResources

public boolean isLowOnResources()
Get the lowOnResource state of the listener. A SocketListener is considered low on resources if the total number of the number of idle threads is less than the lowResource value (or minThreads if not set)

Specified by:
isLowOnResources in interface org.mortbay.http.HttpListener
Returns:
True if low on idle threads.

isOutOfResources

public boolean isOutOfResources()
Get the outOfResource state of the listener. A SocketListener is considered out of resources if the total number of threads is maxThreads and the number of idle threads is zero.

Specified by:
isOutOfResources in interface org.mortbay.http.HttpListener
Returns:
True if out of resources.

isIntegral

public boolean isIntegral(org.mortbay.http.HttpConnection connection)
Specified by:
isIntegral in interface org.mortbay.http.HttpListener

isConfidential

public boolean isConfidential(org.mortbay.http.HttpConnection connection)
Specified by:
isConfidential in interface org.mortbay.http.HttpListener

getIntegralScheme

public java.lang.String getIntegralScheme()
Specified by:
getIntegralScheme in interface org.mortbay.http.HttpListener

setIntegralScheme

public void setIntegralScheme(java.lang.String integralScheme)

getIntegralPort

public int getIntegralPort()
Specified by:
getIntegralPort in interface org.mortbay.http.HttpListener

setIntegralPort

public void setIntegralPort(int integralPort)

getConfidentialScheme

public java.lang.String getConfidentialScheme()
Specified by:
getConfidentialScheme in interface org.mortbay.http.HttpListener

setConfidentialScheme

public void setConfidentialScheme(java.lang.String confidentialScheme)

getConfidentialPort

public int getConfidentialPort()
Specified by:
getConfidentialPort in interface org.mortbay.http.HttpListener

setConfidentialPort

public void setConfidentialPort(int confidentialPort)

getHttpHandler

public org.mortbay.http.HttpHandler getHttpHandler()
Specified by:
getHttpHandler in interface org.mortbay.http.HttpListener

setHttpHandler

public void setHttpHandler(org.mortbay.http.HttpHandler handler)