org.jvnet.hk2.config
Class Transaction

java.lang.Object
  extended by org.jvnet.hk2.config.Transaction

public class Transaction
extends Object

Simple transaction mechanism for config-api objects

Author:
Jerome Dochez

Constructor Summary
Transaction()
           
 
Method Summary
 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>
T
enroll(T source)
          Enroll a configuration object in a transaction and returns a writeable view of it
static
<T extends ConfigBeanProxy>
Transaction
getTransaction(T source)
          Returns the transaction associated with a writable view
 void rollback()
          Rollbacks all participants to this transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public 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, the commit() 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).


Copyright © 2013 Oracle Corporation. All Rights Reserved.