Sun Adapter for TCP/IP HL7

com.stc.connector.tcpip.model.client
Class TCPIPApplicationConnection

java.lang.Object
  extended by com.stc.connector.tcpip.model.client.TCPIPApplicationConnection
All Implemented Interfaces:
com.stc.connector.appconn.common.ApplicationConnection, com.stc.connector.framework.client.AssociateableHandle

public class TCPIPApplicationConnection
extends java.lang.Object
implements com.stc.connector.appconn.common.ApplicationConnection, com.stc.connector.framework.client.AssociateableHandle

This class implements the ApplicationConnection interface for the TCPIP Application Connection.

Version:
cvs revision: $Revision: 1.11 $ Last Modified: $Date: 2008/04/23 07:15:12 $
Author:
Harry Liu

Field Summary
static java.lang.String version
           
 
Constructor Summary
TCPIPApplicationConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mcCallback)
          Creates a new instance of TCPIPApplicationConnection.
 
Method Summary
 int available()
          returns the length of the data if it is available to read
 boolean checkIfClosed()
          Checks whether the Connection instance was already closed (if close was previously called).
 void close()
          Closes the application connection handle.
 java.lang.Object createApplication(java.lang.String appName)
          Creates an Application from the Application Connection.
 com.stc.connector.appconn.common.OutputHandler createOutputHandler()
          Creates an OutputHandler for "sending" data to the EIS.
 void destroy()
          Destroys the application connection handle and the associated physical connection.
 TCPIPEwayConnection getEwayConnection()
          Gets the TCPIPEwayConnection associated with this application connection.
 byte[] getLeftOverFromLastRead()
          returns the data left over from last read
 com.stc.connector.framework.eway.ManagedConnectionCallback getManagedConnectionCallback()
           
 java.net.Socket getSocket()
          Gets the Socket associated with this application connection.
 State getState()
           
 void invalidateConnection()
          This is called by the ManagedConnection to invalidate the connection handle.
 boolean isUsedByBPEL()
          Returns the usedByBPEL.
 void reassociateConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
          This is called by the ManagedConnection to associate the connection handle to the ManagedConnection.
 void setLeftOverFromLastRead(byte[] bs)
          sets the data which is left over from last read
 void setManagedConnectionCallback(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
           
 void setState(State state)
           
 void setUsedByBPEL(boolean usedByBPEL)
          Sets the usedByBPEL.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values
Constructor Detail

TCPIPApplicationConnection

public TCPIPApplicationConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mcCallback)
Creates a new instance of TCPIPApplicationConnection.

Parameters:
mcCallback - The ManagedConnectionCallback for getting services from ManagedConnection.
Method Detail

close

public void close()
           throws TCPIPApplicationConnectionException
Closes the application connection handle. Once the close method is called, using the application created from the application connection must be forbidden and must result in an ApplicationConnectionException. The association between an application connection and the application is implementation specific.

Specified by:
close in interface com.stc.connector.appconn.common.ApplicationConnection
Throws:
TCPIPApplicationConnectionException - upon error.
See Also:
ApplicationConnection.close()

destroy

public void destroy()
             throws TCPIPApplicationConnectionException
Destroys the application connection handle and the associated physical connection. The container will remove the corresponding connection from the connection pool, so it won't be matched/picked-up again by the containner.

Throws:
TCPIPApplicationConnectionException - upon error.

createApplication

public java.lang.Object createApplication(java.lang.String appName)
                                   throws TCPIPApplicationException
Creates an Application from the Application Connection. The application is an API which can be used to interact with the underlying EIS. The application API must be invalidated once the close method is called on the Application Connection. If null is passed for the application name, then the default application will be created. Otherwise, the application name will be used to create the appropriate connection.

Specified by:
createApplication in interface com.stc.connector.appconn.common.ApplicationConnection
Parameters:
appName - The name of the application to create.
Returns:
A java.lang.Object representing the EIS specific application component to interact with the EIS.
Throws:
TCPIPApplicationException - upon error.
See Also:
ApplicationConnection.createApplication(String)

createOutputHandler

public com.stc.connector.appconn.common.OutputHandler createOutputHandler()
                                                                   throws TCPIPApplicationException
Creates an OutputHandler for "sending" data to the EIS. If the eWay does not support an OutputHandler, then it should return null for its implementation of this method.

Specified by:
createOutputHandler in interface com.stc.connector.appconn.common.ApplicationConnection
Returns:
The eWay specific OutputHandler for handling "sending" data to the external system or null if the eWay does not have an OutputHandler.
Throws:
TCPIPApplicationException - upon error.
See Also:
ApplicationConnection.createOutputHandler()

invalidateConnection

public void invalidateConnection()
                          throws javax.resource.ResourceException
This is called by the ManagedConnection to invalidate the connection handle.

Specified by:
invalidateConnection in interface com.stc.connector.framework.client.AssociateableHandle
Throws:
javax.resource.ResourceException - upon error.
See Also:
AssociateableHandle.invalidateConnection()

reassociateConnection

public void reassociateConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
                           throws javax.resource.ResourceException
This is called by the ManagedConnection to associate the connection handle to the ManagedConnection. The implementation should disassociate the associated ManagedConnection and associate itself to the ManagedConnection passed in as the argument.

Specified by:
reassociateConnection in interface com.stc.connector.framework.client.AssociateableHandle
Parameters:
mc - The ManagedConnection instance with which the connection handle will associate.
Throws:
javax.resource.ResourceException - upon error.
See Also:
AssociateableHandle.reassociateConnection(ManagedConnectionCallback)

checkIfClosed

public boolean checkIfClosed()
Checks whether the Connection instance was already closed (if close was previously called).

Returns:
true if already closed, false otherwise.

getSocket

public java.net.Socket getSocket()
Gets the Socket associated with this application connection.

Returns:
The Socket instance associated with this application connection.

getEwayConnection

public TCPIPEwayConnection getEwayConnection()
Gets the TCPIPEwayConnection associated with this application connection.

Returns:
The TCPIPEwayConnection instance associated with this application connection.

isUsedByBPEL

public boolean isUsedByBPEL()
Returns the usedByBPEL.

Returns:
boolean

setUsedByBPEL

public void setUsedByBPEL(boolean usedByBPEL)
Sets the usedByBPEL.

Parameters:
usedByBPEL - The usedByBPEL to set

getState

public State getState()
Returns:
the state

setState

public void setState(State state)
Parameters:
state - the state to be set

getManagedConnectionCallback

public com.stc.connector.framework.eway.ManagedConnectionCallback getManagedConnectionCallback()
Returns:
the ManagedConnectionCallback

setManagedConnectionCallback

public void setManagedConnectionCallback(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
Parameters:
mc - ManagedConnectionCallback to be set

getLeftOverFromLastRead

public byte[] getLeftOverFromLastRead()
returns the data left over from last read

Returns:
the data left over from last read

setLeftOverFromLastRead

public void setLeftOverFromLastRead(byte[] bs)
sets the data which is left over from last read

Parameters:
bs - data which is left over from last read

available

public int available()
              throws TCPIPApplicationException,
                     java.io.IOException
returns the length of the data if it is available to read

Returns:
an integer representing the length of available data
Throws:
TCPIPApplicationException
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

Sun Adapter for TCP/IP HL7