org.aselect.system.communication.server
Class TCPProtocolRequest

java.lang.Object
  extended by org.aselect.system.communication.server.TCPProtocolRequest
All Implemented Interfaces:
IProtocolRequest

public class TCPProtocolRequest
extends java.lang.Object
implements IProtocolRequest

Wrapper to communicate transparent to an incoming Socket request.

Description:
The TCPProtocolRequest reads headers and other information from an input stream and places this information in a Hashtable. The headers can be retrieved by calling the getProperty() method.

The TCPProtocolRequest can be used in the Communicator and Message creators. The getProtocolName() method can be used to switch between SOAP12 communication, currently used raw communication, or other protocols that use TCP as a underlying transport protocol.

Concurrency issues:
Every request should have its own TCPProtocolRequest instance.

Author:
Alfa & Ariss

Constructor Summary
TCPProtocolRequest(java.net.Socket oRequestSocket)
          Create a new instance.
 
Method Summary
 java.io.InputStream getInputStream()
          Get the input stream to the request after stripping the headers.
 java.lang.String getMessage()
          Get the request data.
 java.lang.String getProperty(java.lang.String sName)
          Retrieve a property of the request.
 java.lang.String getProtocolName()
          Retrieve the name of the protocol.
 java.lang.String getTarget()
          Retrieve the full local address with port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPProtocolRequest

public TCPProtocolRequest(java.net.Socket oRequestSocket)
                   throws java.io.IOException
Create a new instance.

Description:
Creates a new wrapper for oRequestSocket. All protocol data (e.g. headers) is extracted from the socket and buffered.

Concurrency issues:
-

Preconditions:
oRequestSocket should be connected to a server of some kind. Request data should be available.

Postconditions:
The headers are read from the Socket the remaining data (if available) is the actual request data.

Parameters:
oRequestSocket - The Socket with the incoming request.
Throws:
java.io.IOException - If reading from the socket fails.
Method Detail

getProtocolName

public java.lang.String getProtocolName()
Retrieve the name of the protocol.

Specified by:
getProtocolName in interface IProtocolRequest
Returns:
the full name of the protocol
See Also:
IProtocolRequest.getProtocolName()

getProperty

public java.lang.String getProperty(java.lang.String sName)
Retrieve a property of the request.

Specified by:
getProperty in interface IProtocolRequest
Parameters:
sName - The property name.
Returns:
The propery value.
See Also:
IProtocolRequest.getProperty(java.lang.String)

getTarget

public java.lang.String getTarget()
Retrieve the full local address with port.

Specified by:
getTarget in interface IProtocolRequest
Returns:
the full URL of the target of the request.
See Also:
IProtocolRequest.getTarget()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get the input stream to the request after stripping the headers.

Description:
This class returns a ByteArrayInputStream. The alternative StringBufferInputStream is deprecated:
This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the StringReader class.
Because the StringReader is not an InputStream,ByteArrayInputStream is used.

Specified by:
getInputStream in interface IProtocolRequest
Returns:
InputStream from which the incomming message can be retrieved.
Throws:
java.io.IOException - if InputStream can't be retrieved from the protocol.
See Also:
IProtocolRequest.getInputStream(), ByteArrayInputStream

getMessage

public java.lang.String getMessage()
Get the request data.

Specified by:
getMessage in interface IProtocolRequest
Returns:
The request data as String.
See Also:
IProtocolRequest.getMessage()


Copyright © 2008 SURFnet BV. All Rights Reserved.