Voyager ORB

com.objectspace.voyager.transport
Interface IRequestHandler


public abstract interface IRequestHandler

The IRequestHandler interface can be implemented to allow a Voyager host to recognize and process application level protocols such as VRMP, IIOP, and even HTTP.
It is assumed that a request handler can recognize its protocol by scanning the incoming stream, if not, it does nothing with the stream allowing for the next request handler in line to process the incoming data.


Method Summary
 boolean canProcess(java.io.InputStream stream)
          Allows the request handler to scan the incoming stream and determine if it can handle the incoming protocol.
Typically the header size would be read from the stream and compared to the tag.
 int getHeaderSize()
          The size in bytes of the expected tag or bytes on the stream.
 java.lang.String getTag()
          A String representation of the first bytes that uniquely identify the incoming data stream as being a particular protocol.
 void process(ITransportConnection connection, java.io.InputStream stream)
          If canProcess() returns true, this method is immediately called to handle the incoming data stream.
 

Method Detail

getTag

public java.lang.String getTag()
A String representation of the first bytes that uniquely identify the incoming data stream as being a particular protocol. For example, an IIOP handler would return "GIOP", and an HTTP handler would return "get".

getHeaderSize

public int getHeaderSize()
The size in bytes of the expected tag or bytes on the stream.

canProcess

public boolean canProcess(java.io.InputStream stream)
                   throws java.io.IOException
Allows the request handler to scan the incoming stream and determine if it can handle the incoming protocol.
Typically the header size would be read from the stream and compared to the tag. If there is a match, true should be returned, otherwise false. The transport will handle rolling back the read bytes for the next stream if this method return false for the current handler.
Throws:
java.io.IOException - Thrown if there was an error reading the stream.

process

public void process(ITransportConnection connection,
                    java.io.InputStream stream)
             throws java.io.IOException
If canProcess() returns true, this method is immediately called to handle the incoming data stream. Note that the first "header size" bytes will already have been read by the canProcess() method.
When the incoming message has been read, this method must return so that future messages can be processed in the same manner.
Throws:
java.io.IOException - Thrown if there was an error reading the stream.

ObjectSpace Inc.

(c) Copyright 1997-1999 ObjectSpace, Inc.
14850 Quorum Drive, Suite 500
Dallas, Texas 75240