Package org.jboss.jca.adapters.jdbc
Class BaseWrapperManagedConnection
- java.lang.Object
-
- org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection
-
- All Implemented Interfaces:
javax.resource.spi.ManagedConnection,org.jboss.jca.core.connectionmanager.pool.mcp.NotifyingManagedConnection,ConnectableResource
- Direct Known Subclasses:
LocalManagedConnection,XAManagedConnection
public abstract class BaseWrapperManagedConnection extends Object implements org.jboss.jca.core.connectionmanager.pool.mcp.NotifyingManagedConnection, ConnectableResource
BaseWrapperManagedConnection- Author:
- David Jencks, Adrian Brock, Weston Price, Jesper Pedersen
-
-
Field Summary
Fields Modifier and Type Field Description protected static AdaptersBundlebundleThe bundleprotected ConnectionconThe connectionprotected booleandestroyedDestroyedprotected static booleanignoreInManagedAutoCommitCallsIgnore in managed auto commit callsprotected AtomicBooleaninLocalTransactionIs inside a local transactionprotected booleaninManagedTransactionIs inside a managed transactionprotected booleanjdbcAutoCommitJDBC auto-commitprotected booleanjdbcReadOnlyJDBC read-onlyprotected intjdbcTransactionIsolationJDBC transaction isolationprotected BaseWrapperManagedConnectionFactorymcfThe managed connection factoryprotected javax.resource.spi.ManagedConnectionMetaDatametadataMetadataprotected PropertiespropsThe propertiesprotected static booleansetAutoCommitOnCleanupprotected ObjectstateLockThe state lockprotected booleanunderlyingAutoCommitUnderlying auto-commitprotected booleanunderlyingReadOnlyUnderlying read-only
-
Constructor Summary
Constructors Constructor Description BaseWrapperManagedConnection(BaseWrapperManagedConnectionFactory mcf, Connection con, Properties props, int transactionIsolation, int psCacheSize)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddConnectionEventListener(javax.resource.spi.ConnectionEventListener cel)Add a connection event listenervoidassociateConnection(Object handle)Associate a handleprotected voidbroadcastConnectionError(Throwable e)Broad cast a connection errorprotected voidcheckException(SQLException e)Check exceptionprotected voidcheckState()Check statevoidcleanup()voiddestroy()Destroyprotected Optional<MethodHandle>getBeginRequestNotify()ObjectgetConnection()ObjectgetConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cri)Get a connectionprotected Optional<MethodHandle>getEndRequestNotify()protected AdaptersLoggergetLog()Get the loggerPrintWritergetLogWriter()javax.resource.spi.ManagedConnectionMetaDatagetMetaData()PropertiesgetProperties()Get the propertiesabstract booleanisXA()Returns true if the underlying connection is handled by an XA resource managerprotected voidlock()LockvoidnotifyRequestBegin()voidnotifyRequestEnd()voidremoveConnectionEventListener(javax.resource.spi.ConnectionEventListener cel)Remove a connection event listenerprotected voidsetBeginRequestNotify(Optional<MethodHandle> beginRequest)voidsetConnectableResourceListener(ConnectableResourceListener crl)protected voidsetEndRequestNotify(Optional<MethodHandle> endRequest)voidsetLogWriter(PrintWriter param1)protected voidtryLock()Try lockprotected voidunlock()Unlock
-
-
-
Field Detail
-
bundle
protected static AdaptersBundle bundle
The bundle
-
mcf
protected final BaseWrapperManagedConnectionFactory mcf
The managed connection factory
-
con
protected final Connection con
The connection
-
props
protected Properties props
The properties
-
stateLock
protected final Object stateLock
The state lock
-
inManagedTransaction
protected boolean inManagedTransaction
Is inside a managed transaction
-
inLocalTransaction
protected AtomicBoolean inLocalTransaction
Is inside a local transaction
-
jdbcAutoCommit
protected boolean jdbcAutoCommit
JDBC auto-commit
-
ignoreInManagedAutoCommitCalls
protected static boolean ignoreInManagedAutoCommitCalls
Ignore in managed auto commit calls
-
setAutoCommitOnCleanup
protected static boolean setAutoCommitOnCleanup
-
underlyingAutoCommit
protected boolean underlyingAutoCommit
Underlying auto-commit
-
jdbcReadOnly
protected boolean jdbcReadOnly
JDBC read-only
-
underlyingReadOnly
protected boolean underlyingReadOnly
Underlying read-only
-
jdbcTransactionIsolation
protected int jdbcTransactionIsolation
JDBC transaction isolation
-
destroyed
protected boolean destroyed
Destroyed
-
metadata
protected javax.resource.spi.ManagedConnectionMetaData metadata
Metadata
-
-
Constructor Detail
-
BaseWrapperManagedConnection
public BaseWrapperManagedConnection(BaseWrapperManagedConnectionFactory mcf, Connection con, Properties props, int transactionIsolation, int psCacheSize) throws SQLException
Constructor- Parameters:
mcf- The managed connection factorycon- The connectionprops- The propertiestransactionIsolation- The transaction isolationpsCacheSize- The prepared statement cache size- Throws:
SQLException- Thrown if an error occurs
-
-
Method Detail
-
addConnectionEventListener
public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener cel)
Add a connection event listener- Specified by:
addConnectionEventListenerin interfacejavax.resource.spi.ManagedConnection- Parameters:
cel- The listener
-
removeConnectionEventListener
public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener cel)
Remove a connection event listener- Specified by:
removeConnectionEventListenerin interfacejavax.resource.spi.ManagedConnection- Parameters:
cel- The listener
-
associateConnection
public void associateConnection(Object handle) throws javax.resource.ResourceException
Associate a handle- Specified by:
associateConnectionin interfacejavax.resource.spi.ManagedConnection- Parameters:
handle- The handle- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
getLogWriter
public PrintWriter getLogWriter() throws javax.resource.ResourceException
- Specified by:
getLogWriterin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException
-
getMetaData
public javax.resource.spi.ManagedConnectionMetaData getMetaData() throws javax.resource.ResourceException- Specified by:
getMetaDatain interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException
-
setLogWriter
public void setLogWriter(PrintWriter param1) throws javax.resource.ResourceException
- Specified by:
setLogWriterin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException
-
cleanup
public void cleanup() throws javax.resource.ResourceException- Specified by:
cleanupin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException
-
lock
protected void lock()
Lock
-
tryLock
protected void tryLock() throws SQLExceptionTry lock- Throws:
SQLException- Thrown if a lock can't be obtained
-
unlock
protected void unlock()
Unlock
-
getConnection
public Object getConnection(Subject subject, javax.resource.spi.ConnectionRequestInfo cri) throws javax.resource.ResourceException
Get a connection- Specified by:
getConnectionin interfacejavax.resource.spi.ManagedConnection- Parameters:
subject- The subjectcri- The connection request info- Returns:
- The connection
- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
destroy
public void destroy() throws javax.resource.ResourceExceptionDestroy- Specified by:
destroyin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
getProperties
public Properties getProperties()
Get the properties- Returns:
- The value
-
getConnection
public Object getConnection() throws Exception
- Specified by:
getConnectionin interfaceConnectableResource- Throws:
Exception
-
setConnectableResourceListener
public void setConnectableResourceListener(ConnectableResourceListener crl)
- Specified by:
setConnectableResourceListenerin interfaceConnectableResource
-
broadcastConnectionError
protected void broadcastConnectionError(Throwable e)
Broad cast a connection error- Parameters:
e- The error
-
getLog
protected AdaptersLogger getLog()
Get the logger- Returns:
- The value
-
checkState
protected void checkState() throws SQLExceptionCheck state- Throws:
SQLException- Thrown if an error occurs
-
checkException
protected void checkException(SQLException e) throws javax.resource.ResourceException
Check exception- Parameters:
e- The exception- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
getEndRequestNotify
protected Optional<MethodHandle> getEndRequestNotify()
-
setEndRequestNotify
protected void setEndRequestNotify(Optional<MethodHandle> endRequest)
-
getBeginRequestNotify
protected Optional<MethodHandle> getBeginRequestNotify()
-
setBeginRequestNotify
protected void setBeginRequestNotify(Optional<MethodHandle> beginRequest)
-
isXA
public abstract boolean isXA()
Returns true if the underlying connection is handled by an XA resource manager- Returns:
- The value
-
notifyRequestBegin
public void notifyRequestBegin()
- Specified by:
notifyRequestBeginin interfaceorg.jboss.jca.core.connectionmanager.pool.mcp.NotifyingManagedConnection
-
notifyRequestEnd
public void notifyRequestEnd()
- Specified by:
notifyRequestEndin interfaceorg.jboss.jca.core.connectionmanager.pool.mcp.NotifyingManagedConnection
-
-