bitronix.tm.resource.ehcache
Class EhCacheXAResourceProducer

java.lang.Object
  extended by bitronix.tm.resource.common.ResourceBean
      extended by bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
All Implemented Interfaces:
XAResourceProducer, Serializable, Referenceable

public final class EhCacheXAResourceProducer
extends ResourceBean
implements XAResourceProducer

EHCache implementation of BTM's XAResourceProducer.

Copyright 2003-2010 Terracotta, Inc.

Author:
lorban
See Also:
Serialized Form

Method Summary
 void close()
          Release this XAResourceProducer's internal resources.
 XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 void endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 Reference getReference()
          
 void init()
          Initialize this XAResourceProducer's internal resources.
static void registerXAResource(String uniqueName, XAResource xaResource)
          Register an XAResource of a cache with BTM.
 void setFailed(boolean failed)
          Mark this resource producer as failed or not.
 XAResourceHolderState startRecovery()
          Prepare the recoverable XAResource producer for recovery.
static void unregisterXAResource(String uniqueName, XAResource xaResource)
          Unregister an XAResource of a cache from BTM.
 
Methods inherited from class bitronix.tm.resource.common.ResourceBean
getAcquireIncrement, getAcquisitionInterval, getAcquisitionTimeout, getAllowLocalTransactions, getApplyTransactionTimeout, getAutomaticEnlistingEnabled, getClassName, getDeferConnectionRelease, getDriverProperties, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getShareTransactionConnections, getTwoPcOrderingPosition, getUniqueName, getUseTmJoin, incCreatedResourcesCounter, setAcquireIncrement, setAcquisitionInterval, setAcquisitionTimeout, setAllowLocalTransactions, setApplyTransactionTimeout, setAutomaticEnlistingEnabled, setClassName, setDeferConnectionRelease, setDriverProperties, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setShareTransactionConnections, setTwoPcOrderingPosition, setUniqueName, setUseTmJoin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAResourceProducer
getUniqueName
 

Method Detail

registerXAResource

public static void registerXAResource(String uniqueName,
                                      XAResource xaResource)
Register an XAResource of a cache with BTM. The first time a XAResource is registered a new EhCacheXAResourceProducer is created to hold it.

Parameters:
uniqueName - the uniqueName of this XAResourceProducer, usually the cache's name
xaResource - the XAResource to be registered

unregisterXAResource

public static void unregisterXAResource(String uniqueName,
                                        XAResource xaResource)
Unregister an XAResource of a cache from BTM.

Parameters:
uniqueName - the uniqueName of this XAResourceProducer, usually the cache's name
xaResource - the XAResource to be registered

startRecovery

public XAResourceHolderState startRecovery()
                                    throws RecoveryException
Prepare the recoverable XAResource producer for recovery.

Specified by:
startRecovery in interface XAResourceProducer
Returns:
a XAResourceHolderState object that can be used to call recover().
Throws:
RecoveryException - thrown when a XAResourceHolderState cannot be acquired.

endRecovery

public void endRecovery()
                 throws RecoveryException
Release internal resources held after call to startRecovery().

Specified by:
endRecovery in interface XAResourceProducer
Throws:
RecoveryException - thrown when an error occured while releasing reserved resources.

setFailed

public void setFailed(boolean failed)
Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

Specified by:
setFailed in interface XAResourceProducer
Parameters:
failed - true is the resource must be considered failed, false it it must be considered sane.

findXAResourceHolder

public XAResourceHolder findXAResourceHolder(XAResource xaResource)
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.

Specified by:
findXAResourceHolder in interface XAResourceProducer
Parameters:
xaResource - the XAResource to look for.
Returns:
the associated XAResourceHolder or null if the XAResource does not belong to this XAResourceProducer.

init

public void init()
Initialize this XAResourceProducer's internal resources.

Specified by:
init in interface XAResourceProducer

close

public void close()
Release this XAResourceProducer's internal resources.

Specified by:
close in interface XAResourceProducer

createPooledConnection

public XAStatefulHolder createPooledConnection(Object xaFactory,
                                               ResourceBean bean)
                                        throws Exception
Create a XAStatefulHolder that will be placed in an XAPool.

Specified by:
createPooledConnection in interface XAResourceProducer
Parameters:
xaFactory - the vendor's resource-specific XA factory.
bean - the resource-specific bean describing the resource parameters.
Returns:
a XAStatefulHolder that will be placed in an XAPool.
Throws:
Exception - thrown when the XAStatefulHolder cannot be created.

getReference

public Reference getReference()
                       throws NamingException

Specified by:
getReference in interface Referenceable
Throws:
NamingException


Copyright © 2006-2011 Bitronix Software. All Rights Reserved.