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 Details

    • Transaction

      public Transaction()
  • Method Details

    • 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

      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).