Package org.apache.qpid.protonj2.engine
Interface Transaction<E extends Endpoint<?>>
- Type Parameters:
E
- The parent of this Transaction either aTransactionController
orTransactionManager
- 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
-
Method Summary
Modifier and TypeMethodDescriptionIf the declare or discharge of the transaction caused its state to becomeTransactionState
FAILED this method returns theErrorCondition
that the remote used to describe the reason for the failure.For aTransaction
that has either been requested to discharge or has successfully discharged theTransaction.DischargeState
reflects whether the transaction was to be committed or rolled back.<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.getState()
getTxnId()
Returns the transaction Id that is associated with the declared transaction.boolean
boolean
boolean
isFailed()
The parent resource will mark theTransaction
as failed is any of the operations performed on it cannot be successfully completed such as aDeclare
operation failing to write due to an IO error.parent()
Returns a reference to the parent of thisTransaction
which will be either aTransactionController
or aTransactionManager
manager depending on the end of theLink
that is operating on theTransaction
.void
setLinkedResource
(Object resource) Links a given resource to thisTransaction
.
-
Method Details
-
getState
TransactionState getState()- Returns:
- the current
Transaction
state.
-
getDischargeState
Transaction.DischargeState getDischargeState()For aTransaction
that has either been requested to discharge or has successfully discharged theTransaction.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 aTransaction.DischargeState
of none.- Returns:
- the current
Transaction.DischargeState
of the transaction.
-
isDeclared
boolean isDeclared()- Returns:
- true if the
Transaction
has been marked declared by theTransactionManager
.
-
isDischarged
boolean isDischarged()- Returns:
- true if the
Transaction
has been marked discharged by theTransactionManager
.
-
isFailed
boolean isFailed()The parent resource will mark theTransaction
as failed is any of the operations performed on it cannot be successfully completed such as aDeclare
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 becomeTransactionState
FAILED this method returns theErrorCondition
that the remote used to describe the reason for the failure.- Returns:
- the
ErrorCondition
that theTransactionManager
used to fail theTransaction
.
-
parent
E parent()Returns a reference to the parent of thisTransaction
which will be either aTransactionController
or aTransactionManager
manager depending on the end of theLink
that 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 aTransactionManager
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 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
Transaction
instance.
-
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.
-