ehcache

net.sf.ehcache.transaction.manager
Class DefaultTransactionManagerLookup

java.lang.Object
  extended by net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup
All Implemented Interfaces:
TransactionManagerLookup
Direct Known Subclasses:
EhcacheJtaTransactionManagerLookup

public class DefaultTransactionManagerLookup
extends Object
implements TransactionManagerLookup

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

Constructor Summary
DefaultTransactionManagerLookup()
           
 
Method Summary
 TransactionManager getTransactionManager()
          Lookup available txnManagers
 void init()
          Switch the TransactionManagerLookup implementation to its initialized state.
 void register(EhcacheXAResource resource, boolean forRecovery)
          execute txnManager specific code to register the XAResource for recovery.
 void setProperties(Properties properties)
          Setter to the properties properties.
 void unregister(EhcacheXAResource resource, boolean forRecovery)
          execute txnManager specific code to unregister the XAResource for recovery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTransactionManagerLookup

public DefaultTransactionManagerLookup()
Method Detail

init

public void 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.

Specified by:
init in interface TransactionManagerLookup

getTransactionManager

public TransactionManager getTransactionManager()
Lookup available txnManagers

Specified by:
getTransactionManager in interface TransactionManagerLookup
Returns:
TransactionManager

register

public void register(EhcacheXAResource resource,
                     boolean forRecovery)
execute txnManager specific code to register the XAResource for recovery.

Specified by:
register in interface TransactionManagerLookup
Parameters:
resource - the XAResource to register for recovery in the choosen TM.
forRecovery - true if the XAResource is meant to be registered for recovery purpose only.

unregister

public void unregister(EhcacheXAResource resource,
                       boolean forRecovery)
execute txnManager specific code to unregister the XAResource for recovery.

Specified by:
unregister in interface TransactionManagerLookup
Parameters:
resource - the XAResource to register for recovery in the choosen TM.
forRecovery - true if the XAResource is meant to be registered for recovery purpose only.

setProperties

public void setProperties(Properties properties)
Setter to the properties properties. This will be called right after the class has been instantiated.

Specified by:
setProperties in interface TransactionManagerLookup
Parameters:
properties - the properties parsed from the config file's transactionManagerLookup tag's properties attribute

ehcache

Copyright 2001-2016, Terracotta, Inc.