Package org.jvnet.hk2.config
Class Transaction
- java.lang.Object
-
- org.jvnet.hk2.config.Transaction
-
public class Transaction extends Object
Simple transaction mechanism for config-api objects- Author:
- Jerome Dochez
-
-
Constructor Summary
Constructors Constructor Description Transaction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCommit()
Tests if the transaction participants will pass the prepare phase successfully.List<PropertyChangeEvent>
commit()
Commits all participants to this transaction<T extends ConfigBeanProxy>
Tenroll(T source)
Enroll a configuration object in a transaction and returns a writeable view of itstatic <T extends ConfigBeanProxy>
TransactiongetTransaction(T source)
Returns the transaction associated with a writable viewvoid
rollback()
Rollbacks all participants to this transaction.
-
-
-
Method Detail
-
rollback
public void rollback()
Rollbacks all participants to this transaction.
-
canCommit
public boolean canCommit() throws TransactionFailure
Tests if the transaction participants will pass the prepare phase successfully. The prepare phase will invoke validation of the changes, so a positive return usually means the changes are valid and unless a external factor arise, thecommit()
method will succeed.- Returns:
- true if the participants changes are valid, false otherwise
- Throws:
TransactionFailure
- if the changes are not valid
-
commit
public List<PropertyChangeEvent> commit() throws RetryableException, TransactionFailure
Commits all participants to this transaction- Returns:
- list of PropertyChangeEvent for the changes that were applied to the participants during the transaction.
- Throws:
RetryableException
- if the transaction cannot commit at this time but could succeed later.TransactionFailure
- if the transaction commit failed.
-
getTransaction
public static <T extends ConfigBeanProxy> Transaction getTransaction(T source)
Returns the transaction associated with a writable view- Parameters:
source
- the proxy to the writable view- Returns:
- the transaction object for that view or null if not transaction is in progress
-
enroll
public <T extends ConfigBeanProxy> T enroll(T source) throws TransactionFailure
Enroll a configuration object in a transaction and returns a writeable view of it- Parameters:
source
- the configured interface implementation- Returns:
- the new interface implementation providing write access
- Throws:
TransactionFailure
- if the object cannot be enrolled (probably already enrolled in another transaction).
-
-