org.alfresco.repo.transaction
Class AlfrescoTransactionSupport

java.lang.Object
  extended by org.alfresco.repo.transaction.AlfrescoTransactionSupport

public abstract class AlfrescoTransactionSupport
extends java.lang.Object

Helper class to manage transaction synchronization. This provides helpers to ensure that the necessary TransactionSynchronization instances are registered on behalf of the application code.


Nested Class Summary
static class AlfrescoTransactionSupport.TxnReadState
           
 
Field Summary
static int SESSION_SYNCHRONIZATION_ORDER
          The order of synchronization set to be 100 less than the Hibernate synchronization order
 
Constructor Summary
AlfrescoTransactionSupport()
           
 
Method Summary
static void bindDaoService(TransactionalDao daoService)
          Method that registers a NodeDaoService against the transaction.
static void bindIntegrityChecker(IntegrityChecker integrityChecker)
          Method that registers an IntegrityChecker against the transaction.
static void bindListener(TransactionListener listener)
          Method that registers a LuceneIndexerAndSearcherFactory against the transaction.
static void bindLucene(LuceneIndexerAndSearcher indexerAndSearcher)
          Method that registers a LuceneIndexerAndSearcherFactory against the transaction.
static void bindResource(java.lang.Object key, java.lang.Object resource)
          Binds a resource to the current transaction, which must be active.
static void checkTransactionReadState(boolean requireReadWrite)
          Checks the state of the current transaction and throws an exception if a transaction is not present or if the transaction is not read-write, if required.
static void flush()
          Deprecated. No longer does anything
static java.lang.Object getResource(java.lang.Object key)
          Gets a resource associated with the current transaction, which must be active.
static java.lang.String getTransactionId()
          Get a unique identifier associated with each transaction of each thread.
static AlfrescoTransactionSupport.TxnReadState getTransactionReadState()
           
static long getTransactionStartTime()
           
static boolean isActualTransactionActive()
           
static boolean isDirty()
          Deprecated. To be replaced by DirtySessionMethodInterceptor
static void unbindResource(java.lang.Object key)
          Unbinds a resource from the current transaction, which must be active.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_SYNCHRONIZATION_ORDER

public static final int SESSION_SYNCHRONIZATION_ORDER
The order of synchronization set to be 100 less than the Hibernate synchronization order

See Also:
Constant Field Values
Constructor Detail

AlfrescoTransactionSupport

public AlfrescoTransactionSupport()
Method Detail

getTransactionStartTime

public static long getTransactionStartTime()
Returns:
Returns the system time when the transaction started, or -1 if there is no current transaction.

getTransactionId

public static java.lang.String getTransactionId()
Get a unique identifier associated with each transaction of each thread. Null is returned if no transaction is currently active.

Returns:
Returns the transaction ID, or null if no transaction is present

isActualTransactionActive

public static boolean isActualTransactionActive()

getTransactionReadState

public static AlfrescoTransactionSupport.TxnReadState getTransactionReadState()
Returns:
Returns the read-write state of the current transaction
Since:
2.1.4

checkTransactionReadState

public static void checkTransactionReadState(boolean requireReadWrite)
Checks the state of the current transaction and throws an exception if a transaction is not present or if the transaction is not read-write, if required.

Parameters:
requireReadWrite - true if the transaction must be read-write
Since:
3.2

isDirty

public static boolean isDirty()
Deprecated. To be replaced by DirtySessionMethodInterceptor

Are there any pending changes which must be synchronized with the store?

Returns:
true => changes are pending

getResource

public static java.lang.Object getResource(java.lang.Object key)
Gets a resource associated with the current transaction, which must be active.

All necessary synchronization instances will be registered automatically, if required.

Parameters:
key - the thread resource map key
Returns:
Returns a thread resource of null if not present
See Also:
for helper methods to create and bind common collection types

bindResource

public static void bindResource(java.lang.Object key,
                                java.lang.Object resource)
Binds a resource to the current transaction, which must be active.

All necessary synchronization instances will be registered automatically, if required.

Parameters:
key -
resource -

unbindResource

public static void unbindResource(java.lang.Object key)
Unbinds a resource from the current transaction, which must be active.

All necessary synchronization instances will be registered automatically, if required.

Parameters:
key -

bindDaoService

public static void bindDaoService(TransactionalDao daoService)
Method that registers a NodeDaoService against the transaction. Setting this will ensure that the pre- and post-commit operations perform the necessary cleanups against the NodeDaoService.

This method can be called repeatedly as long as the service being bound implements equals and hashCode.

Parameters:
daoService -

bindIntegrityChecker

public static void bindIntegrityChecker(IntegrityChecker integrityChecker)
Method that registers an IntegrityChecker against the transaction. Setting this will ensure that the pre- and post-commit operations perform the necessary cleanups against the IntegrityChecker.

This method can be called repeatedly as long as the service being bound implements equals and hashCode.

Parameters:
integrityChecker -

bindLucene

public static void bindLucene(LuceneIndexerAndSearcher indexerAndSearcher)
Method that registers a LuceneIndexerAndSearcherFactory against the transaction.

Setting this will ensure that the pre- and post-commit operations perform the necessary cleanups against the LuceneIndexerAndSearcherFactory.

Although bound within a Set, it would still be better for the caller to only bind once per transaction, if possible.

Parameters:
indexerAndSearcher - the Lucene indexer to perform transaction completion tasks on

bindListener

public static void bindListener(TransactionListener listener)
Method that registers a LuceneIndexerAndSearcherFactory against the transaction.

Setting this will ensure that the pre- and post-commit operations perform the necessary cleanups against the LuceneIndexerAndSearcherFactory.

Although bound within a Set, it would still be better for the caller to only bind once per transaction, if possible.

Parameters:
indexerAndSearcher - the Lucene indexer to perform transaction completion tasks on

flush

public static void flush()
Deprecated. No longer does anything

No-op



Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.