Package org.apache.qpid.protonj2.engine
Interface Transaction<E extends Endpoint<?>>
- Type Parameters:
E- The parent of this Transaction either aTransactionControllerorTransactionManager
- All Known Implementing Classes:
ProtonTransaction
public interface Transaction<E extends Endpoint<?>>
A Transaction object that hold information and context for a single
Transaction.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionIf the declare or discharge of the transaction caused its state to becomeTransactionStateFAILED this method returns theErrorConditionthat the remote used to describe the reason for the failure.For aTransactionthat has either been requested to discharge or has successfully discharged theTransaction.DischargeStatereflects whether the transaction was to be committed or rolled back.<T> TgetLinkedResource(Class<T> typeClass) Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.getState()getTxnId()Returns the transaction Id that is associated with the declared transaction.booleanbooleanbooleanisFailed()The parent resource will mark theTransactionas failed is any of the operations performed on it cannot be successfully completed such as aDeclareoperation failing to write due to an IO error.parent()Returns a reference to the parent of thisTransactionwhich will be either aTransactionControlleror aTransactionManagermanager depending on the end of theLinkthat is operating on theTransaction.voidsetLinkedResource(Object resource) Links a given resource to thisTransaction.
-
Method Details
-
getState
TransactionState getState()- Returns:
- the current
Transactionstate.
-
getDischargeState
Transaction.DischargeState getDischargeState()For aTransactionthat has either been requested to discharge or has successfully discharged theTransaction.DischargeStatereflects 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 aTransaction.DischargeStateof none.- Returns:
- the current
Transaction.DischargeStateof the transaction.
-
isDeclared
boolean isDeclared()- Returns:
- true if the
Transactionhas been marked declared by theTransactionManager.
-
isDischarged
boolean isDischarged()- Returns:
- true if the
Transactionhas been marked discharged by theTransactionManager.
-
isFailed
boolean isFailed()The parent resource will mark theTransactionas failed is any of the operations performed on it cannot be successfully completed such as aDeclareoperation failing to write due to an IO error.- Returns:
- true if the
Transactionhas been marked failed by the parent resource.
-
getCondition
ErrorCondition getCondition()If the declare or discharge of the transaction caused its state to becomeTransactionStateFAILED this method returns theErrorConditionthat the remote used to describe the reason for the failure.- Returns:
- the
ErrorConditionthat theTransactionManagerused to fail theTransaction.
-
parent
E parent()Returns a reference to the parent of thisTransactionwhich will be either aTransactionControlleror aTransactionManagermanager depending on the end of theLinkthat is operating on theTransaction.- 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 aTransactionManagercompleting 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
Attachmentsinstance that is associated with thisTransaction
-
setLinkedResource
Links a given resource to thisTransaction.- Parameters:
resource- The resource to link to thisTransaction.
-
getLinkedResource
Object getLinkedResource()- Returns:
- the user set linked resource for this
Transactioninstance.
-
getLinkedResource
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.
-