Package bitronix.tm.resource.common
Interface XAStatefulHolder
- All Known Subinterfaces:
XAResourceHolder
- All Known Implementing Classes:
AbstractXAResourceHolder,AbstractXAStatefulHolder,DualSessionWrapper,DualSessionWrapper,EhCacheXAResourceHolder,JdbcPooledConnection,JmsPooledConnection,MessagingPooledConnection,RecoveryXAResourceHolder
public interface XAStatefulHolder
Any pooled connection class must implement the
XAStatefulHolder interface. It defines all the services
that must be implemented by the connection as well as the pooling lifecycle states.
Instances of this interface have to create and manage XAResourceHolders.- Author:
- lorban
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe state in which the resource is when it out of the pool but accessible by the application.static final intThe state in which the resource is when it is closed and unusable.static final intThe state in which the resource is when it is available in the pool.static final intThe state in which the resource is when it out of the pool but not accessible by the application. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister an implementation ofStateChangeListener.voidclose()Close the physical connection that thisXAStatefulHolderrepresents.Create a disposable handler used to drive a pooled instance ofXAStatefulHolder.Get the date at which this object was last released to the pool.intgetState()Get the current resource state.Get the list ofXAResourceHolders created by thisXAStatefulHolderthat are still open.voidUnregister an implementation ofStateChangeListener.voidsetState(int state) Set the current resource state.
-
Field Details
-
STATE_CLOSED
static final int STATE_CLOSEDThe state in which the resource is when it is closed and unusable.- See Also:
-
STATE_IN_POOL
static final int STATE_IN_POOLThe state in which the resource is when it is available in the pool.- See Also:
-
STATE_ACCESSIBLE
static final int STATE_ACCESSIBLEThe state in which the resource is when it out of the pool but accessible by the application.- See Also:
-
STATE_NOT_ACCESSIBLE
static final int STATE_NOT_ACCESSIBLEThe state in which the resource is when it out of the pool but not accessible by the application.- See Also:
-
-
Method Details
-
getState
int getState()Get the current resource state.This method is thread-safe.
- Returns:
- the current resource state.
-
setState
void setState(int state) Set the current resource state.This method is thread-safe.
- Parameters:
state- the current resource state.
-
addStateChangeEventListener
Register an implementation ofStateChangeListener.- Parameters:
listener- theStateChangeListenerimplementation to register.
-
removeStateChangeEventListener
Unregister an implementation ofStateChangeListener.- Parameters:
listener- theStateChangeListenerimplementation to unregister.
-
getXAResourceHolders
List<XAResourceHolder> getXAResourceHolders()Get the list ofXAResourceHolders created by thisXAStatefulHolderthat are still open.This method is thread-safe.
- Returns:
- the list of
XAResourceHolders created by thisXAStatefulHolderthat are still open.
-
getConnectionHandle
Create a disposable handler used to drive a pooled instance ofXAStatefulHolder.This method is thread-safe.
- Returns:
- a resource-specific disaposable connection object.
- Throws:
Exception- a resource-specific exception thrown when the disaposable connection cannot be created.
-
close
Close the physical connection that thisXAStatefulHolderrepresents.- Throws:
Exception- a resource-specific exception thrown when there is an error closing the physical connection.
-
getLastReleaseDate
Date getLastReleaseDate()Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.- Returns:
- the date at which this object was last released to the pool or null if it never left the pool.
-