Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.http.ajp
Class AJP13Listener  view AJP13Listener download AJP13Listener.java

java.lang.Object
  extended byorg.mortbay.util.ThreadPool
      extended byorg.mortbay.util.ThreadedServer
          extended byorg.mortbay.http.ajp.AJP13Listener
All Implemented Interfaces:
org.mortbay.http.HttpListener, org.mortbay.util.LifeCycle, java.io.Serializable

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

AJP 1.3 Protocol Listener. This listener takes requests from the mod_jk or mod_jk2 modules used by web servers such as apache and IIS to forward requests to a servlet container.

This code uses the AJP13 code from tomcat3.3 as the protocol specification, but is new implementation.

Version:
$Id: AJP13Listener.java,v 1.17 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  org.mortbay.http.HttpHandler _handler
           
private  boolean _identifyListener
           
private  int _integralPort
           
private  java.lang.String _integralScheme
           
private  boolean _lastLow
           
private  boolean _lastOut
           
private  java.lang.String[] _remoteServers
           
private  org.mortbay.http.HttpServer _server
           
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
AJP13Listener()
           
AJP13Listener(org.mortbay.util.InetAddrPort address)
           
 
Method Summary
protected  AJP13Connection createConnection(java.net.Socket socket)
          Create an AJP13Connection instance.
 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 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.
 org.mortbay.http.HttpHandler getHttpHandler()
          Get an optional HttpHandler for the listener.
 org.mortbay.http.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.
 java.lang.String[] getRemoteServers()
           
 void handleConnection(java.net.Socket socket)
          Handle Job.
 boolean isConfidential(org.mortbay.http.HttpConnection connection)
          Get the confidential status of a connection.
 boolean isIntegral(org.mortbay.http.HttpConnection connection)
          Get the integral status of a connection.
 boolean isLowOnResources()
          Get the low on resources state of the listener.
 boolean isOutOfResources()
          Get the out of resources state of the listener.
 void persistConnection(org.mortbay.http.HttpConnection connection)
          Persist the connection.
 void setBufferReserve(int size)
           
 void setBufferSize(int size)
           
 void setConfidentialPort(int confidentialPort)
           
 void setConfidentialScheme(java.lang.String confidentialScheme)
           
 void setHttpHandler(org.mortbay.http.HttpHandler handler)
           
 void setHttpServer(org.mortbay.http.HttpServer server)
          Set the HttpServer instance for this HttpListener.
 void setIdentifyListener(boolean identifyListener)
           
 void setIntegralPort(int integralPort)
           
 void setIntegralScheme(java.lang.String integralScheme)
           
 void setRemoteServers(java.lang.String[] servers)
          Set accepted remote servers.
 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

_server

private org.mortbay.http.HttpServer _server

_lastOut

private boolean _lastOut

_lastLow

private boolean _lastLow

_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

_remoteServers

private java.lang.String[] _remoteServers

_handler

private org.mortbay.http.HttpHandler _handler
Constructor Detail

AJP13Listener

public AJP13Listener()

AJP13Listener

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

setHttpServer

public void setHttpServer(org.mortbay.http.HttpServer server)
Description copied from interface: org.mortbay.http.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:
setHttpServer in interface org.mortbay.http.HttpListener

getHttpServer

public org.mortbay.http.HttpServer getHttpServer()
Description copied from interface: org.mortbay.http.HttpListener
Get the HttpServer instance for this HttpListener.

Specified by:
getHttpServer in interface org.mortbay.http.HttpListener

getBufferSize

public int getBufferSize()
Description copied from interface: org.mortbay.http.HttpListener
Get the size of the buffers used by connections from this listener.

Specified by:
getBufferSize in interface org.mortbay.http.HttpListener

setBufferSize

public void setBufferSize(int size)

getBufferReserve

public int getBufferReserve()
Description copied from interface: org.mortbay.http.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:
getBufferReserve in interface org.mortbay.http.HttpListener

setBufferReserve

public void setBufferReserve(int size)

getIdentifyListener

public boolean getIdentifyListener()

setIdentifyListener

public void setIdentifyListener(boolean identifyListener)

getDefaultScheme

public java.lang.String getDefaultScheme()
Description copied from interface: org.mortbay.http.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:
getDefaultScheme in interface org.mortbay.http.HttpListener

start

public void start()
           throws java.lang.Exception
Description copied from interface: org.mortbay.util.LifeCycle
Start the LifeCycle.

Specified by:
start in interface org.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:
stop in interface org.mortbay.util.LifeCycle

getRemoteServers

public java.lang.String[] getRemoteServers()

setRemoteServers

public void setRemoteServers(java.lang.String[] servers)
Set accepted remote servers. The AJP13 protocol is not secure and contains no authentication. If remote servers are set, then this listener will only accept connections from hosts with matching addresses or hostnames.


handleConnection

public void handleConnection(java.net.Socket socket)
                      throws java.io.IOException
Handle Job. Implementation of ThreadPool.handle(), calls handleConnection.


createConnection

protected AJP13Connection createConnection(java.net.Socket socket)
                                    throws java.io.IOException
Create an AJP13Connection instance. This method can be used to override the connection instance.


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

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).


persistConnection

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

Specified by:
persistConnection in interface org.mortbay.http.HttpListener

isLowOnResources

public boolean isLowOnResources()
Description copied from interface: org.mortbay.http.HttpListener
Get the low on resources state of the listener. For most implementations, Threads are the resource reported on by this method.

Specified by:
isLowOnResources in interface org.mortbay.http.HttpListener

isOutOfResources

public boolean isOutOfResources()
Description copied from interface: org.mortbay.http.HttpListener
Get the out of resources state of the listener. For most implementations, Threads are the resource reported on by this method.

Specified by:
isOutOfResources in interface org.mortbay.http.HttpListener

isIntegral

public boolean isIntegral(org.mortbay.http.HttpConnection connection)
Description copied from interface: org.mortbay.http.HttpListener
Get the integral status of a connection.

Specified by:
isIntegral in interface org.mortbay.http.HttpListener

isConfidential

public boolean isConfidential(org.mortbay.http.HttpConnection connection)
Description copied from interface: org.mortbay.http.HttpListener
Get the confidential status of a connection.

Specified by:
isConfidential in interface org.mortbay.http.HttpListener

getIntegralScheme

public java.lang.String getIntegralScheme()
Description copied from interface: org.mortbay.http.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:
getIntegralScheme in interface org.mortbay.http.HttpListener

setIntegralScheme

public void setIntegralScheme(java.lang.String integralScheme)

getIntegralPort

public int getIntegralPort()
Description copied from interface: org.mortbay.http.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:
getIntegralPort in interface org.mortbay.http.HttpListener

setIntegralPort

public void setIntegralPort(int integralPort)

getConfidentialScheme

public java.lang.String getConfidentialScheme()
Description copied from interface: org.mortbay.http.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:
getConfidentialScheme in interface org.mortbay.http.HttpListener

setConfidentialScheme

public void setConfidentialScheme(java.lang.String confidentialScheme)

getConfidentialPort

public int getConfidentialPort()
Description copied from interface: org.mortbay.http.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:
getConfidentialPort in interface org.mortbay.http.HttpListener

setConfidentialPort

public void setConfidentialPort(int confidentialPort)

getHttpHandler

public org.mortbay.http.HttpHandler getHttpHandler()
Description copied from interface: org.mortbay.http.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:
getHttpHandler in interface org.mortbay.http.HttpListener

setHttpHandler

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