winstone.ajp13
Class Ajp13Listener

java.lang.Object
  extended by winstone.ajp13.Ajp13Listener
All Implemented Interfaces:
java.lang.Runnable, Listener

public class Ajp13Listener
extends java.lang.Object
implements Listener, java.lang.Runnable

Implements the main listener daemon thread. This is the class that gets launched by the command line, and owns the server socket, etc.

Version:
$Id: Ajp13Listener.java,v 1.12 2006/03/24 17:24:22 rickknowles Exp $
Author:
mailto: Rick Knowles

Field Summary
static WinstoneResourceBundle AJP_RESOURCES
           
 
Constructor Summary
Ajp13Listener(java.util.Map args, ObjectPool objectPool, HostGroup hostGroup)
          Constructor
 
Method Summary
 void allocateRequestResponse(java.net.Socket socket, java.io.InputStream inSocket, java.io.OutputStream outSocket, RequestHandlerThread handler, boolean iAmFirst)
          Called by the request handler thread, because it needs specific setup code for this connection's protocol (ie construction of request/response objects, in/out streams, etc).
 void deallocateRequestResponse(RequestHandlerThread handler, WinstoneRequest req, WinstoneResponse rsp, WinstoneInputStream inData, WinstoneOutputStream outData)
          Called by the request handler thread, because it needs specific shutdown code for this connection's protocol (ie releasing input/output streams, etc).
 void destroy()
          Interrupts the listener thread.
 java.lang.String parseURI(RequestHandlerThread handler, WinstoneRequest req, WinstoneResponse rsp, WinstoneInputStream inData, java.net.Socket socket, boolean iAmFirst)
          This is kind of a hack, since we have already parsed the uri to get the input stream.
 boolean processKeepAlive(WinstoneRequest request, WinstoneResponse response, java.io.InputStream inSocket)
          Tries to wait for extra requests on the same socket.
 void releaseSocket(java.net.Socket socket, java.io.InputStream inSocket, java.io.OutputStream outSocket)
          Called by the request handler thread, because it needs specific shutdown code for this connection's protocol if the keep-alive period expires (ie closing sockets, etc).
 void run()
          The main run method.
 boolean start()
          After the listener is loaded and initialized, this starts the thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AJP_RESOURCES

public static final WinstoneResourceBundle AJP_RESOURCES
Constructor Detail

Ajp13Listener

public Ajp13Listener(java.util.Map args,
                     ObjectPool objectPool,
                     HostGroup hostGroup)
Constructor

Method Detail

start

public boolean start()
              throws java.io.IOException
Description copied from interface: Listener
After the listener is loaded and initialized, this starts the thread

Specified by:
start in interface Listener
Throws:
java.io.IOException

run

public void run()
The main run method. This handles the normal thread processing.

Specified by:
run in interface java.lang.Runnable

destroy

public void destroy()
Interrupts the listener thread. This will trigger a listener shutdown once the so timeout has passed.

Specified by:
destroy in interface Listener

allocateRequestResponse

public void allocateRequestResponse(java.net.Socket socket,
                                    java.io.InputStream inSocket,
                                    java.io.OutputStream outSocket,
                                    RequestHandlerThread handler,
                                    boolean iAmFirst)
                             throws java.net.SocketException,
                                    java.io.IOException
Called by the request handler thread, because it needs specific setup code for this connection's protocol (ie construction of request/response objects, in/out streams, etc). This implementation parses incoming AJP13 packets, and builds an outputstream that is capable of writing back the response in AJP13 packets.

Specified by:
allocateRequestResponse in interface Listener
Throws:
java.net.SocketException
java.io.IOException

deallocateRequestResponse

public void deallocateRequestResponse(RequestHandlerThread handler,
                                      WinstoneRequest req,
                                      WinstoneResponse rsp,
                                      WinstoneInputStream inData,
                                      WinstoneOutputStream outData)
Called by the request handler thread, because it needs specific shutdown code for this connection's protocol (ie releasing input/output streams, etc).

Specified by:
deallocateRequestResponse in interface Listener

parseURI

public java.lang.String parseURI(RequestHandlerThread handler,
                                 WinstoneRequest req,
                                 WinstoneResponse rsp,
                                 WinstoneInputStream inData,
                                 java.net.Socket socket,
                                 boolean iAmFirst)
                          throws java.io.IOException
This is kind of a hack, since we have already parsed the uri to get the input stream. Just pass back the request uri

Specified by:
parseURI in interface Listener
Throws:
java.io.IOException

releaseSocket

public void releaseSocket(java.net.Socket socket,
                          java.io.InputStream inSocket,
                          java.io.OutputStream outSocket)
                   throws java.io.IOException
Called by the request handler thread, because it needs specific shutdown code for this connection's protocol if the keep-alive period expires (ie closing sockets, etc). This implementation simply shuts down the socket and streams.

Specified by:
releaseSocket in interface Listener
Throws:
java.io.IOException

processKeepAlive

public boolean processKeepAlive(WinstoneRequest request,
                                WinstoneResponse response,
                                java.io.InputStream inSocket)
Tries to wait for extra requests on the same socket. If any are found before the timeout expires, it exits with a true, indicating a new request is waiting. If the timeout expires, return a false, instructing the handler thread to begin shutting down the socket and relase itself.

Specified by:
processKeepAlive in interface Listener


Copyright © 2013. All Rights Reserved.