public class SocketListener extends ThreadedServer implements HttpListener
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.
ThreadPool.PoolThread
__DAEMON, __PRIORITY
ATTRIBUTE
Constructor and Description |
---|
SocketListener() |
SocketListener(InetAddrPort address) |
Modifier and Type | Method and Description |
---|---|
protected HttpConnection |
createConnection(Socket socket)
Create an HttpConnection instance.
|
void |
customizeRequest(HttpConnection connection,
HttpRequest request)
Customize the request from connection.
|
protected void |
customizeRequest(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.
|
String |
getConfidentialScheme()
Get the protocol scheme to use for confidential redirections.
|
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.
|
String |
getIntegralScheme()
Get the protocol scheme to use for integral redirections.
|
int |
getLowResourcePersistTimeMs() |
int |
getLowResources() |
void |
handleConnection(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(String confidentialScheme) |
void |
setDefaultScheme(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(String integralScheme) |
void |
setLowResourcePersistTimeMs(int ms)
Set the low resource persistace time.
|
void |
setLowResources(int lowResources) |
void |
start()
Start the LifeCycle.
|
void |
stop()
Stop the ThreadPool.
|
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
getIdleThreads, getMaxIdleTimeMs, getMaxThreads, getMinThreads, getName, getPoolName, getThreads, getThreadsPriority, isDaemon, isStarted, join, run, setDaemon, setMaxIdleTimeMs, setMaxStopTimeMs, setMaxThreads, setMinThreads, setName, setPoolName, setThreadsPriority, shrink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getHost, getPort, setHost, setPort
public SocketListener()
public SocketListener(InetAddrPort address)
public HttpServer getHttpServer()
HttpListener
getHttpServer
in interface HttpListener
public void setHttpServer(HttpServer server)
HttpListener
setHttpServer
in interface HttpListener
server
- The HttpServer instance this HttpListener has been added to.public HttpHandler getHttpHandler()
HttpListener
getHttpHandler
in interface HttpListener
public void setHttpHandler(HttpHandler handler)
public int getBufferSize()
HttpListener
getBufferSize
in interface HttpListener
public void setBufferSize(int size)
public int getBufferReserve()
HttpListener
getBufferReserve
in interface HttpListener
public void setBufferReserve(int size)
public boolean getIdentifyListener()
public void setIdentifyListener(boolean identifyListener)
identifyListener
- If true, the listener name is added to all
requests as the org.openqa.jetty.http.HttListener attributepublic void setDefaultScheme(String scheme)
public String getDefaultScheme()
HttpListener
getDefaultScheme
in interface HttpListener
public int getLowResources()
public void setLowResources(int lowResources)
lowResources
- The number of idle threads needed to not be in
low resources state.public int getLowResourcePersistTimeMs()
public void setLowResourcePersistTimeMs(int ms)
ms
- time in ms that connections will persist if listener is
low on resources.public void start() throws Exception
LifeCycle
start
in interface LifeCycle
start
in class ThreadedServer
Exception
- An arbitrary exception may be thrown.public void stop() throws InterruptedException
ThreadPool
stop
in interface LifeCycle
stop
in class ThreadedServer
InterruptedException
- Stopping a lifecycle is rarely atomic
and may be interrupted by another thread. If this happens
InterruptedException is throw and the component will be in an
indeterminant state and should probably be discarded.public void handleConnection(Socket socket) throws IOException
handleConnection
in class ThreadedServer
socket
- A Connection.IOException
protected HttpConnection createConnection(Socket socket) throws IOException
socket
- The underlying socket.IOException
public void customizeRequest(HttpConnection connection, HttpRequest request)
customizeRequest
in interface HttpListener
request
- connection
- The connection the request was received on, which must
be a HttpConnection created by this listener.protected void customizeRequest(Socket socket, HttpRequest request)
request
- public void persistConnection(HttpConnection connection)
persistConnection
in interface HttpListener
connection
- The HttpConnection to use.public boolean isLowOnResources()
isLowOnResources
in interface HttpListener
public boolean isOutOfResources()
isOutOfResources
in interface HttpListener
public boolean isIntegral(HttpConnection connection)
HttpListener
isIntegral
in interface HttpListener
connection
- The connection to test.public boolean isConfidential(HttpConnection connection)
HttpListener
isConfidential
in interface HttpListener
connection
- The connection to test.public String getIntegralScheme()
HttpListener
getIntegralScheme
in interface HttpListener
public void setIntegralScheme(String integralScheme)
public int getIntegralPort()
HttpListener
getIntegralPort
in interface HttpListener
public void setIntegralPort(int integralPort)
public String getConfidentialScheme()
HttpListener
getConfidentialScheme
in interface HttpListener
public void setConfidentialScheme(String confidentialScheme)
public int getConfidentialPort()
HttpListener
getConfidentialPort
in interface HttpListener
public void setConfidentialPort(int confidentialPort)
Copyright © 2013. All Rights Reserved.