-
public interface ManagedConnection
ManagedConnection instance represents a physical connection to the underlying EIS.A ManagedConnection instance provides access to a pair of interfaces:
javax.transaction.xa.XAResource
andjavax.resource.spi.LocalTransaction
.XAResource
interface is used by the transaction manager to associate and dissociate a transaction with the underlying EIS resource manager instance and to perform two-phase commit protocol. The ManagedConnection interface is not directly used by the transaction manager. More details on the XAResource interface are described in the JTA specification.The LocalTransaction interface is used by the application server to manage local transactions.
- Version:
- 0.5
- Author:
- Rahul Sharma
- See Also:
ManagedConnectionFactory
,XAResource
,LocalTransaction
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
addConnectionEventListener(ConnectionEventListener listener)
Adds a connection event listener to the ManagedConnection instance.void
associateConnection(Object connection)
Used typically by the container to change the association of an application-level connection handle with a ManagedConneciton instance.void
cleanup()
Application server calls this method to force any cleanup on the ManagedConnection instance.void
destroy()
Destroys the physical connection to the underlying resource manager.Object
getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo)
Creates a new connection handle for the underlying physical connection represented by the ManagedConnection instance.LocalTransaction
getLocalTransaction()
Returns anjavax.resource.spi.LocalTransaction
instance.PrintWriter
getLogWriter()
Gets the log writer for this ManagedConnection instance.ManagedConnectionMetaData
getMetaData()
Gets the metadata information for this connection's underlying EIS resource manager instance.XAResource
getXAResource()
Returns anjavax.transaction.xa.XAresource
instance.void
removeConnectionEventListener(ConnectionEventListener listener)
Removes an already registered connection event listener from the ManagedConnection instance.void
setLogWriter(PrintWriter out)
Sets the log writer for this ManagedConnection instance.
-
-
-
Method Detail
-
getConnection
Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
Creates a new connection handle for the underlying physical connection represented by the ManagedConnection instance. This connection handle is used by the application code to refer to the underlying physical connection. This connection handle is associated with its ManagedConnection instance in a resource adapter implementation specific way.The ManagedConnection uses the Subject and additional ConnectionRequest Info (which is specific to resource adapter and opaque to application server) to set the state of the physical connection.
- Parameters:
subject
- security context as JAAS subjectcxRequestInfo
- ConnectionRequestInfo instance- Returns:
- generic Object instance representing the connection handle. For CCI, the connection handle created by a ManagedConnection instance is of the type javax.resource.cci.Connection.
- Throws:
ResourceException
- generic exception if operation failsResourceAdapterInternalException
- resource adapter internal error conditionSecurityException
- security related error conditionCommException
- failed communication with EIS instanceEISSystemException
- internal error condition in EIS instance - used if EIS instance is involved in setting state of ManagedConnection
-
destroy
void destroy() throws ResourceException
Destroys the physical connection to the underlying resource manager.To manage the size of the connection pool, an application server can explictly call ManagedConnection.destroy to destroy a physical connection. A resource adapter should destroy all allocated system resources for this ManagedConnection instance when the method destroy is called.
- Throws:
ResourceException
- generic exception if operation failedIllegalStateException
- illegal state for destroying connection
-
cleanup
void cleanup() throws ResourceException
Application server calls this method to force any cleanup on the ManagedConnection instance.The method ManagedConnection.cleanup initiates a cleanup of the any client-specific state as maintained by a ManagedConnection instance. The cleanup should invalidate all connection handles that had been created using this ManagedConnection instance. Any attempt by an application component to use the connection handle after cleanup of the underlying ManagedConnection should result in an exception.
The cleanup of ManagedConnection is always driven by an application server. An application server should not invoke ManagedConnection.cleanup when there is an uncompleted transaction (associated with a ManagedConnection instance) in progress.
The invocation of ManagedConnection.cleanup method on an already cleaned-up connection should not throw an exception.
The cleanup of ManagedConnection instance resets its client specific state and prepares the connection to be put back in to a connection pool. The cleanup method should not cause resource adapter to close the physical pipe and reclaim system resources associated with the physical connection.
- Throws:
ResourceException
- generic exception if operation failsResourceAdapterInternalException
- resource adapter internal error conditionIllegalStateException
- Illegal state for calling connection cleanup. Example - if a localtransaction is in progress that doesn't allow connection cleanup
-
associateConnection
void associateConnection(Object connection) throws ResourceException
Used typically by the container to change the association of an application-level connection handle with a ManagedConneciton instance. The container should find the right ManagedConnection instance and call the associateConnection method. In order to set a Connection Handle as the active connection handle, the container may also use theassociateConnection
method to set the sameManagedConnection
associated with the Connection handle.The resource adapter is required to implement the associateConnection method. The method implementation for a ManagedConnection should dissociate the connection handle (passed as a parameter) from its currently associated ManagedConnection and associate the new connection handle with itself.
- Parameters:
connection
- Application-level connection handle- Throws:
ResourceException
- Failed to associate the connection handle with this ManagedConnection instanceIllegalStateException
- Illegal state for invoking this methodResourceAdapterInternalException
- Resource adapter internal error condition
-
addConnectionEventListener
void addConnectionEventListener(ConnectionEventListener listener)
Adds a connection event listener to the ManagedConnection instance.The registered ConnectionEventListener instances are notified of connection close and error events, also of local transaction related events on the Managed Connection.
- Parameters:
listener
- a new ConnectionEventListener to be registered
-
removeConnectionEventListener
void removeConnectionEventListener(ConnectionEventListener listener)
Removes an already registered connection event listener from the ManagedConnection instance.- Parameters:
listener
- already registered connection event listener to be removed
-
getXAResource
XAResource getXAResource() throws ResourceException
Returns anjavax.transaction.xa.XAresource
instance. An application server enlists this XAResource instance with the Transaction Manager if the ManagedConnection instance is being used in a JTA transaction that is being coordinated by the Transaction Manager.- Returns:
- XAResource instance
- Throws:
ResourceException
- generic exception if operation failsNotSupportedException
- if the operation is not supportedResourceAdapterInternalException
- resource adapter internal error condition
-
getLocalTransaction
LocalTransaction getLocalTransaction() throws ResourceException
Returns anjavax.resource.spi.LocalTransaction
instance. The LocalTransaction interface is used by the container to manage local transactions for a RM instance.- Returns:
- LocalTransaction instance
- Throws:
ResourceException
- generic exception if operation failsNotSupportedException
- if the operation is not supportedResourceAdapterInternalException
- resource adapter internal error condition
-
getMetaData
ManagedConnectionMetaData getMetaData() throws ResourceException
Gets the metadata information for this connection's underlying EIS resource manager instance. The ManagedConnectionMetaData interface provides information about the underlying EIS instance associated with the ManagedConenction instance.
- Returns:
- ManagedConnectionMetaData instance
- Throws:
ResourceException
- generic exception if operation failsNotSupportedException
- if the operation is not supported
-
setLogWriter
void setLogWriter(PrintWriter out) throws ResourceException
Sets the log writer for this ManagedConnection instance.The log writer is a character output stream to which all logging and tracing messages for this ManagedConnection instance will be printed. Application Server manages the association of output stream with the ManagedConnection instance based on the connection pooling requirements.
When a ManagedConnection object is initially created, the default log writer associated with this instance is obtained from the ManagedConnectionFactory. An application server can set a log writer specific to this ManagedConnection to log/trace this instance using setLogWriter method.
- Parameters:
out
- Character Output stream to be associated- Throws:
ResourceException
- generic exception if operation failsResourceAdapterInternalException
- resource adapter related error condition
-
getLogWriter
PrintWriter getLogWriter() throws ResourceException
Gets the log writer for this ManagedConnection instance.The log writer is a character output stream to which all logging and tracing messages for this ManagedConnection instance will be printed. ConnectionManager manages the association of output stream with the ManagedConnection instance based on the connection pooling requirements.
The Log writer associated with a ManagedConnection instance can be one set as default from the ManagedConnectionFactory (that created this connection) or one set specifically for this instance by the application server.
- Returns:
- Character ourput stream associated with this Managed- Connection instance
- Throws:
ResourceException
- generic exception if operation fails
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/resource/spi/ManagedConnection.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.