Class TransactionMetadata
- java.lang.Object
-
- org.seedstack.seed.transaction.spi.TransactionMetadata
-
public class TransactionMetadata extends Object
This class holds transaction metadata attributes.
-
-
Constructor Summary
Constructors Constructor Description TransactionMetadata()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetadata(String key, Object value)Add additional metadata.Class<? extends ExceptionHandler>getExceptionHandler()Get the exception handler of the associated transaction.Class<? extends TransactionHandler>getHandler()Get the transaction handler of the associated transaction.ObjectgetMetadata(String key)Get additional metadata.Class<? extends Exception>[]getNoRollbackFor()Get the exception classes on which the associated transaction will NOT be rollbacked.PropagationgetPropagation()Get the propagation of the associated transaction.StringgetResource()Get the name of the transacted resource (must be unique per transaction handler).Class<? extends Exception>[]getRollbackOn()Get the exception classes on which the associated transaction will be rollbacked.BooleanisReadOnly()Check if the associated transaction is read-only.BooleanisRollbackOnParticipationFailure()Check if the associated participating transaction should mark the whole transaction as rollback-only.TransactionMetadatamergeFrom(TransactionMetadata other)Merge this instance with another one, which has precedence (i.e.TransactionMetadatamergeFrom(Transactional other)Merge this instance with metadata defined in aTransactionalannotation, which has precedence over this instance.voidsetExceptionHandler(Class<? extends ExceptionHandler> exceptionHandler)Set the exception handler of the associated transaction.voidsetHandler(Class<? extends TransactionHandler> handler)Set the transaction handler of the associated transaction.voidsetNoRollbackFor(Class<? extends Exception>[] noRollbackFor)Set the exception classes on which the associated transaction will NOT be rollbacked.voidsetPropagation(Propagation propagation)Set the propagation of the associated transaction.voidsetReadOnly(Boolean readOnly)Set if the associated transaction is read-only.voidsetResource(String resource)Set the name of the transacted resource (must be unique per transaction handler).voidsetRollbackOn(Class<? extends Exception>[] rollbackOn)Set the exception classes on which the associated transaction will be rollbacked.voidsetRollbackOnParticipationFailure(Boolean rollbackOnParticipationFailure)Set if the associated participating transaction should mark the whole transaction as rollback-only.StringtoString()
-
-
-
Method Detail
-
getPropagation
public Propagation getPropagation()
Get the propagation of the associated transaction.- Returns:
- the
Propagationinstance.
-
setPropagation
public void setPropagation(Propagation propagation)
Set the propagation of the associated transaction.- Parameters:
propagation- thePropagationinstance.
-
isReadOnly
public Boolean isReadOnly()
Check if the associated transaction is read-only.- Returns:
- true if read-only, false otherwise.
-
setReadOnly
public void setReadOnly(Boolean readOnly)
Set if the associated transaction is read-only.- Parameters:
readOnly- true if read-only, false otherwise.
-
isRollbackOnParticipationFailure
public Boolean isRollbackOnParticipationFailure()
Check if the associated participating transaction should mark the whole transaction as rollback-only.- Returns:
- true if it marks it as rollback-only, false otherwise.
-
setRollbackOnParticipationFailure
public void setRollbackOnParticipationFailure(Boolean rollbackOnParticipationFailure)
Set if the associated participating transaction should mark the whole transaction as rollback-only.- Parameters:
rollbackOnParticipationFailure- true if it marks it as rollback-only, false otherwise.
-
getRollbackOn
public Class<? extends Exception>[] getRollbackOn()
Get the exception classes on which the associated transaction will be rollbacked.- Returns:
- the exception classes array.
-
setRollbackOn
public void setRollbackOn(Class<? extends Exception>[] rollbackOn)
Set the exception classes on which the associated transaction will be rollbacked.- Parameters:
rollbackOn- the exception classes array.
-
getNoRollbackFor
public Class<? extends Exception>[] getNoRollbackFor()
Get the exception classes on which the associated transaction will NOT be rollbacked.- Returns:
- the exception classes array.
-
setNoRollbackFor
public void setNoRollbackFor(Class<? extends Exception>[] noRollbackFor)
Set the exception classes on which the associated transaction will NOT be rollbacked.- Parameters:
noRollbackFor- the exception classes array.
-
getHandler
public Class<? extends TransactionHandler> getHandler()
Get the transaction handler of the associated transaction.- Returns:
- the transaction handler class.
-
setHandler
public void setHandler(Class<? extends TransactionHandler> handler)
Set the transaction handler of the associated transaction.- Parameters:
handler- the transaction handler class.
-
getResource
public String getResource()
Get the name of the transacted resource (must be unique per transaction handler).- Returns:
- the name of the transacted resource.
-
setResource
public void setResource(String resource)
Set the name of the transacted resource (must be unique per transaction handler).- Parameters:
resource- the name of the transacted resource.
-
getExceptionHandler
public Class<? extends ExceptionHandler> getExceptionHandler()
Get the exception handler of the associated transaction.- Returns:
- the exception handler class.
-
setExceptionHandler
public void setExceptionHandler(Class<? extends ExceptionHandler> exceptionHandler)
Set the exception handler of the associated transaction.- Parameters:
exceptionHandler- the exception handler class.
-
getMetadata
public Object getMetadata(String key)
Get additional metadata.- Parameters:
key- the key of the metadata to retrieve.- Returns:
- the value of the metadata.
-
addMetadata
public void addMetadata(String key, Object value)
Add additional metadata.- Parameters:
key- the key of the metadata to add.value- the value of the metadata to add.
-
mergeFrom
public TransactionMetadata mergeFrom(TransactionMetadata other)
Merge this instance with another one, which has precedence (i.e. every non null attribute will override the corresponding one on this instance).- Parameters:
other- the instance to merge from.- Returns:
- this instance, merged.
-
mergeFrom
public TransactionMetadata mergeFrom(Transactional other)
Merge this instance with metadata defined in aTransactionalannotation, which has precedence over this instance.- Parameters:
other- the annotation to merge from.- Returns:
- this instance, merged.
-
-