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>
BaseTransactionimplementation that provides the basic functionality needed to manage theTransactionthat 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 ProtonAttachmentsgetAttachments()ErrorConditiongetCondition()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.Transaction.DischargeStategetDischargeState()For aTransactionthat has either been requested to discharge or has successfully discharged theTransaction.DischargeStatereflects whether the transaction was to be committed or rolled back.java.lang.ObjectgetLinkedResource()<T> TgetLinkedResource(java.lang.Class<T> typeClass)Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.TransactionStategetState()BinarygetTxnId()Returns the transaction Id that is associated with the declared transaction.booleanisDeclared()booleanisDischarged()booleanisFailed()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.abstract Eparent()Overridden by theTransactionControllerorTransactionManagerthat creates thisTransactioninstance, this method returns the parent instance that created it.voidsetLinkedResource(java.lang.Object resource)Links a given resource to thisTransaction.
-
-
-
Method Detail
-
getState
public TransactionState getState()
- Specified by:
getStatein interfaceTransaction<E extends Endpoint<?>>- Returns:
- the current
Transactionstate.
-
isDeclared
public boolean isDeclared()
- Specified by:
isDeclaredin interfaceTransaction<E extends Endpoint<?>>- Returns:
- true if the
Transactionhas been marked declared by theTransactionManager.
-
isDischarged
public boolean isDischarged()
- Specified by:
isDischargedin interfaceTransaction<E extends Endpoint<?>>- Returns:
- true if the
Transactionhas been marked discharged by theTransactionManager.
-
isFailed
public boolean isFailed()
Description copied from interface:TransactionThe 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.- Specified by:
isFailedin interfaceTransaction<E extends Endpoint<?>>- Returns:
- true if the
Transactionhas been marked failed by the parent resource.
-
getCondition
public ErrorCondition getCondition()
Description copied from interface:TransactionIf 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.- Specified by:
getConditionin interfaceTransaction<E extends Endpoint<?>>- Returns:
- the
ErrorConditionthat theTransactionManagerused to fail theTransaction.
-
getDischargeState
public Transaction.DischargeState getDischargeState()
Description copied from interface:TransactionFor 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.- Specified by:
getDischargeStatein interfaceTransaction<E extends Endpoint<?>>- Returns:
- the current
Transaction.DischargeStateof the transaction.
-
getTxnId
public Binary getTxnId()
Description copied from interface:TransactionReturns 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.- Specified by:
getTxnIdin 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:TransactionLinks a given resource to thisTransaction.- Specified by:
setLinkedResourcein interfaceTransaction<E extends Endpoint<?>>- Parameters:
resource- The resource to link to thisTransaction.
-
getLinkedResource
public java.lang.Object getLinkedResource()
- Specified by:
getLinkedResourcein interfaceTransaction<E extends Endpoint<?>>- Returns:
- the user set linked resource for this
Transactioninstance.
-
getLinkedResource
public <T> T getLinkedResource(java.lang.Class<T> typeClass)
Description copied from interface:TransactionGets the linked resource (if set) and returns it using the type information provided to cast the returned value.- Specified by:
getLinkedResourcein 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:
getAttachmentsin interfaceTransaction<E extends Endpoint<?>>- Returns:
- the
Attachmentsinstance that is associated with thisTransaction
-
parent
public abstract E parent()
Overridden by theTransactionControllerorTransactionManagerthat creates thisTransactioninstance, this method returns the parent instance that created it.- Specified by:
parentin interfaceTransaction<E extends Endpoint<?>>- Returns:
- the resource that created this
Transaction.
-
-