Interface Transaction<E extends Endpoint<?>>

Type Parameters:
E - The parent of this Transaction either a TransactionController or TransactionManager
All Known Implementing Classes:
ProtonTransaction

public interface Transaction<E extends Endpoint<?>>
A Transaction object that hold information and context for a single Transaction.
  • Method Details

    • getState

      TransactionState getState()
      Returns:
      the current Transaction state.
    • getDischargeState

      Transaction.DischargeState getDischargeState()
      For a Transaction that has either been requested to discharge or has successfully discharged the Transaction.DischargeState reflects whether the transaction was to be committed or rolled back. Prior to a discharge being attempted there is no state value and this method returns a Transaction.DischargeState of none.
      Returns:
      the current Transaction.DischargeState of the transaction.
    • isDeclared

      boolean isDeclared()
      Returns:
      true if the Transaction has been marked declared by the TransactionManager.
    • isDischarged

      boolean isDischarged()
      Returns:
      true if the Transaction has been marked discharged by the TransactionManager.
    • isFailed

      boolean isFailed()
      The parent resource will mark the Transaction as failed is any of the operations performed on it cannot be successfully completed such as a Declare operation failing to write due to an IO error.
      Returns:
      true if the Transaction has been marked failed by the parent resource.
    • getCondition

      ErrorCondition getCondition()
      If the declare or discharge of the transaction caused its state to become TransactionState FAILED this method returns the ErrorCondition that the remote used to describe the reason for the failure.
      Returns:
      the ErrorCondition that the TransactionManager used to fail the Transaction.
    • parent

      E parent()
      Returns a reference to the parent of this Transaction which will be either a TransactionController or a TransactionManager manager depending on the end of the Link that is operating on the Transaction.
      Returns:
      a reference to the parent of this Transaction.
    • getTxnId

      Binary getTxnId()
      Returns the transaction Id that is associated with the declared transaction. Prior to a TransactionManager completing a transaction declaration this method will return null to indicate that the transaction has not been declared yet.
      Returns:
      the transaction Id associated with the transaction once successfully declared.
    • getAttachments

      Attachments getAttachments()
      Returns:
      the Attachments instance that is associated with this Transaction
    • setLinkedResource

      void setLinkedResource(Object resource)
      Links a given resource to this Transaction.
      Parameters:
      resource - The resource to link to this Transaction.
    • getLinkedResource

      Object getLinkedResource()
      Returns:
      the user set linked resource for this Transaction instance.
    • getLinkedResource

      <T> T getLinkedResource(Class<T> typeClass)
      Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.
      Type Parameters:
      T - The type to cast the linked resource to if one is set.
      Parameters:
      typeClass - the type's Class which is used for casting the returned value.
      Returns:
      the user set linked resource for this Context instance.
      Throws:
      ClassCastException - if the linked resource cannot be cast to the type requested.