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 Object
implements Transaction<E>
Base
Transaction
implementation that provides the basic functionality needed
to manage the Transaction
that it represents.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.qpid.protonj2.engine.Transaction
Transaction.DischargeState
-
Constructor 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.abstract E
parent()
Overridden by theTransactionController
orTransactionManager
that creates thisTransaction
instance, this method returns the parent instance that created it.void
setLinkedResource
(Object resource) Links a given resource to thisTransaction
.
-
Constructor Details
-
ProtonTransaction
public ProtonTransaction()
-
-
Method Details
-
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
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
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
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
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
- Specified by:
getLinkedResource
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the user set linked resource for this
Transaction
instance.
-
getLinkedResource
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
- Specified by:
getAttachments
in interfaceTransaction<E extends Endpoint<?>>
- Returns:
- the
Attachments
instance that is associated with thisTransaction
-
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
.
-