php.java.bridge
Class Request

java.lang.Object
  extended by php.java.bridge.Request
All Implemented Interfaces:
IDocHandler

public final class Request
extends java.lang.Object
implements IDocHandler

This class is used to handle requests from the front-end.

Author:
jostb

Nested Class Summary
static class Request.AbortException
          This exception isn't an exception but a construct to emulate a one-shot continuation in Java.
 
Constructor Summary
Request(JavaBridge bridge)
          Creates an empty request object.
 
Method Summary
 boolean begin(php.java.bridge.ParserTag[] tag)
          Called for each <tag arg1 ...
 void end(php.java.bridge.ParserString[] string)
          Called for each </tag>
 boolean handleOneRequest()
          Start handling one request.
 void handleRequests()
          Start handling requests until EOF.
 void init(byte ch)
          This method must be called with the current header option byte.
 boolean init(java.io.InputStream in, java.io.OutputStream out)
          This method must be called with the current input and output streams.
 void parseHeader(java.io.InputStream in)
          Called for the header
 void recycle()
          re-initialize for new requests
 void reset()
          Reset the internal state so that a new input and output stream can be used for the next packed.
 void setBridge(JavaBridge bridge)
          Set a temporary bridge into this request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Request

public Request(JavaBridge bridge)
Creates an empty request object.

Parameters:
bridge - The bridge instance.
See Also:
init(InputStream, OutputStream)
Method Detail

init

public void init(byte ch)
This method must be called with the current header option byte. It initializes the request object.

Parameters:
ch - the current php options.

init

public boolean init(java.io.InputStream in,
                    java.io.OutputStream out)
             throws java.io.IOException
This method must be called with the current input and output streams. It reads the protocol header and initializes the request object.

Parameters:
in - The input stream.
out - The output stream.
Returns:
true, if the protocol header was valid, false otherwise.
Throws:
java.io.IOException

begin

public boolean begin(php.java.bridge.ParserTag[] tag)
Called for each <tag arg1 ... argn>

Specified by:
begin in interface IDocHandler
Parameters:
tag - The tag and the args.
Returns:
true, if the parser should stop after reading the top-level end tag, false otherwise. Implements a short path: Set this to true, if you already know that the current top-level request doesn't need a reply.

end

public void end(php.java.bridge.ParserString[] string)
Called for each </tag>

Specified by:
end in interface IDocHandler
Parameters:
string - The tag and the args.
See Also:
IDocHandler.begin(ParserTag[])

handleRequests

public void handleRequests()
                    throws java.io.IOException
Start handling requests until EOF. Creates a response object and handles all packets.

Throws:
java.io.IOException

handleOneRequest

public boolean handleOneRequest()
                         throws java.io.IOException
Start handling one request. Creates a response object and handles one packet.

Throws:
java.io.IOException

reset

public void reset()
Reset the internal state so that a new input and output stream can be used for the next packed. Note that request options (from init()) remain valid.

See Also:
init(InputStream, OutputStream)

setBridge

public void setBridge(JavaBridge bridge)
Set a temporary bridge into this request. The bridge and its associated session-/contextFactory will be automatically destroyed when the request is done.

Parameters:
bridge - The fresh bridge and its ContextFactory
See Also:
IContextFactory.recycle(String)

recycle

public void recycle()
re-initialize for new requests


parseHeader

public void parseHeader(java.io.InputStream in)
                 throws java.io.IOException
Called for the header

Specified by:
parseHeader in interface IDocHandler
Parameters:
in - the input stream
Throws:
java.io.IOException