com.mulesoft.adapter.ra
Class SPIManagedConnection

java.lang.Object
  extended by com.mulesoft.adapter.ra.SPIManagedConnection
All Implemented Interfaces:
Serializable, javax.resource.spi.ManagedConnection

public class SPIManagedConnection
extends Object
implements javax.resource.spi.ManagedConnection, Serializable

A SpiManagedConnection represents a physical, managed connection from the resource adapter to the connected external system. In this sample resource adapter it represents a simple file.

See Also:
Serialized Form

Method Summary
 void addCciConnection(CCIConnection cciCon)
          Adds a CCI connection in order to operate on this managed connection (ra implementation specific)
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Store a new connection event listener (instantiated by the (J2EE server) container) for this managed connection.
 void associateConnection(Object connection)
          Associate a previously created CCI connection to this managed connection (SPI JCA 1.0)
 void cleanup()
          Cleanups this managed connection.
 IPILogger createLogger(com.sap.engine.interfaces.messaging.api.Message message)
           
 void destroy()
          Destroys the underlying physical connection (i.e.
 Object getConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo info)
          Returns a CCI connection that operates on this managed connection.
 javax.resource.spi.LocalTransaction getLocalTransaction()
          Get the JCA local transaction if this kind of transaction is supported by the adapter.
 PrintWriter getLogWriter()
          Gets the JCA J2EE logwriter PrintWriter object.
 javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
          Returns the associated ManagedConnectionFactory (ra implementation specific)
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
          Returns the descriptive and configuration data for this managed connection as ManagedConnectionMetaData.
 PIModule getModule()
           
 boolean getSupportsLocalTx()
          Returns true if local transactions are supported.
 XAResource getXAResource()
          Get the two-way JTA transaction if this kind of transaction is supported by the adapter.
 void removeCciConnection(CCIConnection cciCon)
          Removes a CCI connection which operates on this managed connection (ra implementation specific)
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Remove a connection event listener (instantiated by the (J2EE server) container) from this managed connection.
 void sendEvent(int eventType, Exception ex)
          Sends a ConnectionEvent to all registered ConnectionEventListeners.
 void sendEvent(int eventType, Exception ex, Object connectionHandle)
          Sends a ConnectionEvent to all registered ConnectionEventListeners.
 void setLogWriter(PrintWriter out)
          Sets the JCA J2EE logwriter PrintWriter object.
 void setManagedConnectionFactory(SPIManagedConnectionFactory mcf)
          Assignes this ManagedConnection to a (new) ManagedConnectionFactory (ra implementation specific)
 void setSupportsLocalTx(boolean ltx)
          Switches on the support of local transactions.
 void start()
          Propagates the start request to the mcf (ra implementation specific)
 void stop()
          Propagates the stop request to the mcf (ra implementation specific)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createLogger

public IPILogger createLogger(com.sap.engine.interfaces.messaging.api.Message message)

getModule

public final PIModule getModule()

setSupportsLocalTx

public void setSupportsLocalTx(boolean ltx)
                        throws javax.resource.NotSupportedException
Switches on the support of local transactions. (ra implementation specific)

Parameters:
ltx - True, if local transactions must be supported, else false. Must be false currently.
Throws:
javax.resource.NotSupportedException - If supportsLocalTx equals true since local transactions are currently not supported

getSupportsLocalTx

public boolean getSupportsLocalTx()
Returns true if local transactions are supported. (ra implementation specific)

Returns:
true, if local transactions are supported, else false

setManagedConnectionFactory

public void setManagedConnectionFactory(SPIManagedConnectionFactory mcf)
Assignes this ManagedConnection to a (new) ManagedConnectionFactory (ra implementation specific)

Parameters:
mcf - ManagedConnectionFactory to which this connection must be assigned to

getManagedConnectionFactory

public javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
Returns the associated ManagedConnectionFactory (ra implementation specific)

Returns:
Associated ManagedConnectionFactory

getConnection

public Object getConnection(Subject subject,
                            javax.resource.spi.ConnectionRequestInfo info)
                     throws javax.resource.ResourceException
Returns a CCI connection that operates on this managed connection. The CciConnection object is always created newly. The credentials must be equal to the one which was used when the ManagedConnectionFactory was created. (SPI JCA 1.0)

Specified by:
getConnection in interface javax.resource.spi.ManagedConnection
Returns:
CCI connection for the XI AF to work with
Throws:
SecurityException - Subject does not fit to the original specified credentials
javax.resource.ResourceException - CCI connection cannot be created
IllegalStateException - Managed connection is already destroyed

destroy

public void destroy()
             throws javax.resource.ResourceException
Destroys the underlying physical connection (i.e. the output file is closed) and invalidates the registered CCI connections. This managed connection cannot be used further more. (SPI JCA 1.0)

Specified by:
destroy in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - CCI connection cannot be invalidated or file cannot be closed

cleanup

public void cleanup()
             throws javax.resource.ResourceException
Cleanups this managed connection. The current output file is closed if file mode is set to "new". It invalidates the registered CCI connections. This managed connection can be be used later, but writes to another file than before. (SPI JCA 1.0)

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - CCI connection cannot be invalidated or file cannot be closed

associateConnection

public void associateConnection(Object connection)
                         throws javax.resource.ResourceException
Associate a previously created CCI connection to this managed connection (SPI JCA 1.0)

Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection
Parameters:
connection - CciConnection which has to be assigned to this managed connection
Throws:
IllegalStateException - connection is not instanceof CciConnection
javax.resource.ResourceException

addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Store a new connection event listener (instantiated by the (J2EE server) container) for this managed connection. Connection change events will be send to that listener from now on. (SPI JCA 1.0)

Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - ConnectionEventListener to store.

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Remove a connection event listener (instantiated by the (J2EE server) container) from this managed connection. Connection change events won't be send to that listener anymore. (SPI JCA 1.0)

Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - ConnectionEventListener to remove.

getXAResource

public XAResource getXAResource()
                         throws javax.resource.ResourceException
Get the two-way JTA transaction if this kind of transaction is supported by the adapter. Since this sample implementation does not supports XAResources it throws always an exception. (SPI JCA 1.0)

Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection
Returns:
JTA transaction as XAResource to remove.
Throws:
javax.resource.NotSupportedException - Always thrown
javax.resource.ResourceException

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
Get the JCA local transaction if this kind of transaction is supported by the adapter. Since this sample implementation does not supports LocalTransaction it throws always an exception. (SPI JCA 1.0)

Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection
Returns:
JTA transaction as XAResource to remove.
Throws:
javax.resource.NotSupportedException - Always thrown
javax.resource.ResourceException

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
Returns the descriptive and configuration data for this managed connection as ManagedConnectionMetaData. (SPI JCA 1.0)

Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection
Returns:
Managed connection meta data
Throws:
IllegalStateException - Thrown if connection is already deleted
javax.resource.ResourceException

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws javax.resource.ResourceException
Sets the JCA J2EE logwriter PrintWriter object. Although JCA specifies this mechansim it is not being used by XI AF. Instead the resource adapters should use the XI AF trace service classes as done here in this sample. (SPI JCA 1.0)

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection
Parameters:
out - PrintWriter print writer for logging purposes
Throws:
javax.resource.ResourceException

getLogWriter

public PrintWriter getLogWriter()
                         throws javax.resource.ResourceException
Gets the JCA J2EE logwriter PrintWriter object. (SPI JCA 1.0)

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection
Returns:
PrintWriter print writer for logging purposes
Throws:
javax.resource.ResourceException

sendEvent

public void sendEvent(int eventType,
                      Exception ex)
Sends a ConnectionEvent to all registered ConnectionEventListeners. (ra implementation specific)

Parameters:
eventType - One of the ConnectionEvent event types
ex - Exception if event is related to an exception, might be null

sendEvent

public void sendEvent(int eventType,
                      Exception ex,
                      Object connectionHandle)
Sends a ConnectionEvent to all registered ConnectionEventListeners. (ra implementation specific)

Parameters:
eventType - One of the ConnectionEvent event types
ex - Exception if event is related to an exception, might be null
connectionHandle - An object that represents the "handle" to the ManagedConnection, might be null

addCciConnection

public void addCciConnection(CCIConnection cciCon)
Adds a CCI connection in order to operate on this managed connection (ra implementation specific)

Parameters:
cciCon - CCI connection to add

removeCciConnection

public void removeCciConnection(CCIConnection cciCon)
Removes a CCI connection which operates on this managed connection (ra implementation specific)

Parameters:
cciCon - CCI connection which must be removed

start

public void start()
           throws javax.resource.ResourceException
Propagates the start request to the mcf (ra implementation specific)

Throws:
javax.resource.ResourceException

stop

public void stop()
          throws javax.resource.ResourceException
Propagates the stop request to the mcf (ra implementation specific)

Throws:
javax.resource.ResourceException


Copyright © 2012. All Rights Reserved.