com.ibm.ulc.comm
Class UlcConnection

java.lang.Object
  |
  +--com.ibm.ulc.util.UlcObject
        |
        +--com.ibm.ulc.comm.UlcConnection
Direct Known Subclasses:
ORBConnection

public abstract class UlcConnection
extends UlcObject
implements IConnection

A connection to a ULC peer. A RequestProcessor is used to pass requests coming from the peer to an event loop. The send() method allows a caller to pass a request to the peer. An instance of an UlcTransport is used for the actual communication. Incoming and outgoing communication is asynchronous.

See Also:
IRequestProcessor, UlcTransport, Serialized Form

Field Summary
static boolean fgDebug
           
static boolean fgIPAddr
           
static int INVALIDPORT
           
 
Constructor Summary
protected UlcConnection(java.lang.String urlString, IRequestProcessor rp, java.lang.String connId, java.lang.String clientData)
          Creates a connection for the given url, request processor, and connection identification data.
protected UlcConnection(UlcTransport transport, IRequestProcessor rp, java.lang.String connId, java.lang.String clientData)
          Creates a connection for the given transport, request processor, and connection identification data.
 
Method Summary
 void addRequestListener(IRequestListener listener)
          Register an IRequestListener that will be notified each time a request is sent or received.
 void close()
          Closes the connection (including the transport)
abstract  Request createRequest()
          Creates a request.
 void finalize()
           
 java.lang.String getApplicationName()
           
 java.lang.String getClientData()
           
static java.lang.String getFileFromUrlString(java.lang.String urlString)
          Helper method to extract the 'file' part from a URL string.
 java.lang.String getHost()
           
static java.lang.String getHostFromUrlString(java.lang.String urlString)
          Helper method to extract the 'host' part from a URL string.
 java.lang.String getId()
           
static java.lang.String getLocalHost()
          Helper method to return the local host either as host name or as IP address (dotted string) depending on preference set.
 java.lang.String getLocalUrlString()
          Return a URL string that identifies the local end point of the connection.
 int getPort()
           
static int getPortFromUrlString(java.lang.String urlString)
          Helper method to extract the 'port' part from a URL string.
static java.lang.String getProtocolFromUrlString(java.lang.String urlString)
          Helper method to extract the 'protocol' part from a URL string.
static java.lang.String getReferenceFromUrlString(java.lang.String urlString)
          Helper method to extract the 'reference' ('anchor') part from a URL string.
 java.lang.String getRemoteUrlString()
          Return a URL string that identifies the remote end point of the connection.
 IRequestFilter getRequestFilter()
          Returns the IRequestFilter object that is currently installed or null.
 java.util.Vector getRequestListeners()
          Returns the vector of currently registered IRequestListener objects or null.
 UlcTransport getTransport()
           
 java.lang.String getUrlString()
          Return a URL string that identifies the remote end point of the connection.
 void postRequest(Request r)
          Posts a request to the connection's request queue.
 boolean receive(Request request)
          Receives a request and posts it to the connection's request queue.
 void removeRequestListener(IRequestListener listener)
          Remove a previously registered IRequestListener
 boolean send(Request request)
          Sends a request out using the installed transport.
 void setRequestFilter(IRequestFilter filter)
          Set the IRequestFilter object that will receive all requests just before they are sent and all requests just after they are recieved.
protected abstract  void shutdownHook()
          A hook that can be overridden to add additional actions when the connection is shut down.
 void start()
          Starts the connection.
 
Methods inherited from class com.ibm.ulc.util.UlcObject
trouble, trouble2, trouble2Err, troubleErr
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fgIPAddr

public static boolean fgIPAddr

fgDebug

public static boolean fgDebug

INVALIDPORT

public static final int INVALIDPORT
Constructor Detail

UlcConnection

protected UlcConnection(UlcTransport transport,
                        IRequestProcessor rp,
                        java.lang.String connId,
                        java.lang.String clientData)
Creates a connection for the given transport, request processor, and connection identification data. Will use the given transport.
Parameters:
transport - com.ibm.ulc.comm.UlcTransport
rp - com.ibm.ulc.comm.IRequestProcessor
connId - java.lang.String
clientData - java.lang.String
See Also:
UlcTransport

UlcConnection

protected UlcConnection(java.lang.String urlString,
                        IRequestProcessor rp,
                        java.lang.String connId,
                        java.lang.String clientData)
Creates a connection for the given url, request processor, and connection identification data. Will establish a transport based on the given URL.
Parameters:
urlString - java.lang.String
rp - com.ibm.ulc.comm.IRequestProcessor
connId - java.lang.String
clientData - java.lang.String
See Also:
UlcTransport
Method Detail

addRequestListener

public void addRequestListener(IRequestListener listener)
Register an IRequestListener that will be notified each time a request is sent or received.
Specified by:
addRequestListener in interface IConnection
See Also:
IRequestListener

close

public void close()
Closes the connection (including the transport)

createRequest

public abstract Request createRequest()
Creates a request. Overridde to define the request to to be created.
Specified by:
createRequest in interface IConnection

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object

getApplicationName

public java.lang.String getApplicationName()

getClientData

public java.lang.String getClientData()

getFileFromUrlString

public static java.lang.String getFileFromUrlString(java.lang.String urlString)
Helper method to extract the 'file' part from a URL string.

getHost

public java.lang.String getHost()

getHostFromUrlString

public static java.lang.String getHostFromUrlString(java.lang.String urlString)
Helper method to extract the 'host' part from a URL string.

getId

public java.lang.String getId()

getLocalHost

public static java.lang.String getLocalHost()
Helper method to return the local host either as host name or as IP address (dotted string) depending on preference set.

getLocalUrlString

public java.lang.String getLocalUrlString()
Return a URL string that identifies the local end point of the connection.

getPort

public int getPort()

getPortFromUrlString

public static int getPortFromUrlString(java.lang.String urlString)
Helper method to extract the 'port' part from a URL string.

getProtocolFromUrlString

public static java.lang.String getProtocolFromUrlString(java.lang.String urlString)
Helper method to extract the 'protocol' part from a URL string.

getReferenceFromUrlString

public static java.lang.String getReferenceFromUrlString(java.lang.String urlString)
Helper method to extract the 'reference' ('anchor') part from a URL string.

getRemoteUrlString

public java.lang.String getRemoteUrlString()
Return a URL string that identifies the remote end point of the connection.

getRequestFilter

public IRequestFilter getRequestFilter()
Returns the IRequestFilter object that is currently installed or null.
Specified by:
getRequestFilter in interface IConnection

getRequestListeners

public java.util.Vector getRequestListeners()
Returns the vector of currently registered IRequestListener objects or null.

getTransport

public UlcTransport getTransport()

getUrlString

public java.lang.String getUrlString()
Return a URL string that identifies the remote end point of the connection.
Specified by:
getUrlString in interface IConnection

postRequest

public void postRequest(Request r)
Posts a request to the connection's request queue. Bypasses receive filters and listeners.

receive

public final boolean receive(Request request)
Receives a request and posts it to the connection's request queue. Passes the request through an installed request filter and notifies request listeners.
Specified by:
receive in interface IConnection

removeRequestListener

public void removeRequestListener(IRequestListener listener)
Remove a previously registered IRequestListener
Specified by:
removeRequestListener in interface IConnection

send

public final boolean send(Request request)
Sends a request out using the installed transport. Requests are sent asynchronously.
Specified by:
send in interface IConnection

setRequestFilter

public void setRequestFilter(IRequestFilter filter)
Set the IRequestFilter object that will receive all requests just before they are sent and all requests just after they are recieved.
Specified by:
setRequestFilter in interface IConnection
See Also:
IRequestFilter

shutdownHook

protected abstract void shutdownHook()
A hook that can be overridden to add additional actions when the connection is shut down.

start

public void start()
           throws UlcTransportException
Starts the connection. After this method, requests can be sent and are received using the installed transport.