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.EntityManagerFactory
protected int
protected org.springframework.transaction.PlatformTransactionManager
protected 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) int
The result set size per page of data when streaming.int
org.springframework.transaction.PlatformTransactionManager
void
init()
void
Executes 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) void
setPageSize
(int pageSize) void
setRetryMax
(int retryMax) void
setTransactionManager
(org.springframework.transaction.PlatformTransactionManager transactionManager) protected org.springframework.transaction.TransactionStatus
startTransaction
(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:StreamingTransactionCapable
Run a streaming operation inside a transaction. Uses theStreamCapableTransactionalOperation
API to determine the page of data to work on within the transaction scope.- Specified by:
runStreamingTransactionalOperation
in interfaceStreamingTransactionCapable
- Throws:
G
-
runStreamingTransactionalOperation
public <G extends Throwable> void runStreamingTransactionalOperation(StreamCapableTransactionalOperation streamOperation, Class<G> exceptionType, int transactionBehavior, int isolationLevel) throws G - Specified by:
runStreamingTransactionalOperation
in interfaceStreamingTransactionCapable
- Throws:
G extends Throwable
-
runTransactionalOperation
public <G extends Throwable> void runTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType) throws G Description copied from interface:StreamingTransactionCapable
Run 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:
runTransactionalOperation
in interfaceStreamingTransactionCapable
- Throws:
G
-
runTransactionalOperation
public <G extends Throwable> void runTransactionalOperation(StreamCapableTransactionalOperation operation, Class<G> exceptionType, org.springframework.transaction.PlatformTransactionManager transactionManager) throws G - Specified by:
runTransactionalOperation
in 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:
runTransactionalOperation
in 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:StreamingTransactionCapable
Run 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:
runOptionalTransactionalOperation
in 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:
runOptionalTransactionalOperation
in interfaceStreamingTransactionCapable
- Throws:
G extends Throwable
-
runOptionalEntityManagerInViewOperation
Description copied from interface:StreamingTransactionCapable
Executes 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:
runOptionalEntityManagerInViewOperation
in 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:
runOptionalTransactionalOperation
in interfaceStreamingTransactionCapable
- Throws:
G extends Throwable
-
getPageSize
public int getPageSize()Description copied from interface:StreamingTransactionCapable
The result set size per page of data when streaming. SeeStreamingTransactionCapable.runStreamingTransactionalOperation(StreamCapableTransactionalOperation, Class)
.- Specified by:
getPageSize
in interfaceStreamingTransactionCapable
- Returns:
-
setPageSize
public void setPageSize(int pageSize) - Specified by:
setPageSize
in interfaceStreamingTransactionCapable
-
getTransactionManager
public org.springframework.transaction.PlatformTransactionManager getTransactionManager()- Specified by:
getTransactionManager
in interfaceStreamingTransactionCapable
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) - Specified by:
setTransactionManager
in interfaceStreamingTransactionCapable
-
getRetryMax
public int getRetryMax()- Specified by:
getRetryMax
in interfaceStreamingTransactionCapable
-
setRetryMax
public void setRetryMax(int retryMax) - Specified by:
setRetryMax
in 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)
-