Class ProtonTransaction<E extends Endpoint<?>>
- java.lang.Object
-
- org.apache.qpid.protonj2.engine.impl.ProtonTransaction<E>
-
- Type Parameters:
E
- The parent type for thisTransaction
- All Implemented Interfaces:
Transaction<E>
public abstract class ProtonTransaction<E extends Endpoint<?>> extends java.lang.Object implements Transaction<E>
BaseTransaction
implementation that provides the basic functionality needed to manage theTransaction
that it represents.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.qpid.protonj2.engine.Transaction
Transaction.DischargeState
-
-
Constructor Summary
Constructors Constructor Description ProtonTransaction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ProtonAttachments
getAttachments()
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.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.java.lang.Object
getLinkedResource()
<T> T
getLinkedResource(java.lang.Class<T> typeClass)
Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.TransactionState
getState()
Binary
getTxnId()
Returns the transaction Id that is associated with the declared transaction.boolean
isDeclared()
boolean
isDischarged()
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.abstract E
parent()
Overridden by theTransactionController
orTransactionManager
that creates thisTransaction
instance, this method returns the parent instance that created it.void
setLinkedResource(java.lang.Object resource)
Links a given resource to thisTransaction
.
-
-
-
Method Detail
-
getState
public TransactionState getState()
- Specified by:
getState
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the current
Transaction
state.
-
isDeclared
public boolean isDeclared()
- Specified by:
isDeclared
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- true if the
Transaction
has been marked declared by theTransactionManager
.
-
isDischarged
public boolean isDischarged()
- Specified by:
isDischarged
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- true if the
Transaction
has been marked discharged by theTransactionManager
.
-
isFailed
public boolean isFailed()
Description copied from interface:Transaction
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.- Specified by:
isFailed
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- true if the
Transaction
has been marked failed by the parent resource.
-
getCondition
public ErrorCondition getCondition()
Description copied from interface:Transaction
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.- Specified by:
getCondition
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the
ErrorCondition
that theTransactionManager
used to fail theTransaction
.
-
getDischargeState
public Transaction.DischargeState getDischargeState()
Description copied from interface:Transaction
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.- Specified by:
getDischargeState
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the current
Transaction.DischargeState
of the transaction.
-
getTxnId
public Binary getTxnId()
Description copied from interface:Transaction
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.- Specified by:
getTxnId
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the transaction Id associated with the transaction once successfully declared.
-
setLinkedResource
public void setLinkedResource(java.lang.Object resource)
Description copied from interface:Transaction
Links a given resource to thisTransaction
.- Specified by:
setLinkedResource
in interfaceTransaction<E extends Endpoint<?>>
- Parameters:
resource
- The resource to link to thisTransaction
.
-
getLinkedResource
public java.lang.Object getLinkedResource()
- Specified by:
getLinkedResource
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the user set linked resource for this
Transaction
instance.
-
getLinkedResource
public <T> T getLinkedResource(java.lang.Class<T> typeClass)
Description copied from interface:Transaction
Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.- Specified by:
getLinkedResource
in interfaceTransaction<E extends Endpoint<?>>
- 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.
-
getAttachments
public ProtonAttachments getAttachments()
- Specified by:
getAttachments
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the
Attachments
instance that is associated with thisTransaction
-
parent
public abstract E parent()
Overridden by theTransactionController
orTransactionManager
that creates thisTransaction
instance, this method returns the parent instance that created it.- Specified by:
parent
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the resource that created this
Transaction
.
-
-