Class StreamingTransactionCapableUtil
java.lang.Object
org.broadleafcommerce.common.util.StreamingTransactionCapableUtil
- All Implemented Interfaces:
StreamingTransactionCapable
@Component("blStreamingTransactionCapableUtil")
@Scope("prototype")
public class StreamingTransactionCapableUtil
extends Object
implements StreamingTransactionCapable
- Author:
- Jeff Fischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManagerFactoryprotected intprotected org.springframework.transaction.PlatformTransactionManagerprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <G extends Throwable>
voidendTransaction(org.springframework.transaction.TransactionStatus status, boolean error, Class<G> exceptionType, org.springframework.transaction.PlatformTransactionManager transactionManager) intThe result set size per page of data when streaming.intorg.springframework.transaction.PlatformTransactionManagervoidinit()voidExecutes the Runnable operation in the scope of an Entity-Manager-In-View pattern, if there is not already an EntityManager on the thread.<G extends Throwable>
voidrunOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction) Run an operation inside of a single transaction.<G extends Throwable>
voidrunOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction, int transactionBehavior, int isolationLevel) <G extends Throwable>
voidrunOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction, int transactionBehavior, int isolationLevel, boolean readOnly, org.springframework.transaction.PlatformTransactionManager transactionManager) <G extends Throwable>
voidrunStreamingTransactionalOperation(StreamCapableTransactionalOperation streamOperation, Class<G> exceptionType) Run a streaming operation inside a transaction.<G extends Throwable>
voidrunStreamingTransactionalOperation(StreamCapableTransactionalOperation streamOperation, Class<G> exceptionType, int transactionBehavior, int isolationLevel) <G extends Throwable>
voidrunTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType) Run an operation inside of a single transaction.<G extends Throwable>
voidrunTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, int transactionBehavior, int isolationLevel) <G extends Throwable>
voidrunTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, org.springframework.transaction.PlatformTransactionManager transactionManager) voidsetPageSize(int pageSize) voidsetRetryMax(int retryMax) voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) protected org.springframework.transaction.TransactionStatusstartTransaction(int propagationBehavior, int isolationLevel, boolean isReadOnly, org.springframework.transaction.PlatformTransactionManager transactionManager)
-
Field Details
-
platformTransactionManager
protected org.springframework.transaction.PlatformTransactionManager platformTransactionManager -
emf
protected jakarta.persistence.EntityManagerFactory emf -
retryMax
@Value("${streaming.transaction.lock.retry.max}") protected int retryMax -
pageSize
@Value("${streaming.transaction.item.page.size}") protected int pageSize
-
-
Constructor Details
-
StreamingTransactionCapableUtil
public StreamingTransactionCapableUtil()
-
-
Method Details
-
init
@PostConstruct public void init() -
runStreamingTransactionalOperation
public <G extends Throwable> void runStreamingTransactionalOperation(StreamCapableTransactionalOperation streamOperation, Class<G> exceptionType) throws G Description copied from interface:StreamingTransactionCapableRun a streaming operation inside a transaction. Uses theStreamCapableTransactionalOperationAPI to determine the page of data to work on within the transaction scope.- Specified by:
runStreamingTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G
-
runStreamingTransactionalOperation
public <G extends Throwable> void runStreamingTransactionalOperation(StreamCapableTransactionalOperation streamOperation, Class<G> exceptionType, int transactionBehavior, int isolationLevel) throws G - Specified by:
runStreamingTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G extends Throwable
-
runTransactionalOperation
public <G extends Throwable> void runTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType) throws G Description copied from interface:StreamingTransactionCapableRun an operation inside of a single transaction. This is not a streaming use case and represents a basic operation to perform in a transaction. SeeTransactionalOperation.execute().- Specified by:
runTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G
-
runTransactionalOperation
public <G extends Throwable> void runTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, org.springframework.transaction.PlatformTransactionManager transactionManager) throws G - Specified by:
runTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G extends Throwable
-
runTransactionalOperation
public <G extends Throwable> void runTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, int transactionBehavior, int isolationLevel) throws G - Specified by:
runTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G extends Throwable
-
runOptionalTransactionalOperation
public <G extends Throwable> void runOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction) throws G Description copied from interface:StreamingTransactionCapableRun an operation inside of a single transaction. This is not a streaming use case and represents a basic operation to perform in a transaction. SeeTransactionalOperation.execute(). The useTransaction parameter allows the inclusion of some logic to determine whether or not the creation of the transaction is required for the operation. This is useful in situations where there may already be an active transaction that you want to use, if available.- Specified by:
runOptionalTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G
-
runOptionalTransactionalOperation
public <G extends Throwable> void runOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction, int transactionBehavior, int isolationLevel) throws G - Specified by:
runOptionalTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G extends Throwable
-
runOptionalEntityManagerInViewOperation
Description copied from interface:StreamingTransactionCapableExecutes the Runnable operation in the scope of an Entity-Manager-In-View pattern, if there is not already an EntityManager on the thread. This is useful for operations that may be susceptible to lazy init exceptions if there is not an EntityManager available on the thread.- Specified by:
runOptionalEntityManagerInViewOperationin interfaceStreamingTransactionCapable
-
runOptionalTransactionalOperation
public <G extends Throwable> void runOptionalTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, boolean useTransaction, int transactionBehavior, int isolationLevel, boolean readOnly, org.springframework.transaction.PlatformTransactionManager transactionManager) throws G - Specified by:
runOptionalTransactionalOperationin interfaceStreamingTransactionCapable- Throws:
G extends Throwable
-
getPageSize
public int getPageSize()Description copied from interface:StreamingTransactionCapableThe result set size per page of data when streaming. SeeStreamingTransactionCapable.runStreamingTransactionalOperation(StreamCapableTransactionalOperation, Class).- Specified by:
getPageSizein interfaceStreamingTransactionCapable- Returns:
-
setPageSize
public void setPageSize(int pageSize) - Specified by:
setPageSizein interfaceStreamingTransactionCapable
-
getTransactionManager
public org.springframework.transaction.PlatformTransactionManager getTransactionManager()- Specified by:
getTransactionManagerin interfaceStreamingTransactionCapable
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) - Specified by:
setTransactionManagerin interfaceStreamingTransactionCapable
-
getRetryMax
public int getRetryMax()- Specified by:
getRetryMaxin interfaceStreamingTransactionCapable
-
setRetryMax
public void setRetryMax(int retryMax) - Specified by:
setRetryMaxin interfaceStreamingTransactionCapable
-
endTransaction
protected <G extends Throwable> void endTransaction(org.springframework.transaction.TransactionStatus status, boolean error, Class<G> exceptionType, org.springframework.transaction.PlatformTransactionManager transactionManager) throws G - Throws:
G extends Throwable
-
startTransaction
protected org.springframework.transaction.TransactionStatus startTransaction(int propagationBehavior, int isolationLevel, boolean isReadOnly, org.springframework.transaction.PlatformTransactionManager transactionManager)
-