public class EhcacheXAResourceImpl extends java.lang.Object implements EhcacheXAResource
Modifier and Type | Field and Description |
---|---|
private Ehcache |
cache |
private ElementValueComparator |
comparator |
private javax.transaction.xa.Xid |
currentXid |
private java.util.List<XAExecutionListener> |
listeners |
private static org.slf4j.Logger |
LOG |
private static long |
MILLISECOND_PER_SECOND |
private XARequestProcessor |
processor |
private SoftLockManager |
softLockManager |
private TransactionIDFactory |
transactionIDFactory |
private int |
transactionTimeout |
private javax.transaction.TransactionManager |
txnManager |
private Store |
underlyingStore |
private java.util.concurrent.ConcurrentMap<javax.transaction.xa.Xid,XATransactionContext> |
xidToContextMap |
Constructor and Description |
---|
EhcacheXAResourceImpl(Ehcache cache,
Store underlyingStore,
TransactionManagerLookup txnManagerLookup,
SoftLockManager softLockManager,
TransactionIDFactory transactionIDFactory,
ReadWriteCopyStrategy<Element> copyStrategy)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addTwoPcExecutionListener(XAExecutionListener listener)
Add a listener which will be called back according to the 2PC lifecycle
|
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase) |
void |
commitInternal(javax.transaction.xa.Xid xid,
boolean onePhase)
The commit implementation
|
XATransactionContext |
createTransactionContext()
Obtain the already associated
XATransactionContext with the current Transaction,
or create a new one should none be there yet. |
void |
end(javax.transaction.xa.Xid xid,
int flag) |
private void |
fireAfterCommitOrRollback() |
private void |
fireBeforePrepare() |
void |
forget(javax.transaction.xa.Xid xid) |
void |
forgetInternal(javax.transaction.xa.Xid xid)
The forget implementation
|
java.lang.String |
getCacheName()
Getter to the name of the cache wrapped by this XAResource
|
XATransactionContext |
getCurrentTransactionContext()
Gets the current
XATransactionContext associated with this resource |
int |
getTransactionTimeout() |
boolean |
isSameRM(javax.transaction.xa.XAResource xaResource) |
int |
prepare(javax.transaction.xa.Xid xid) |
int |
prepareInternal(javax.transaction.xa.Xid xid)
The prepare implementation
|
private static java.lang.String |
prettyPrintXAResourceFlags(int flags) |
javax.transaction.xa.Xid[] |
recover(int flags) |
void |
rollback(javax.transaction.xa.Xid xid) |
void |
rollbackInternal(javax.transaction.xa.Xid xid)
The rollback implementation
|
boolean |
setTransactionTimeout(int timeout) |
void |
start(javax.transaction.xa.Xid xid,
int flag) |
java.lang.String |
toString() |
private static final org.slf4j.Logger LOG
private static final long MILLISECOND_PER_SECOND
private final Ehcache cache
private final Store underlyingStore
private final TransactionIDFactory transactionIDFactory
private final javax.transaction.TransactionManager txnManager
private final SoftLockManager softLockManager
private final java.util.concurrent.ConcurrentMap<javax.transaction.xa.Xid,XATransactionContext> xidToContextMap
private final XARequestProcessor processor
private volatile javax.transaction.xa.Xid currentXid
private volatile int transactionTimeout
private final java.util.List<XAExecutionListener> listeners
private final ElementValueComparator comparator
public EhcacheXAResourceImpl(Ehcache cache, Store underlyingStore, TransactionManagerLookup txnManagerLookup, SoftLockManager softLockManager, TransactionIDFactory transactionIDFactory, ReadWriteCopyStrategy<Element> copyStrategy)
cache
- the cacheunderlyingStore
- the underlying storetxnManagerLookup
- the transaction manager lookupsoftLockManager
- the soft lock managertransactionIDFactory
- the transaction ID factorypublic void start(javax.transaction.xa.Xid xid, int flag) throws javax.transaction.xa.XAException
start
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void end(javax.transaction.xa.Xid xid, int flag) throws javax.transaction.xa.XAException
end
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void forget(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
forget
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void forgetInternal(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
xid
- a XIDjavax.transaction.xa.XAException
- when an error occurspublic int getTransactionTimeout() throws javax.transaction.xa.XAException
getTransactionTimeout
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public boolean isSameRM(javax.transaction.xa.XAResource xaResource) throws javax.transaction.xa.XAException
isSameRM
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
prepare
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public int prepareInternal(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
xid
- a XIDjavax.transaction.xa.XAException
- when an error occurspublic void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
commit
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void commitInternal(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
xid
- a XIDonePhase
- true if onePhase, false otherwisejavax.transaction.xa.XAException
- when an error occurspublic javax.transaction.xa.Xid[] recover(int flags) throws javax.transaction.xa.XAException
recover
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
rollback
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void rollbackInternal(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
xid
- a XIDjavax.transaction.xa.XAException
- when an error occurspublic boolean setTransactionTimeout(int timeout) throws javax.transaction.xa.XAException
setTransactionTimeout
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void addTwoPcExecutionListener(XAExecutionListener listener)
addTwoPcExecutionListener
in interface EhcacheXAResource
listener
- the XAExecutionListenerprivate void fireBeforePrepare()
private void fireAfterCommitOrRollback()
public java.lang.String getCacheName()
getCacheName
in interface EhcacheXAResource
Ehcache.getName()
valuepublic XATransactionContext createTransactionContext() throws javax.transaction.SystemException, javax.transaction.RollbackException
XATransactionContext
with the current Transaction,
or create a new one should none be there yet.createTransactionContext
in interface EhcacheXAResource
XATransactionContext
javax.transaction.SystemException
- Thrown if the associated transaction manager encounters an unexpected error condition.javax.transaction.RollbackException
- Thrown if the resource has to be enlisted with the transaction, while it is marked for rollback only.public XATransactionContext getCurrentTransactionContext()
XATransactionContext
associated with this resourcegetCurrentTransactionContext
in interface EhcacheXAResource
XATransactionContext
, or null if noneprivate static java.lang.String prettyPrintXAResourceFlags(int flags)
public java.lang.String toString()
toString
in class java.lang.Object