com.infoengine.connector
Class IeManagedConnection

java.lang.Object
  extended bycom.infoengine.connector.IeManagedConnection
All Implemented Interfaces:
javax.resource.spi.ManagedConnection

public class IeManagedConnection
extends Object
implements javax.resource.spi.ManagedConnection

As far as JCA is concerned this class respresents a physical connection to the underlying EIS (Info*Engine/Windchill). In actuality the physical connection has been abstracted further with the PhyscalConnection abstract class since interactions with Info*Engine over SOAP can occur via HTTP and possibly JMS (today, maybe other protocols in the future). IeConnection is the CCI connection class that represents a connection handle to a managed connection. Connection handles are actually what applications are given and can use to interact with the underlying EIS.

See Also:
PhysicalConnection, IeConnection

Field Summary
private  Vector cxEventListeners
           
private  javax.resource.spi.ConnectionRequestInfo cxRequestInfo
           
private  Vector handles
           
private  Log log
           
private  PrintWriter logWriter
           
private  IeManagedConnectionMetaData metadata
           
private  PhysicalConnection physicalConnection
           
private  Subject subject
           
private  IeSPILocalTransaction transaction
           
 
Constructor Summary
(package private) IeManagedConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo, Log l)
          create a new IeManagedConnection
 
Method Summary
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          add a connection event listener.
 void associateConnection(Object connection)
          associate a connection handle with this managed connection.
 void cleanup()
          cleanup this managed connection so that it can be placed back in a connection pool and is ready to be used again.
private  void createPhysicalConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
          actually create the underlying physical connection could be HTTP or JMS or ...
 void destroy()
          close the physical connection exceptions are grounded out.
(package private)  void fireConnectionClosed(IeConnection cx)
          notify event listeners that the underlying handle has been closed and this ManagedConnection can be returned to the pool or destroyed.
(package private)  void fireConnectionErrorOccurred(Exception ex)
          notify event listeners that a fatal connection error has occurred so the container can do some clean up, remove this ManagedConnection from its pool and destroy it.
(package private)  void fireTransactionCommitted(IeConnection cx)
          notify event listeners that a transaction has been committed.
(package private)  void fireTransactionRolledback(IeConnection cx)
          notify event listeners that a transaction has been rolled back.
(package private)  void fireTransactionStarted(IeConnection cx)
          notify event listeners that a transaction has started.
 Object getConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
          create a new "handle" to this physical connection
 javax.resource.spi.LocalTransaction getLocalTransaction()
          get the SPI LocalTransaction object.
 PrintWriter getLogWriter()
          get the PrintWriter associated with this managed connection
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
          get metadata about this physical connection
(package private)  PhysicalConnection getPhysicalConnection()
          get the underlying PhysicalConnection object
 XAResource getXAResource()
          XAResource not supported.
(package private)  boolean match(Subject s, javax.resource.spi.ConnectionRequestInfo cri)
          does the underlying physical connection match these criteria?
private  void reInitialize(Subject s, javax.resource.spi.ConnectionRequestInfo cri)
          re-initialize the underly physical connection with some new criteria.
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          remove a previously registered ConnectionEventListener
 void setLogWriter(PrintWriter out)
          set the PrintWriter this managed connection will use to write info to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cxEventListeners

private Vector cxEventListeners

handles

private Vector handles

logWriter

private PrintWriter logWriter

metadata

private IeManagedConnectionMetaData metadata

subject

private Subject subject

cxRequestInfo

private javax.resource.spi.ConnectionRequestInfo cxRequestInfo

physicalConnection

private PhysicalConnection physicalConnection

transaction

private IeSPILocalTransaction transaction

log

private Log log
Constructor Detail

IeManagedConnection

IeManagedConnection(Subject subject,
                    javax.resource.spi.ConnectionRequestInfo cxRequestInfo,
                    Log l)
              throws javax.resource.ResourceException
create a new IeManagedConnection

Parameters:
subject - the credentials object (may be null, not null in "Container managed sign on" scenario)
cxRequestInfo - connection request info
l - Log
Throws:
javax.resource.ResourceException
Method Detail

addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
add a connection event listener. called by the ConnectionManager so that it can be informed of connection and transaction related events.

Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - the listener to be notified of events

associateConnection

public void associateConnection(Object connection)
                         throws javax.resource.ResourceException
associate a connection handle with this managed connection. the connection object must be an instance of IeConnection or a ClassCastException will occur.

Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection
Parameters:
connection - the connection handle to associcate with this managed connection
Throws:
javax.resource.ResourceException - if there's a problem with the association
ClassCastException - if connection is not an instance of IeConnection

cleanup

public void cleanup()
             throws javax.resource.ResourceException
cleanup this managed connection so that it can be placed back in a connection pool and is ready to be used again.

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

destroy

public void destroy()
             throws javax.resource.ResourceException
close the physical connection exceptions are grounded out.

Specified by:
destroy in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

getConnection

public Object getConnection(Subject subject,
                            javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
                     throws javax.resource.ResourceException
create a new "handle" to this physical connection

Specified by:
getConnection in interface javax.resource.spi.ManagedConnection
Parameters:
subject - security credentials (may be null)
cxRequestInfo - connection request info (may be null)
Returns:
Object (instance of IeConnection)
Throws:
javax.resource.ResourceException - if an error occurs when creating the connection handle
javax.resource.spi.SecurityException - if subject or cxRequestInfo has changed as re-authentication is not supported (cannot re-authenticate a JMS connection)

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
get the SPI LocalTransaction object. this object is used by an application server to automatically demarcate transactions for EJBs.

Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection
Returns:
LocalTransaction
Throws:
javax.resource.ResourceException - (not really)

getLogWriter

public PrintWriter getLogWriter()
                         throws javax.resource.ResourceException
get the PrintWriter associated with this managed connection

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection
Returns:
PrintWriter
Throws:
javax.resource.ResourceException - (not really)

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
get metadata about this physical connection

Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection
Returns:
ManagedConnectionMetaData
Throws:
javax.resource.ResourceException

getXAResource

public XAResource getXAResource()
                         throws javax.resource.ResourceException
XAResource not supported. NotSupportedException is always thrown. JTA transactions are not supported resource adapter claims "LocalTransaction" support only. No need for extra over-head of JTA transactions when Windchill does not support 2PC.

Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException
javax.resource.NotSupportedException - (always)

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
remove a previously registered ConnectionEventListener

Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - the listener to unregister

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws javax.resource.ResourceException
set the PrintWriter this managed connection will use to write info to.

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection
Parameters:
out - the PrintWriter the connection should write to.
Throws:
javax.resource.ResourceException - (not really)

fireConnectionClosed

void fireConnectionClosed(IeConnection cx)
notify event listeners that the underlying handle has been closed and this ManagedConnection can be returned to the pool or destroyed.

Parameters:
cx - the connection handle

fireConnectionErrorOccurred

void fireConnectionErrorOccurred(Exception ex)
notify event listeners that a fatal connection error has occurred so the container can do some clean up, remove this ManagedConnection from its pool and destroy it.

Parameters:
ex - Exception that occurred

fireTransactionStarted

void fireTransactionStarted(IeConnection cx)
notify event listeners that a transaction has started. this event occurs when an application is manually managing a transaction. the call back is necessary so that the application server always knows the state of transactions that it may be required to manage.

Parameters:
cx - the connection handle

fireTransactionCommitted

void fireTransactionCommitted(IeConnection cx)
notify event listeners that a transaction has been committed. this event occurs when an application is manually managing a transaction. the call back is necessary so that the application server always knows the state of transactions that it may be required to manage.

Parameters:
cx - the connection handle

fireTransactionRolledback

void fireTransactionRolledback(IeConnection cx)
notify event listeners that a transaction has been rolled back. this event occurs when an application is manually managing a transaction. the call back is necessary so that the application server always knows the state of transactions that it may be required to manage.

Parameters:
cx - the connection handle

match

boolean match(Subject s,
              javax.resource.spi.ConnectionRequestInfo cri)
        throws PrivilegedActionException
does the underlying physical connection match these criteria?

Parameters:
s - security credentials
cri - connection request info
Returns:
boolean
Throws:
PrivilegedActionException

reInitialize

private void reInitialize(Subject s,
                          javax.resource.spi.ConnectionRequestInfo cri)
                   throws javax.resource.ResourceException
re-initialize the underly physical connection with some new criteria. since re-authentication is not supported this is only called when the connection is initially created.

Parameters:
s - security credentials ("container managed sign on")
cri - connection request info
Throws:
javax.resource.ResourceException - if something bad happens

createPhysicalConnection

private void createPhysicalConnection(Subject subject,
                                      javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
                               throws javax.resource.ResourceException
actually create the underlying physical connection could be HTTP or JMS or ...

Parameters:
subject - security credentials ("container managed sign on")
cxRequestInfo - connection request info
Throws:
javax.resource.ResourceException - if something bad happens

getPhysicalConnection

PhysicalConnection getPhysicalConnection()
get the underlying PhysicalConnection object

Returns:
PhysicalConnection