|
|||||||||
| Home >> All >> org >> mortbay >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.mortbay.http
Class SocketListener

java.lang.Objectorg.mortbay.util.ThreadPool
org.mortbay.util.ThreadedServer
org.mortbay.http.SocketListener
- All Implemented Interfaces:
- HttpListener, org.mortbay.util.LifeCycle, java.io.Serializable
- Direct Known Subclasses:
- JsseListener
- public class SocketListener
- extends org.mortbay.util.ThreadedServer
- implements HttpListener
- extends org.mortbay.util.ThreadedServer
Socket HTTP Listener. The behaviour of the listener can be controlled with the attributues of the ThreadedServer and ThreadPool from which it is derived. Specifically:
MinThreads - Minumum threads waiting to service requests.
MaxThread - Maximum thread that will service requests.
MaxIdleTimeMs - Time for an idle thread to wait for a request or read.
LowResourcePersistTimeMs - time in ms that connections will persist if listener is
low on resources.
- Version:
- $Id: SocketListener.java,v 1.33 2003/11/22 16:06:02 gregwilkins Exp $
| Nested Class Summary |
| Nested classes inherited from class org.mortbay.util.ThreadedServer |
|
| Nested classes inherited from class org.mortbay.util.ThreadPool |
org.mortbay.util.ThreadPool.PoolThread |
| Field Summary | |
private int |
_bufferReserve
|
private int |
_bufferSize
|
private int |
_confidentialPort
|
private java.lang.String |
_confidentialScheme
|
private HttpHandler |
_handler
|
private boolean |
_identifyListener
|
private int |
_integralPort
|
private java.lang.String |
_integralScheme
|
private boolean |
_isLow
|
private boolean |
_isOut
|
private int |
_lowResourcePersistTimeMs
|
private java.lang.String |
_scheme
|
private HttpServer |
_server
|
private long |
_warned
|
private static org.apache.commons.logging.Log |
log
|
| Fields inherited from class org.mortbay.util.ThreadedServer |
|
| Fields inherited from class org.mortbay.util.ThreadPool |
__DAEMON, __PRIORITY |
| Fields inherited from interface org.mortbay.http.HttpListener |
ATTRIBUTE |
| Constructor Summary | |
SocketListener()
|
|
SocketListener(org.mortbay.util.InetAddrPort address)
|
|
| Method Summary | |
protected HttpConnection |
createConnection(java.net.Socket socket)
Create an HttpConnection instance. |
void |
customizeRequest(HttpConnection connection,
HttpRequest request)
Customize the request from connection. |
protected void |
customizeRequest(java.net.Socket socket,
HttpRequest request)
Customize request from socket. |
int |
getBufferReserve()
Get the size of the header reserve area. |
int |
getBufferSize()
Get the size of the buffers used by connections from this listener. |
int |
getConfidentialPort()
Get the protocol port to use for confidential redirections. |
java.lang.String |
getConfidentialScheme()
Get the protocol scheme to use for confidential redirections. |
java.lang.String |
getDefaultScheme()
Get the default scheme for requests. |
HttpHandler |
getHttpHandler()
Get an optional HttpHandler for the listener. |
HttpServer |
getHttpServer()
Get the HttpServer instance for this HttpListener. |
boolean |
getIdentifyListener()
|
int |
getIntegralPort()
Get the protocol port to use for integral redirections. |
java.lang.String |
getIntegralScheme()
Get the protocol scheme to use for integral redirections. |
int |
getLowResourcePersistTimeMs()
|
void |
handleConnection(java.net.Socket socket)
Handle Job. |
boolean |
isConfidential(HttpConnection connection)
Get the confidential status of a connection. |
boolean |
isIntegral(HttpConnection connection)
Get the integral status of a connection. |
boolean |
isLowOnResources()
Get the lowOnResource state of the listener. |
boolean |
isOutOfResources()
Get the outOfResource state of the listener. |
void |
persistConnection(HttpConnection connection)
Persist the connection. |
void |
setBufferReserve(int size)
|
void |
setBufferSize(int size)
|
void |
setConfidentialPort(int confidentialPort)
|
void |
setConfidentialScheme(java.lang.String confidentialScheme)
|
void |
setDefaultScheme(java.lang.String scheme)
|
void |
setHttpHandler(HttpHandler handler)
|
void |
setHttpServer(HttpServer server)
Set the HttpServer instance for this HttpListener. |
void |
setIdentifyListener(boolean identifyListener)
|
void |
setIntegralPort(int integralPort)
|
void |
setIntegralScheme(java.lang.String integralScheme)
|
void |
setLowResourcePersistTimeMs(int ms)
Set the low resource persistace time. |
void |
start()
Start the LifeCycle. |
void |
stop()
Stop the LifeCycle. |
| Methods inherited from class org.mortbay.util.ThreadedServer |
acceptSocket, getHost, getInetAddress, getInetAddrPort, getLingerTimeSecs, getMaxReadTimeMs, getPort, getServerSocket, getTcpNoDelay, handle, handleConnection, newServerSocket, open, 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 |
log
private static org.apache.commons.logging.Log log
_lowResourcePersistTimeMs
private int _lowResourcePersistTimeMs
_scheme
private java.lang.String _scheme
_integralScheme
private java.lang.String _integralScheme
_confidentialScheme
private java.lang.String _confidentialScheme
_integralPort
private int _integralPort
_confidentialPort
private int _confidentialPort
_identifyListener
private boolean _identifyListener
_bufferSize
private int _bufferSize
_bufferReserve
private int _bufferReserve
_handler
private HttpHandler _handler
_server
private transient HttpServer _server
_isLow
private transient boolean _isLow
_isOut
private transient boolean _isOut
_warned
private transient long _warned
| Constructor Detail |
SocketListener
public SocketListener()
SocketListener
public SocketListener(org.mortbay.util.InetAddrPort address)
| Method Detail |
getHttpServer
public HttpServer getHttpServer()
- Description copied from interface:
HttpListener - Get the HttpServer instance for this HttpListener.
- Specified by:
getHttpServerin interfaceHttpListener
setHttpServer
public void setHttpServer(HttpServer server)
- Description copied from interface:
HttpListener - Set the HttpServer instance for this HttpListener.
This method is called by the HttpServer.addListener method.
It should not be called directly.
- Specified by:
setHttpServerin interfaceHttpListener
getHttpHandler
public HttpHandler getHttpHandler()
- Description copied from interface:
HttpListener - Get an optional HttpHandler for the listener.
If Set, then HttpConnection will pass requests from this listener
to this handler with an empty context path, before passing the
request to the HttpServer. This allows listener specific handling
to be added or even a HttpContext (which is a HttpHandler) to be
bound directly to HttpListener.
- Specified by:
getHttpHandlerin interfaceHttpListener
setHttpHandler
public void setHttpHandler(HttpHandler handler)
getBufferSize
public int getBufferSize()
- Description copied from interface:
HttpListener - Get the size of the buffers used by connections from this listener.
- Specified by:
getBufferSizein interfaceHttpListener
setBufferSize
public void setBufferSize(int size)
getBufferReserve
public int getBufferReserve()
- Description copied from interface:
HttpListener - Get the size of the header reserve area.
Get the size of the header reserve area within the buffers used
by connections from this listener. The header reserve is space
reserved in the first buffer of a response to allow a HTTP header to
be written in the same packet. The reserve should be large enough to
avoid moving data to fit the header, but not too large as to waste memory.
- Specified by:
getBufferReservein interfaceHttpListener
setBufferReserve
public void setBufferReserve(int size)
getIdentifyListener
public boolean getIdentifyListener()
setIdentifyListener
public void setIdentifyListener(boolean identifyListener)
setDefaultScheme
public void setDefaultScheme(java.lang.String scheme)
getDefaultScheme
public java.lang.String getDefaultScheme()
- Description copied from interface:
HttpListener - Get the default scheme for requests.
If a request is received from a HttpConnection created by this
listener, that does not include a scheme in it's request URL, then
this method is used to determine the protocol scheme most likely used
to connect to this listener.
- Specified by:
getDefaultSchemein interfaceHttpListener
getLowResourcePersistTimeMs
public int getLowResourcePersistTimeMs()
setLowResourcePersistTimeMs
public void setLowResourcePersistTimeMs(int ms)
- Set the low resource persistace time.
When the listener is low on resources, this timeout is used for idle
persistent connections. It is desirable to have this set to a short
period of time so that idle persistent connections do not consume
resources on a busy server.
start
public void start()
throws java.lang.Exception
- Description copied from interface:
org.mortbay.util.LifeCycle - Start the LifeCycle.
- Specified by:
startin interfaceorg.mortbay.util.LifeCycle
stop
public void stop()
throws java.lang.InterruptedException
- Description copied from interface:
org.mortbay.util.LifeCycle - Stop the LifeCycle.
The LifeCycle may wait for current activities to complete
normally, but it can be interrupted.
- Specified by:
stopin interfaceorg.mortbay.util.LifeCycle
handleConnection
public void handleConnection(java.net.Socket socket) throws java.io.IOException
- Handle Job.
Implementation of ThreadPool.handle(), calls handleConnection.
createConnection
protected HttpConnection createConnection(java.net.Socket socket) throws java.io.IOException
- Create an HttpConnection instance. This method can be used to
override the connection instance.
customizeRequest
public void customizeRequest(HttpConnection connection, HttpRequest request)
- Customize the request from connection.
This method extracts the socket from the connection and calls
the customizeRequest(Socket,HttpRequest) method.
- Specified by:
customizeRequestin interfaceHttpListener
customizeRequest
protected void customizeRequest(java.net.Socket socket, 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).
This version resets the SoTimeout if it has been reduced due to
low resources. Derived implementations should call
super.customizeRequest(socket,request) unless persistConnection
has also been overridden and not called.
persistConnection
public void persistConnection(HttpConnection connection)
- Persist the connection.
This method is called by the HttpConnection in order to prepare a
connection to be persisted. For this implementation,
if the listener is low on resources, the connection read
timeout is set to lowResourcePersistTimeMs. The
customizeRequest method is used to reset this to the normal
value after a request has been read.
- Specified by:
persistConnectionin interfaceHttpListener
isLowOnResources
public boolean isLowOnResources()
- Get the lowOnResource state of the listener.
A SocketListener is considered low on resources if the total number of
threads is maxThreads and the number of idle threads is less than minThreads.
- Specified by:
isLowOnResourcesin interfaceHttpListener
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:
isOutOfResourcesin interfaceHttpListener
isIntegral
public boolean isIntegral(HttpConnection connection)
- Description copied from interface:
HttpListener - Get the integral status of a connection.
- Specified by:
isIntegralin interfaceHttpListener
isConfidential
public boolean isConfidential(HttpConnection connection)
- Description copied from interface:
HttpListener - Get the confidential status of a connection.
- Specified by:
isConfidentialin interfaceHttpListener
getIntegralScheme
public java.lang.String getIntegralScheme()
- Description copied from interface:
HttpListener - Get the protocol scheme to use for integral redirections.
If an INTEGRAL security constraint is not met for a request, the
request is redirected to an integral port. This scheme return by this
method is used for that redirection.
- Specified by:
getIntegralSchemein interfaceHttpListener
setIntegralScheme
public void setIntegralScheme(java.lang.String integralScheme)
getIntegralPort
public int getIntegralPort()
- Description copied from interface:
HttpListener - Get the protocol port to use for integral redirections.
If an INTEGRAL security constraint is not met for a request, the
request is redirected to an integral port. This port return by this
method is used for that redirection.
- Specified by:
getIntegralPortin interfaceHttpListener
setIntegralPort
public void setIntegralPort(int integralPort)
getConfidentialScheme
public java.lang.String getConfidentialScheme()
- Description copied from interface:
HttpListener - Get the protocol scheme to use for confidential redirections.
If an CONFIDENTIAL security constraint is not met for a request, the
request is redirected to an confidential port. This scheme return by this
method is used for that redirection.
- Specified by:
getConfidentialSchemein interfaceHttpListener
setConfidentialScheme
public void setConfidentialScheme(java.lang.String confidentialScheme)
getConfidentialPort
public int getConfidentialPort()
- Description copied from interface:
HttpListener - Get the protocol port to use for confidential redirections.
If an CONFIDENTIAL security constraint is not met for a request, the
request is redirected to an confidential port. This port return by this
method is used for that redirection.
- Specified by:
getConfidentialPortin interfaceHttpListener
setConfidentialPort
public void setConfidentialPort(int confidentialPort)
|
|||||||||
| Home >> All >> org >> mortbay >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC