Top Description Fields Constructors Methods
net.sf.ehcache.transaction.manager

public Class DefaultTransactionManagerLookup

extends Object
implements TransactionManagerLookup
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.transaction.manager.TransactionManagerLookup
Known Direct Subclasses
net.sf.ehcache.hibernate.EhcacheJtaTransactionManagerLookup
Imports
java.util.ArrayList, .HashSet, .Iterator, .List, .Properties, .Set, java.util.concurrent.locks.Lock, .ReentrantLock, javax.transaction.TransactionManager, net.sf.ehcache.CacheException, net.sf.ehcache.transaction.manager.selector.AtomikosSelector, .BitronixSelector, .GenericJndiSelector, .GlassfishSelector, .JndiSelector, .NullSelector, .Selector, .WeblogicSelector, net.sf.ehcache.transaction.xa.EhcacheXAResource, org.slf4j.Logger, .LoggerFactory

Default TransactionManagerLookup implementation, that will be used by an initializing Cache should the user have not specified otherwise.

This implementation will:

  1. lookup a TransactionManager under java:/TransactionManager, this location can be overridden;
  2. if it failed, lookup for a Glassfish transaction manager;
  3. if it failed, lookup for a Weblogic transaction manager;
  4. if it failed, look for a Bitronix TransactionManager;
  5. and if it failed, finally an Atomikos one.
To specify under what specific name the TransactionManager is to be found, you can provide a jndiName property using setProperties(java.util.Properties). That can be set in the CacheManager's configuration file. The first TransactionManager instance is then kept and returned on each getTransactionManager() call
Author
Alex Snaps

Field Summary

Modifier and TypeField and Description
private final JndiSelector
private volatile boolean
private final Lock
private static final Logger
private volatile Selector
private final Selector[]
private final List<EhcacheXAResource>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public TransactionManager

Returns:

TransactionManager
getTransactionManager
()

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.getTransactionManager.

Lookup available txnManagers
private Set<String>
public void
init()

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.init.

Switch the TransactionManagerLookup implementation to its initialized state.
private void
public void
register(EhcacheXAResource
the XAResource to register for recovery in the choosen TM.
resource
,
boolean
true if the XAResource is meant to be registered for recovery purpose only.
forRecovery
)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.register.

execute txnManager specific code to register the XAResource for recovery.
public void
setProperties(Properties
the properties parsed from the config file's transactionManagerLookup tag's properties attribute
properties
)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.setProperties.

Setter to the properties properties.
public void
unregister(EhcacheXAResource
the XAResource to register for recovery in the choosen TM.
resource
,
boolean
true if the XAResource is meant to be registered for recovery purpose only.
forRecovery
)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.unregister.

execute txnManager specific code to unregister the XAResource for recovery.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultJndiSelectorback to summary
private final JndiSelector defaultJndiSelector
initializedback to summary
private volatile boolean initialized
lockback to summary
private final Lock lock
LOGback to summary
private static final Logger LOG
selectorback to summary
private volatile Selector selector
transactionManagerSelectorsback to summary
private final Selector[] transactionManagerSelectors
uninitializedEhcacheXAResourcesback to summary
private final List<EhcacheXAResource> uninitializedEhcacheXAResources

Constructor Detail

DefaultTransactionManagerLookupback to summary
public DefaultTransactionManagerLookup()

Method Detail

getTransactionManagerback to summary
public TransactionManager getTransactionManager()

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.getTransactionManager.

Lookup available txnManagers

Returns:TransactionManager

TransactionManager

getUninitializedXAResourceCacheNamesback to summary
private Set<String> getUninitializedXAResourceCacheNames()
initback to summary
public void init()

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.init.

Doc from net.sf.ehcache.transaction.manager.TransactionManagerLookup.init.

Switch the TransactionManagerLookup implementation to its initialized state. All EhcacheXAResources registered before initialization are queued up internally and are only registered with the transaction manager during initialization.

lookupTransactionManagerback to summary
private void lookupTransactionManager()
registerback to summary
public void register(EhcacheXAResource resource, boolean forRecovery)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.register.

Doc from net.sf.ehcache.transaction.manager.TransactionManagerLookup.register.

execute txnManager specific code to register the XAResource for recovery.

Parameters
resource:EhcacheXAResource

the XAResource to register for recovery in the choosen TM.

forRecovery:boolean

true if the XAResource is meant to be registered for recovery purpose only.

setPropertiesback to summary
public void setProperties(Properties properties)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.setProperties.

Doc from net.sf.ehcache.transaction.manager.TransactionManagerLookup.setProperties.

Setter to the properties properties. This will be called right after the class has been instantiated.

Parameters
properties:Properties

the properties parsed from the config file's transactionManagerLookup tag's properties attribute

unregisterback to summary
public void unregister(EhcacheXAResource resource, boolean forRecovery)

Implements net.sf.ehcache.transaction.manager.TransactionManagerLookup.unregister.

Doc from net.sf.ehcache.transaction.manager.TransactionManagerLookup.unregister.

execute txnManager specific code to unregister the XAResource for recovery.

Parameters
resource:EhcacheXAResource

the XAResource to register for recovery in the choosen TM.

forRecovery:boolean

true if the XAResource is meant to be registered for recovery purpose only.