Top Description Inners Fields Constructors Methods
net.sf.ehcache.transaction.local

public Class JtaLocalTransactionStore

extends AbstractTransactionStore
Class Inheritance
Imports
net.sf.ehcache.CacheEntry, .CacheException, .Ehcache, .Element, .TransactionController, net.sf.ehcache.store.ElementValueComparator, net.sf.ehcache.transaction.AbstractTransactionStore, .TransactionException, .TransactionID, net.sf.ehcache.transaction.manager.TransactionManagerLookup, net.sf.ehcache.transaction.xa.EhcacheXAResource, .XAExecutionListener, .XATransactionContext, net.sf.ehcache.util.lang.VicariousThreadLocal, net.sf.ehcache.writer.CacheWriterManager, org.slf4j.Logger, .LoggerFactory, java.util.Collection, .List, java.util.concurrent.atomic.AtomicBoolean, javax.transaction.RollbackException, .Synchronization, .SystemException, .Transaction, .TransactionManager, javax.transaction.xa.XAException, .XAResource, .Xid

A Store implementation with support for local transactions driven by a JTA transaction manager
Author
Ludovic Orban

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
JtaLocalTransactionStore.JtaLocalEhcacheSynchronization

A Synchronization used to terminate the local transaction and clean it up

private static class
JtaLocalTransactionStore.JtaLocalEhcacheXAResource

A XAResource implementation used to terminate the local transaction and clean it up.

Field Summary

Modifier and TypeField and Description
private static final String
private static final AtomicBoolean
private static final VicariousThreadLocal<Transaction>
private final Ehcache
private static final Logger
private final TransactionController
private final TransactionManager
private final TransactionManagerLookup
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
underlyingStore

Constructor Summary

AccessConstructor and Description
public
JtaLocalTransactionStore(LocalTransactionStore
the underlying LocalTransactionStore
underlyingStore
,
TransactionManagerLookup
the TransactionManagerLookup
transactionManagerLookup
,
TransactionController
the TransactionController
transactionController
)

Create a new JtaLocalTransactionStore instance

Method Summary

Modifier and TypeMethod and Description
public boolean
containsKey(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.
public Element
get(Object key)

Implements net.sf.ehcache.store.Store.get.

Gets an item from the cache.
public List<E>
getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.
public Element
getOldElement(Object
the key to look for
key
)

Overrides net.sf.ehcache.transaction.AbstractTransactionStore.getOldElement.

Method to get to the Element matching the key, oblivious of any in-flight transaction.
public Element
getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics
public int
getSize()

Implements net.sf.ehcache.store.Store.getSize.

Returns the current local store size
public int
getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size
public boolean
put(Element element)

Implements net.sf.ehcache.store.Store.put.

Puts an item into the store.
public void
putAll(Collection<Element>
Collection of elements to be put in the store
elements
)

Overrides net.sf.ehcache.store.AbstractStore.putAll.

Implements net.sf.ehcache.store.Store.putAll.

Puts a collection of elements into the store.
public Element
putIfAbsent(Element
element to be added
element
)

Implements net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.
public boolean
putWithWriter(final Element element, final CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation
private void
public Element
remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Removes an item from the cache.
public void
removeAll(Collection<?> keys)

Overrides net.sf.ehcache.store.AbstractStore.removeAll.

Implements net.sf.ehcache.store.Store.removeAll.

Removes a collection of elements from the cache.
public void
removeAll()

Implements net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.
public Element
removeElement(Element
Element to be removed
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element.
public Element
removeWithWriter(final Object key, final CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.
public boolean
replace(Element
Element to be test against
old
,
Element
Element to be cached
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
public Element
replace(Element
Element to be cached
element
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key
private void
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
bufferFullcontainsKeyInMemorycontainsKeyOffHeapcontainsKeyOnDiskcreateWriteBehinddisposeexecuteQueryexpireElementsflushgetInMemoryEvictionPolicygetInMemorySizegetInMemorySizeInBytesgetInternalContextgetLocalKeysgetMBeangetOffHeapSizegetOffHeapSizeInBytesgetOnDiskSizegetOnDiskSizeInBytesgetSearchAttributegetSearchAttributesgetStatusgetTransactionalModehasAbortedSizeOfisCacheCoherentisClusterCoherentisNodeCoherentnotifyCacheEventListenersChangedquickClearquickSizesetAttributeExtractorssetInMemoryEvictionPolicysetNodeCoherentunsafeGetwaitUntilClusterCoherent

Field Detail

ALTERNATIVE_TERMINATION_MODE_SYS_PROPERTY_NAMEback to summary
private static final String ALTERNATIVE_TERMINATION_MODE_SYS_PROPERTY_NAME
ATOMIKOS_WARNING_ISSUEDback to summary
private static final AtomicBoolean ATOMIKOS_WARNING_ISSUED
BOUND_JTA_TRANSACTIONSback to summary
private static final VicariousThreadLocal<Transaction> BOUND_JTA_TRANSACTIONS
cacheback to summary
private final Ehcache cache
LOGback to summary
private static final Logger LOG
transactionControllerback to summary
private final TransactionController transactionController
transactionManagerback to summary
private final TransactionManager transactionManager
transactionManagerLookupback to summary
private final TransactionManagerLookup transactionManagerLookup

Constructor Detail

JtaLocalTransactionStoreback to summary
public JtaLocalTransactionStore(LocalTransactionStore underlyingStore, TransactionManagerLookup transactionManagerLookup, TransactionController transactionController)

Create a new JtaLocalTransactionStore instance

Parameters
underlyingStore:LocalTransactionStore

the underlying LocalTransactionStore

transactionManagerLookup:TransactionManagerLookup

the TransactionManagerLookup

transactionController:TransactionController

the TransactionController

Method Detail

containsKeyback to summary
public boolean containsKey(Object key)

Implements net.sf.ehcache.store.Store.containsKey.

Doc from net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired. 1.2

getback to summary
public Element get(Object key)

Implements net.sf.ehcache.store.Store.get.

Doc from net.sf.ehcache.store.Store.get.

Gets an item from the cache.

getKeysback to summary
public List<E> getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Doc from net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.

Returns:List<E>

An List of java.io.Serializable keys

getOldElementback to summary
public Element getOldElement(Object key)

Overrides net.sf.ehcache.transaction.AbstractTransactionStore.getOldElement.

Doc from net.sf.ehcache.transaction.AbstractTransactionStore.getOldElement.

Method to get to the Element matching the key, oblivious of any in-flight transaction.

Parameters
key:Object

the key to look for

Returns:Element

the mapped element, outside of any transaction

Annotations
@Override
getQuietback to summary
public Element getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Doc from net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics

Returns:Element

The element

getSizeback to summary
public int getSize()

Implements net.sf.ehcache.store.Store.getSize.

Doc from net.sf.ehcache.store.Store.getSize.

Returns the current local store size

Returns:int

the count of the Elements in the Store on the local machine

getTerracottaClusteredSizeback to summary
public int getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Doc from net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size

Returns:int

the count of the Elements in the Store across the cluster

putback to summary
public boolean put(Element element) throws CacheException

Implements net.sf.ehcache.store.Store.put.

Doc from net.sf.ehcache.store.Store.put.

Puts an item into the store.

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

putAllback to summary
public void putAll(Collection<Element> elements) throws CacheException

Overrides net.sf.ehcache.store.AbstractStore.putAll.

Implements net.sf.ehcache.store.Store.putAll.

Doc from net.sf.ehcache.store.Store.putAll.

Puts a collection of elements into the store.

Parameters
elements:Collection<Element>

Collection of elements to be put in the store

Annotations
@Override
putIfAbsentback to summary
public Element putIfAbsent(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.putIfAbsent.

Doc from net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.

Parameters
element:Element

element to be added

Returns:Element

the element previously cached for this key, or null if none.

Exceptions
NullPointerException:
if the element is null, or has a null key
putWithWriterback to summary
public boolean putWithWriter(final Element element, final CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.putWithWriter.

Doc from net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

registerInJtaContextback to summary
private void registerInJtaContext()
removeback to summary
public Element remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Doc from net.sf.ehcache.store.Store.remove.

Removes an item from the cache.

removeAllback to summary
public void removeAll(Collection<?> keys)

Overrides net.sf.ehcache.store.AbstractStore.removeAll.

Implements net.sf.ehcache.store.Store.removeAll.

Doc from net.sf.ehcache.store.Store.removeAll.

Removes a collection of elements from the cache.

Annotations
@Override
removeAllback to summary
public void removeAll() throws CacheException

Implements net.sf.ehcache.store.Store.removeAll.

Doc from net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.

If there are registered CacheEventListeners they are notified of the expiry or removal of the Element as each is removed.

removeElementback to summary
public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException

Implements net.sf.ehcache.store.Store.removeElement.

Doc from net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element. This is a CAS operation. It is consistent even against a distributed cache that is not coherent. If the old value is stale when this operation is attempted the remove does not take place.

Parameters
element:Element

Element to be removed

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:Element

the Element removed or null if no Element was removed

Exceptions
NullPointerException:
if the element is null, or has a null key
removeWithWriterback to summary
public Element removeWithWriter(final Object key, final CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.removeWithWriter.

Doc from net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.

replaceback to summary
public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.

Parameters
old:Element

Element to be test against

element:Element

Element to be cached

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:boolean

true is the Element was replaced

Exceptions
NullPointerException:
if the either Element is null or has a null key
IllegalArgumentException:
if the two Element keys are non-null but not equal
replaceback to summary
public Element replace(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key

Parameters
element:Element

Element to be cached

Returns:Element

the Element previously cached for this key, or null if no Element was cached

Exceptions
NullPointerException:
if the Element is null or has a null key
setRollbackOnlyback to summary
private void setRollbackOnly()
net.sf.ehcache.transaction.local back to summary

private final Class JtaLocalTransactionStore.JtaLocalEhcacheSynchronization

extends Object
implements Synchronization
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.local.JtaLocalTransactionStore.JtaLocalEhcacheSynchronization
All Implemented Interfaces
javax.transaction.Synchronization

A Synchronization used to terminate the local transaction and clean it up

Field Summary

Modifier and TypeField and Description
private final TransactionController
private final TransactionID

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
afterCompletion(int
The status of the transaction completion.
status
)

Implements javax.transaction.Synchronization.afterCompletion.

This method is called by the transaction manager after the transaction is committed or rolled back.
public void
beforeCompletion()

Implements javax.transaction.Synchronization.beforeCompletion.

The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

transactionControllerback to summary
private final TransactionController transactionController
transactionIdback to summary
private final TransactionID transactionId

Constructor Detail

JtaLocalEhcacheSynchronizationback to summary
private JtaLocalEhcacheSynchronization(TransactionController transactionController, TransactionID transactionId)

Method Detail

afterCompletionback to summary
public void afterCompletion(int status)

Implements javax.transaction.Synchronization.afterCompletion.

Doc from javax.transaction.Synchronization.afterCompletion.

This method is called by the transaction manager after the transaction is committed or rolled back.

Parameters
status:int

The status of the transaction completion.

beforeCompletionback to summary
public void beforeCompletion()

Implements javax.transaction.Synchronization.beforeCompletion.

Doc from javax.transaction.Synchronization.beforeCompletion.

The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process. This call is executed with the transaction context of the transaction that is being committed.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
net.sf.ehcache.transaction.local back to summary

private final Class JtaLocalTransactionStore.JtaLocalEhcacheXAResource

extends Object
implements EhcacheXAResource
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.local.JtaLocalTransactionStore.JtaLocalEhcacheXAResource
All Implemented Interfaces
net.sf.ehcache.transaction.xa.EhcacheXAResource, javax.transaction.xa.XAResource

A XAResource implementation used to terminate the local transaction and clean it up. It should only be used with transaction managers providing a defective Synchronization mechanism with which rollback/commit cannot be reliably differentiated as it relies on the fact that the same thread is used to call Ehcache methods as well as XAResource which isn't guaranteed by the specification. This mechanism also has a slight performance impact as there is one extra resource participating in the 2PC.

Field Summary

Modifier and TypeField and Description
private final TransactionController
private final TransactionID
private final TransactionManagerLookup

Constructor Summary

AccessConstructor and Description
private
JtaLocalEhcacheXAResource(TransactionController transactionController, TransactionID transactionId, TransactionManagerLookup transactionManagerLookup)

Method Summary

Modifier and TypeMethod and Description
public void
addTwoPcExecutionListener(XAExecutionListener
the XAExecutionListener
listener
)

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.addTwoPcExecutionListener.

Add a listener which will be called back according to the 2PC lifecycle
public void
commit(Xid
A global transaction identifier
xid
,
boolean
If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.
onePhase
)

Implements javax.transaction.xa.XAResource.commit.

Commits the global transaction specified by xid.
public XATransactionContext
createTransactionContext()

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.createTransactionContext.

Obtain the already associated XATransactionContext with the current Transaction, or create a new one should none be there yet.
public void
end(Xid
A global transaction identifier that is the same as the identifier used previously in the start method.
xid
,
int
One of TMSUCCESS, TMFAIL, or TMSUSPEND.
flag
)

Implements javax.transaction.xa.XAResource.end.

Ends the work performed on behalf of a transaction branch.
public void
forget(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.forget.

Tells the resource manager to forget about a heuristically completed transaction branch.
public String
getCacheName()

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.getCacheName.

Getter to the name of the cache wrapped by this XAResource
public XATransactionContext
public int
getTransactionTimeout()

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Obtains the current transaction timeout value set for this XAResource instance.
public boolean
isSameRM(XAResource
An XAResource object whose resource manager instance is to be compared with the resource manager instance of the target object.
xaResource
)

Implements javax.transaction.xa.XAResource.isSameRM.

This method is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.
public int
prepare(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.prepare.

Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
public Xid[]
recover(int
One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter.
flags
)

Implements javax.transaction.xa.XAResource.recover.

Obtains a list of prepared transaction branches from a resource manager.
public void
rollback(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.rollback.

Informs the resource manager to roll back work done on behalf of a transaction branch.
public boolean
setTransactionTimeout(int
The transaction timeout value in seconds.
timeout
)

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Sets the current transaction timeout value for this XAResource instance.
public void
start(Xid
A global transaction identifier to be associated with the resource.
xid
,
int
One of TMNOFLAGS, TMJOIN, or TMRESUME.
flag
)

Implements javax.transaction.xa.XAResource.start.

Starts work on behalf of a transaction branch specified in xid.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

transactionControllerback to summary
private final TransactionController transactionController
transactionIdback to summary
private final TransactionID transactionId
transactionManagerLookupback to summary
private final TransactionManagerLookup transactionManagerLookup

Constructor Detail

JtaLocalEhcacheXAResourceback to summary
private JtaLocalEhcacheXAResource(TransactionController transactionController, TransactionID transactionId, TransactionManagerLookup transactionManagerLookup)

Method Detail

addTwoPcExecutionListenerback to summary
public void addTwoPcExecutionListener(XAExecutionListener listener)

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.addTwoPcExecutionListener.

Doc from net.sf.ehcache.transaction.xa.EhcacheXAResource.addTwoPcExecutionListener.

Add a listener which will be called back according to the 2PC lifecycle

Parameters
listener:XAExecutionListener

the XAExecutionListener

commitback to summary
public void commit(Xid xid, boolean onePhase) throws XAException

Implements javax.transaction.xa.XAResource.commit.

Doc from javax.transaction.xa.XAResource.commit.

Commits the global transaction specified by xid.

Parameters
xid:Xid

A global transaction identifier

onePhase:boolean

If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.

Exceptions
XAException:
An error has occurred. Possible XAExceptions are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

If the resource manager did not commit the transaction and the paramether onePhase is set to true, the resource manager may throw one of the XA_RB* exceptions. Upon return, the resource manager has rolled back the branch's work and has released all held resources.

createTransactionContextback to summary
public XATransactionContext createTransactionContext() throws SystemException, RollbackException

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.createTransactionContext.

Doc from net.sf.ehcache.transaction.xa.EhcacheXAResource.createTransactionContext.

Obtain the already associated XATransactionContext with the current Transaction, or create a new one should none be there yet.

Returns:XATransactionContext

The associated Transaction associated XATransactionContext

Exceptions
SystemException:
Thrown if the associated transaction manager encounters an unexpected error condition.
RollbackException:
Thrown if the resource has to be enlisted with the transaction, while it is marked for rollback only.
endback to summary
public void end(Xid xid, int flag) throws XAException

Implements javax.transaction.xa.XAResource.end.

Doc from javax.transaction.xa.XAResource.end.

Ends the work performed on behalf of a transaction branch. The resource manager disassociates the XA resource from the transaction branch specified and lets the transaction complete.

If TMSUSPEND is specified in the flags, the transaction branch is temporarily suspended in an incomplete state. The transaction context is in a suspended state and must be resumed via the start method with TMRESUME specified.

If TMFAIL is specified, the portion of work has failed. The resource manager may mark the transaction as rollback-only

If TMSUCCESS is specified, the portion of work has completed successfully.

Parameters
xid:Xid

A global transaction identifier that is the same as the identifier used previously in the start method.

flag:int

One of TMSUCCESS, TMFAIL, or TMSUSPEND.

Exceptions
XAException:
An error has occurred. Possible XAException values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL, XAER_PROTO, or XA_RB*.
forgetback to summary
public void forget(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.forget.

Doc from javax.transaction.xa.XAResource.forget.

Tells the resource manager to forget about a heuristically completed transaction branch.

Parameters
xid:Xid

A global transaction identifier.

Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
getCacheNameback to summary
public String getCacheName()

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.getCacheName.

Doc from net.sf.ehcache.transaction.xa.EhcacheXAResource.getCacheName.

Getter to the name of the cache wrapped by this XAResource

Returns:String

net.sf.ehcache.Ehcache#getName value

getCurrentTransactionContextback to summary
public XATransactionContext getCurrentTransactionContext()

Implements net.sf.ehcache.transaction.xa.EhcacheXAResource.getCurrentTransactionContext.

Doc from net.sf.ehcache.transaction.xa.EhcacheXAResource.getCurrentTransactionContext.

Gets the current XATransactionContext associated with this resource

Returns:XATransactionContext

the current XATransactionContext, or null if none

getTransactionTimeoutback to summary
public int getTransactionTimeout() throws XAException

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Doc from javax.transaction.xa.XAResource.getTransactionTimeout.

Obtains the current transaction timeout value set for this XAResource instance. If XAResource.setTransactionTimeout was not used prior to invoking this method, the return value is the default timeout set for the resource manager; otherwise, the value used in the previous setTransactionTimeout call is returned.

Returns:int

the transaction timeout value in seconds.

Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR and XAER_RMFAIL.
isSameRMback to summary
public boolean isSameRM(XAResource xaResource) throws XAException

Implements javax.transaction.xa.XAResource.isSameRM.

Doc from javax.transaction.xa.XAResource.isSameRM.

This method is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.

Parameters
xaResource:XAResource

An XAResource object whose resource manager instance is to be compared with the resource manager instance of the target object.

Returns:boolean

true if it's the same RM instance; otherwise false.

Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR and XAER_RMFAIL.
prepareback to summary
public int prepare(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.prepare.

Doc from javax.transaction.xa.XAResource.prepare.

Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.

Parameters
xid:Xid

A global transaction identifier.

Returns:int

A value indicating the resource manager's vote on the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by raising an appropriate XAException in the prepare method.

Exceptions
XAException:
An error has occurred. Possible exception values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
recoverback to summary
public Xid[] recover(int flags) throws XAException

Implements javax.transaction.xa.XAResource.recover.

Doc from javax.transaction.xa.XAResource.recover.

Obtains a list of prepared transaction branches from a resource manager. The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.

Parameters
flags:int

One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter.

Returns:Xid[]

The resource manager returns zero or more XIDs of the transaction branches that are currently in a prepared or heuristically completed state. If an error occurs during the operation, the resource manager should throw the appropriate XAException.

Exceptions
XAException:
An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
rollbackback to summary
public void rollback(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.rollback.

Doc from javax.transaction.xa.XAResource.rollback.

Informs the resource manager to roll back work done on behalf of a transaction branch.

Parameters
xid:Xid

A global transaction identifier.

Exceptions
XAException:
An error has occurred.
setTransactionTimeoutback to summary
public boolean setTransactionTimeout(int timeout) throws XAException

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Doc from javax.transaction.xa.XAResource.setTransactionTimeout.

Sets the current transaction timeout value for this XAResource instance. Once set, this timeout value is effective until setTransactionTimeout is invoked again with a different value. To reset the timeout value to the default value used by the resource manager, set the value to zero. If the timeout operation is performed successfully, the method returns true; otherwise false. If a resource manager does not support explicitly setting the transaction timeout value, this method returns false.

Parameters
timeout:int

The transaction timeout value in seconds.

Returns:boolean

true if the transaction timeout value is set successfully; otherwise false.

Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
startback to summary
public void start(Xid xid, int flag) throws XAException

Implements javax.transaction.xa.XAResource.start.

Doc from javax.transaction.xa.XAResource.start.

Starts work on behalf of a transaction branch specified in xid. If TMJOIN is specified, the start applies to joining a transaction previously seen by the resource manager. If TMRESUME is specified, the start applies to resuming a suspended transaction specified in the parameter xid. If neither TMJOIN nor TMRESUME is specified and the transaction specified by xid has previously been seen by the resource manager, the resource manager throws the XAException exception with XAER_DUPID error code.

Parameters
xid:Xid

A global transaction identifier to be associated with the resource.

flag:int

One of TMNOFLAGS, TMJOIN, or TMRESUME.

Exceptions
XAException:
An error has occurred. Possible exceptions are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override