org.iperg.part.core
Class IpHttpConnection

java.lang.Object
  extended by org.iperg.part.core.IpConnection
      extended by org.iperg.part.core.IpHttpConnection
All Implemented Interfaces:
java.lang.Runnable

public class IpHttpConnection
extends IpConnection

The IpHttpConnection class implements a PART HTTP protocol connection.

Version:
1.0.0 Initial version
Author:
Olov Stahl - olovs@sics.se

Field Summary
 
Fields inherited from class org.iperg.part.core.IpConnection
BROKEN, CLOSED_LOCALLY, CLOSED_REMOTELY, CONNECTED, CONNECTING, LISTEN, UNCONNECTED
 
Constructor Summary
IpHttpConnection()
          Create an unconnected HTTP connection object
IpHttpConnection(IpUrl url)
          Create an connected HTTP connection object representing the server side.
 
Method Summary
protected  boolean _outgoingEventsAreCached()
          Check if events sent via the send method are cached locally.
protected  void _send(IpNetworkEvent event)
          Send an event to the remote process.
protected  void close()
          Close the connection
 void insertEvent(IpNetworkEvent event)
          Insert an event, "pretending" that is was received by the connection.
protected  IpConnection protoAccept()
          Accept a incoming connection on the server socket opened by protoListen.
protected  void protoConnect(IpUrl url)
          Connect to a network address represented by an url.
protected  IpUrl protoListen(IpUrl url)
          Method to be implemented by sub-classes.
 void writeCachedEvents(java.io.OutputStream out)
          Can be used on a server side connection to write all cached events to an output stream.
 
Methods inherited from class org.iperg.part.core.IpConnection
getConnectionUrl, getRemoteProcessId, getSilence, getStatus, getTotalBytesReceived, getTotalBytesSent, getUrl, notifyBrokenConnection, notifyBytesReceived, notifyBytesSent, notifyReceivedEvent, run, setInputStream, setOutputStream, setUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IpHttpConnection

public IpHttpConnection()
Create an unconnected HTTP connection object


IpHttpConnection

public IpHttpConnection(IpUrl url)
Create an connected HTTP connection object representing the server side.

Method Detail

protoConnect

protected void protoConnect(IpUrl url)
                     throws IpInvalidUrlException,
                            java.io.IOException
Connect to a network address represented by an url. The url syntax should be 'http://host:port'. Port 80 will be used if no port is part of the URL.

Specified by:
protoConnect in class IpConnection
Parameters:
url - A url representing a remote address
Throws:
IpInvalidUrlException - if the url protocol matches the connection factory protocol but url is somehow invalid, e.g., doesn't identify a remote address
java.io.IOException - if a factory specific error occured

protoListen

protected IpUrl protoListen(IpUrl url)
                     throws IpInvalidUrlException,
                            java.io.IOException
Description copied from class: IpConnection
Method to be implemented by sub-classes. Start listening for connection attempts on local address specified by the given url.

Specified by:
protoListen in class IpConnection
Parameters:
url - A url identifying a local address
Returns:
A url that a remote process can use to connect to the local address
Throws:
IpInvalidUrlException - if the url parameter is invalid, e.g., doesn't identify a local address
java.io.IOException - if a protocol specific error occured

writeCachedEvents

public void writeCachedEvents(java.io.OutputStream out)
Can be used on a server side connection to write all cached events to an output stream.

Parameters:
out - The output stream

protoAccept

protected IpConnection protoAccept()
                            throws java.io.IOException
Accept a incoming connection on the server socket opened by protoListen. Is called by IpConnection.

Specified by:
protoAccept in class IpConnection
Throws:
java.io.IOException

close

protected void close()
              throws java.io.IOException
Close the connection

Specified by:
close in class IpConnection
Throws:
java.io.IOException - if the close failed for some reason

insertEvent

public void insertEvent(IpNetworkEvent event)
Insert an event, "pretending" that is was received by the connection. Is used on the server side where incoming events are first received by a PART servlet and then inserted into the correct connection.

Parameters:
event - The event that is to be inserted

_send

protected void _send(IpNetworkEvent event)
              throws java.io.IOException
Send an event to the remote process.

Overrides:
_send in class IpConnection
Parameters:
event - The event to send
Throws:
java.io.IOException - if a protocol specific error occured

_outgoingEventsAreCached

protected boolean _outgoingEventsAreCached()
Check if events sent via the send method are cached locally.

Specified by:
_outgoingEventsAreCached in class IpConnection