ehcache

net.sf.ehcache.transaction
Class DelegatingTransactionIDFactory

java.lang.Object
  extended by net.sf.ehcache.transaction.DelegatingTransactionIDFactory
All Implemented Interfaces:
TransactionIDFactory

public class DelegatingTransactionIDFactory
extends Object
implements TransactionIDFactory

A TransactionIDFactory implementation with delegates calls to either a clustered or non-clustered factory

Author:
Ludovic Orban

Constructor Summary
DelegatingTransactionIDFactory(FeaturesManager featuresManager, TerracottaClient terracottaClient, String cacheManagerName)
          Create a new DelegatingTransactionIDFactory
 
Method Summary
 void clear(TransactionID transactionID)
          Clear this transaction's state representation.
 TransactionID createTransactionID()
          Create a unique transaction ID
 XidTransactionID createXidTransactionID(Xid xid, Ehcache cache)
          Create a transaction ID based on a XID for uniqueness
 Set<TransactionID> getAllTransactionIDs()
          Get the set of all known transactions.
 Set<XidTransactionID> getAllXidTransactionIDsFor(Ehcache cache)
          Get the set of all XID transactions of a cache.
 boolean isDecisionCommit(TransactionID transactionID)
          Check if the given transaction should be committed or not
 boolean isExpired(TransactionID transactionID)
          Check if the transaction ID expired, ie: that the transaction died abnormally
 Boolean isPersistent()
          Return true if the factory state is persistent (survives JVM restart).
 void markForCommit(TransactionID transactionID)
          Mark that this transaction's decision is commit
 void markForRollback(XidTransactionID transactionID)
          Mark this transaction ID for rollback
 TransactionID restoreTransactionID(TransactionIDSerializedForm serializedForm)
          Restore a transaction ID from its serialized form
 XidTransactionID restoreXidTransactionID(XidTransactionIDSerializedForm serializedForm)
          Restore a XID transaction ID from its serialized form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingTransactionIDFactory

public DelegatingTransactionIDFactory(FeaturesManager featuresManager,
                                      TerracottaClient terracottaClient,
                                      String cacheManagerName)
Create a new DelegatingTransactionIDFactory

Parameters:
terracottaClient - a terracotta client
cacheManagerName - the name of the cache manager which creates this.
Method Detail

createTransactionID

public TransactionID createTransactionID()
Create a unique transaction ID

Specified by:
createTransactionID in interface TransactionIDFactory
Returns:
a transaction ID

restoreTransactionID

public TransactionID restoreTransactionID(TransactionIDSerializedForm serializedForm)
Restore a transaction ID from its serialized form

Specified by:
restoreTransactionID in interface TransactionIDFactory
Parameters:
serializedForm - the TransactionID serialized form
Returns:
the restored TransactionID

createXidTransactionID

public XidTransactionID createXidTransactionID(Xid xid,
                                               Ehcache cache)
Create a transaction ID based on a XID for uniqueness

Specified by:
createXidTransactionID in interface TransactionIDFactory
Parameters:
xid - the XID
Returns:
a transaction ID

restoreXidTransactionID

public XidTransactionID restoreXidTransactionID(XidTransactionIDSerializedForm serializedForm)
Restore a XID transaction ID from its serialized form

Specified by:
restoreXidTransactionID in interface TransactionIDFactory
Parameters:
serializedForm - the XidTransactionID serialized form
Returns:
the restored XidTransactionID

markForCommit

public void markForCommit(TransactionID transactionID)
Description copied from interface: TransactionIDFactory
Mark that this transaction's decision is commit

Specified by:
markForCommit in interface TransactionIDFactory
Parameters:
transactionID - transaction to be marked

markForRollback

public void markForRollback(XidTransactionID transactionID)
Description copied from interface: TransactionIDFactory
Mark this transaction ID for rollback

Specified by:
markForRollback in interface TransactionIDFactory

isDecisionCommit

public boolean isDecisionCommit(TransactionID transactionID)
Description copied from interface: TransactionIDFactory
Check if the given transaction should be committed or not

Specified by:
isDecisionCommit in interface TransactionIDFactory
Parameters:
transactionID - transaction to be queried
Returns:
true if the transaction should be committed

clear

public void clear(TransactionID transactionID)
Description copied from interface: TransactionIDFactory
Clear this transaction's state representation.

Specified by:
clear in interface TransactionIDFactory
Parameters:
transactionID - transaction to be cleared

getAllXidTransactionIDsFor

public Set<XidTransactionID> getAllXidTransactionIDsFor(Ehcache cache)
Description copied from interface: TransactionIDFactory
Get the set of all XID transactions of a cache.

Specified by:
getAllXidTransactionIDsFor in interface TransactionIDFactory
Returns:
the set of transactions

getAllTransactionIDs

public Set<TransactionID> getAllTransactionIDs()
Description copied from interface: TransactionIDFactory
Get the set of all known transactions.

Specified by:
getAllTransactionIDs in interface TransactionIDFactory
Returns:
the set of transactions

isExpired

public boolean isExpired(TransactionID transactionID)
Description copied from interface: TransactionIDFactory
Check if the transaction ID expired, ie: that the transaction died abnormally

Specified by:
isExpired in interface TransactionIDFactory
Returns:
true if the transaction ID expired and should be cleaned up, false otherwise

isPersistent

public Boolean isPersistent()
Description copied from interface: TransactionIDFactory
Return true if the factory state is persistent (survives JVM restart).

This is a tri-state return:

Specified by:
isPersistent in interface TransactionIDFactory
Returns:
true is state is persistent

ehcache

Copyright 2001-2014, Terracotta, Inc.