Package org.mycore.util.concurrent
Class MCRTransactionableRunnable
java.lang.Object
org.mycore.util.concurrent.MCRTransactionableRunnable
- All Implemented Interfaces:
Runnable
,MCRDecorator<Runnable>
Encapsulates a
Runnable
with a mycore session and a database transaction.- Author:
- Matthias Eichner
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMCRTransactionableRunnable
(Runnable runnable) Creates a newRunnable
encapsulating therun()
method with a newMCRSession
and a database transaction.MCRTransactionableRunnable
(Runnable runnable, MCRSession session) -
Method Summary
-
Field Details
-
runnable
-
-
Constructor Details
-
MCRTransactionableRunnable
Creates a newRunnable
encapsulating therun()
method with a newMCRSession
and a database transaction. Afterwards the transaction will be committed and the session will be released and closed.If you want to execute your runnable in the context of an already existing session use the
MCRTransactionableRunnable(Runnable, MCRSession)
constructor instead.- Parameters:
runnable
- the runnable to execute within a session and transaction
-
MCRTransactionableRunnable
Creates a newRunnable
encapsulating therun()
method with a new a database transaction. The transaction will be created in the context of the given session. Afterwards the transaction will be committed and the session will be released (but not closed!).- Parameters:
runnable
- the runnable to execute within a session and transactionsession
- the session to use
-
-
Method Details
-
run
public void run() -
get
Description copied from interface:MCRDecorator
Returns the enclosing instance.- Specified by:
get
in interfaceMCRDecorator<Runnable>
- Returns:
- the decorated instance
-