org.mortbay.http.ajp

Class AJP13Listener

Implemented Interfaces:
HttpListener, LifeCycle, Serializable

public class AJP13Listener
extends ThreadedServer
implements 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.19 2005/08/13 00:01:25 gregwilkins Exp $
Author:
Greg Wilkins (gregw)

Nested Class Summary

Nested classes/interfaces inherited from class org.mortbay.util.ThreadPool

ThreadPool.PoolThread

Field Summary

Fields inherited from class org.mortbay.util.ThreadPool

__DAEMON, __PRIORITY

Fields inherited from interface org.mortbay.http.HttpListener

ATTRIBUTE

Constructor Summary

AJP13Listener()
AJP13Listener(InetAddrPort address)
Construct for specific address and port.

Method Summary

protected AJP13Connection
createConnection(Socket socket)
Create an AJP13Connection instance.
protected void
customizeRequest(Socket socket, HttpRequest request)
Customize request from socket.
void
customizeRequest(HttpConnection connection, HttpRequest request)
Customize the request from connection.
int
getBufferReserve()
int
getBufferSize()
int
getConfidentialPort()
String
getConfidentialScheme()
String
getDefaultScheme()
HttpHandler
getHttpHandler()
HttpServer
getHttpServer()
boolean
getIdentifyListener()
int
getIntegralPort()
String
getIntegralScheme()
String[]
getRemoteServers()
void
handleConnection(Socket socket)
Handle Job.
boolean
isConfidential(HttpConnection connection)
boolean
isIntegral(HttpConnection connection)
boolean
isLowOnResources()
boolean
isOutOfResources()
void
persistConnection(HttpConnection connection)
Persist the connection.
void
setBufferReserve(int size)
void
setBufferSize(int size)
void
setConfidentialPort(int confidentialPort)
void
setConfidentialScheme(String confidentialScheme)
void
setHttpHandler(HttpHandler handler)
void
setHttpServer(HttpServer server)
void
setIdentifyListener(boolean identifyListener)
void
setIntegralPort(int integralPort)
void
setIntegralScheme(String integralScheme)
void
setRemoteServers(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, acceptSocket, getAcceptQueueSize, getAcceptorThreads, getHost, getInetAddrPort, getInetAddress, getLingerTimeSecs, getMaxReadTimeMs, getPort, getServerSocket, getTcpNoDelay, handle, handleConnection, handleConnection, newServerSocket, open, setAcceptQueueSize, setAcceptorThreads, setHost, setInetAddrPort, setInetAddress, setLingerTimeSecs, setMaxReadTimeMs, setPort, setTcpNoDelay, start, stop, stopJob, toString

Methods inherited from class org.mortbay.util.ThreadPool

getIdleThreads, getMaxIdleTimeMs, getMaxThreads, getMinThreads, getName, getPoolName, getThreads, getThreadsPriority, handle, isDaemon, isStarted, join, run, setDaemon, setMaxIdleTimeMs, setMaxStopTimeMs, setMaxThreads, setMinThreads, setName, setPoolName, setThreadsPriority, shrink, start, stop, stopJob

Constructor Details

AJP13Listener

public AJP13Listener()

AJP13Listener

public AJP13Listener(InetAddrPort address)
Construct for specific address and port.

Method Details

createConnection

protected AJP13Connection createConnection(Socket socket)
            throws IOException
Create an AJP13Connection instance. This method can be used to override the connection instance.
Parameters:
socket - The underlying socket.

customizeRequest

protected void customizeRequest(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).
Parameters:
request -

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:
customizeRequest in interface HttpListener
Parameters:
request -

getBufferReserve

public int getBufferReserve()
Specified by:
getBufferReserve in interface HttpListener

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface HttpListener

getConfidentialPort

public int getConfidentialPort()
Specified by:
getConfidentialPort in interface HttpListener

getConfidentialScheme

public String getConfidentialScheme()
Specified by:
getConfidentialScheme in interface HttpListener

getDefaultScheme

public String getDefaultScheme()
Specified by:
getDefaultScheme in interface HttpListener

getHttpHandler

public HttpHandler getHttpHandler()
Specified by:
getHttpHandler in interface HttpListener

getHttpServer

public HttpServer getHttpServer()
Specified by:
getHttpServer in interface HttpListener

getIdentifyListener

public boolean getIdentifyListener()

getIntegralPort

public int getIntegralPort()
Specified by:
getIntegralPort in interface HttpListener

getIntegralScheme

public String getIntegralScheme()
Specified by:
getIntegralScheme in interface HttpListener

getRemoteServers

public String[] getRemoteServers()
Returns:
Array of accepted remote server hostnames or IPs.

handleConnection

public void handleConnection(Socket socket)
            throws IOException
Handle Job. Implementation of ThreadPool.handle(), calls handleConnection.
Overrides:
handleConnection in interface ThreadedServer
Parameters:
socket - A Connection.

isConfidential

public boolean isConfidential(HttpConnection connection)
Specified by:
isConfidential in interface HttpListener

isIntegral

public boolean isIntegral(HttpConnection connection)
Specified by:
isIntegral in interface HttpListener

isLowOnResources

public boolean isLowOnResources()
Specified by:
isLowOnResources in interface HttpListener
Returns:
True if low on idle threads.

isOutOfResources

public boolean isOutOfResources()
Specified by:
isOutOfResources in interface HttpListener
Returns:
True if out of resources.

persistConnection

public void persistConnection(HttpConnection connection)
Persist the connection.
Specified by:
persistConnection in interface HttpListener
Parameters:
connection -

setBufferReserve

public void setBufferReserve(int size)

setBufferSize

public void setBufferSize(int size)

setConfidentialPort

public void setConfidentialPort(int confidentialPort)

setConfidentialScheme

public void setConfidentialScheme(String confidentialScheme)

setHttpHandler

public void setHttpHandler(HttpHandler handler)

setHttpServer

public void setHttpServer(HttpServer server)
Specified by:
setHttpServer in interface HttpListener

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

setIntegralPort

public void setIntegralPort(int integralPort)

setIntegralScheme

public void setIntegralScheme(String integralScheme)

setRemoteServers

public void setRemoteServers(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.
Parameters:
servers - Array of accepted remote server hostnames or IPs

start

public void start()
            throws Exception
Start the LifeCycle.
Specified by:
start in interface LifeCycle
Overrides:
start in interface ThreadedServer

stop

public void stop()
            throws InterruptedException
Stop the LifeCycle. The LifeCycle may wait for current activities to complete normally, but it can be interrupted.
Specified by:
stop in interface LifeCycle
Overrides:
stop in interface ThreadedServer

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.