Package org.jvnet.hk2.config
Class Transaction
java.lang.Object
org.jvnet.hk2.config.Transaction
Simple transaction mechanism for config-api objects
- Author:
- Jerome Dochez
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if the transaction participants will pass the prepare phase successfully.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 viewvoidrollback()Rollbacks all participants to this transaction.
-
Constructor Details
-
Transaction
public Transaction()
-
-
Method Details
-
rollback
public void rollback()Rollbacks all participants to this transaction. -
canCommit
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
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
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
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).
-