Class AbstractBatchJobHandler<T extends BatchConfiguration>
- java.lang.Object
-
- org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler<T>
-
- All Implemented Interfaces:
BatchJobHandler<T>
,OptimisticLockingListener
,JobHandler<BatchJobConfiguration>
- Direct Known Subclasses:
BatchSetRemovalTimeJobHandler
,BatchSetVariablesHandler
,DecisionSetRemovalTimeJobHandler
,DeleteHistoricDecisionInstancesJobHandler
,DeleteHistoricProcessInstancesJobHandler
,DeleteProcessInstancesJobHandler
,MessageCorrelationBatchJobHandler
,MigrationBatchJobHandler
,ModificationBatchJobHandler
,ProcessSetRemovalTimeJobHandler
,RestartProcessInstancesJobHandler
,SetExternalTaskRetriesJobHandler
,SetJobRetriesJobHandler
,UpdateProcessInstancesSuspendStateJobHandler
public abstract class AbstractBatchJobHandler<T extends BatchConfiguration> extends Object implements BatchJobHandler<T>, OptimisticLockingListener
Common methods for batch job handlers based on list of ids, providing serialization, configuration instantiation, etc.- Author:
- Askar Akhmerov
-
-
Constructor Summary
Constructors Constructor Description AbstractBatchJobHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected JobEntity
createBatchJob(BatchEntity batch, ByteArrayEntity configuration)
protected abstract T
createJobConfiguration(T configuration, List<String> processIdsForJob)
protected void
createJobEntities(BatchEntity batch, T configuration, String deploymentId, List<String> processIds, int invocationsPerBatchJob)
boolean
createJobs(BatchEntity batch)
Creates batch jobs for a batch.void
deleteJobs(BatchEntity batch)
Delete all jobs for a batch.void
execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId)
protected abstract void
executeHandler(T configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId)
OptimisticLockingResult
failedOperation(DbOperation operation)
Signifies that an operation failed due to optimistic locking.Class<? extends DbEntity>
getEntityType()
The type of the entity for which this listener should be notified.abstract JobDeclaration<BatchJobContext,MessageEntity>
getJobDeclaration()
Get the job declaration for batch jobs.protected abstract AbstractBatchConfigurationObjectConverter<T>
getJsonConverterInstance()
BatchJobConfiguration
newConfiguration(String canonicalString)
void
onDelete(BatchJobConfiguration configuration, JobEntity jobEntity)
Clean up before job is deleted.protected void
postProcessJob(T configuration, JobEntity job, T jobConfiguration)
T
readConfiguration(byte[] serializedConfiguration)
Read the serialized configuration of the batch.protected void
sanitizeMappings(DeploymentMappings idMappings, List<String> ids)
protected ByteArrayEntity
saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration)
byte[]
writeConfiguration(T configuration)
Converts the configuration of the batch to a byte array.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.camunda.bpm.engine.impl.jobexecutor.JobHandler
getType
-
-
-
-
Method Detail
-
getJobDeclaration
public abstract JobDeclaration<BatchJobContext,MessageEntity> getJobDeclaration()
Description copied from interface:BatchJobHandler
Get the job declaration for batch jobs.- Specified by:
getJobDeclaration
in interfaceBatchJobHandler<T extends BatchConfiguration>
- Returns:
- the batch job declaration
-
createJobs
public boolean createJobs(BatchEntity batch)
Description copied from interface:BatchJobHandler
Creates batch jobs for a batch.- Specified by:
createJobs
in interfaceBatchJobHandler<T extends BatchConfiguration>
- Parameters:
batch
- the batch to create jobs for- Returns:
- true of no more jobs have to be created for this batch, false otherwise
-
execute
public final void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId)
- Specified by:
execute
in interfaceJobHandler<T extends BatchConfiguration>
-
executeHandler
protected abstract void executeHandler(T configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId)
-
sanitizeMappings
protected void sanitizeMappings(DeploymentMappings idMappings, List<String> ids)
-
createJobEntities
protected void createJobEntities(BatchEntity batch, T configuration, String deploymentId, List<String> processIds, int invocationsPerBatchJob)
-
createJobConfiguration
protected abstract T createJobConfiguration(T configuration, List<String> processIdsForJob)
-
createBatchJob
protected JobEntity createBatchJob(BatchEntity batch, ByteArrayEntity configuration)
-
deleteJobs
public void deleteJobs(BatchEntity batch)
Description copied from interface:BatchJobHandler
Delete all jobs for a batch.- Specified by:
deleteJobs
in interfaceBatchJobHandler<T extends BatchConfiguration>
- Parameters:
batch
- the batch to delete jobs for
-
newConfiguration
public BatchJobConfiguration newConfiguration(String canonicalString)
- Specified by:
newConfiguration
in interfaceJobHandler<T extends BatchConfiguration>
-
onDelete
public void onDelete(BatchJobConfiguration configuration, JobEntity jobEntity)
Description copied from interface:JobHandler
Clean up before job is deleted. Like removing of auxiliary entities specific for this job handler.- Specified by:
onDelete
in interfaceJobHandler<T extends BatchConfiguration>
- Parameters:
configuration
- the job handler configurationjobEntity
- the job entity to be deleted
-
saveConfiguration
protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration)
-
writeConfiguration
public byte[] writeConfiguration(T configuration)
Description copied from interface:BatchJobHandler
Converts the configuration of the batch to a byte array.- Specified by:
writeConfiguration
in interfaceBatchJobHandler<T extends BatchConfiguration>
- Parameters:
configuration
- the configuration object- Returns:
- the serialized configuration
-
readConfiguration
public T readConfiguration(byte[] serializedConfiguration)
Description copied from interface:BatchJobHandler
Read the serialized configuration of the batch.- Specified by:
readConfiguration
in interfaceBatchJobHandler<T extends BatchConfiguration>
- Parameters:
serializedConfiguration
- the serialized configuration- Returns:
- the deserialized configuration object
-
getJsonConverterInstance
protected abstract AbstractBatchConfigurationObjectConverter<T> getJsonConverterInstance()
-
getEntityType
public Class<? extends DbEntity> getEntityType()
Description copied from interface:OptimisticLockingListener
The type of the entity for which this listener should be notified. If the implementation returns 'null', the listener is notified for all entity types.- Specified by:
getEntityType
in interfaceOptimisticLockingListener
- Returns:
- the entity type for which the listener should be notified.
-
failedOperation
public OptimisticLockingResult failedOperation(DbOperation operation)
Description copied from interface:OptimisticLockingListener
Signifies that an operation failed due to optimistic locking.- Specified by:
failedOperation
in interfaceOptimisticLockingListener
- Parameters:
operation
- the failed operation.- Returns:
OptimisticLockingResult
that instructs the caller how to handle the result of the failed operation.
-
-