Package org.camunda.bpm.engine.impl
Class AbstractDefinitionDeployer<DefinitionEntity extends ResourceDefinitionEntity>
- java.lang.Object
-
- org.camunda.bpm.engine.impl.AbstractDefinitionDeployer<DefinitionEntity>
-
- All Implemented Interfaces:
Deployer
- Direct Known Subclasses:
BpmnDeployer
,CamundaFormDefinitionDeployer
,CmmnDeployer
,DecisionDefinitionDeployer
,DecisionRequirementsDefinitionDeployer
public abstract class AbstractDefinitionDeployer<DefinitionEntity extends ResourceDefinitionEntity> extends Object implements Deployer
Deployer
responsible to parse resource files and create the proper entities. This class is extended by specific resource deployers. Note: Implementations must be thread-safe. In particular they should not keep deployment-specific state.
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
DIAGRAM_SUFFIXES
protected IdGenerator
idGenerator
-
Constructor Summary
Constructors Constructor Description AbstractDefinitionDeployer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addDefinitionToDeploymentCache(DeploymentCache deploymentCache, DefinitionEntity definition)
Add a definition to the deployment cacheprotected void
definitionAddedToDeploymentCache(DeploymentEntity deployment, DefinitionEntity definition, Properties properties)
Called after a definition was added to the deployment cache.void
deploy(DeploymentEntity deployment)
protected void
ensureNoDuplicateDefinitionKeys(List<DefinitionEntity> definitions)
protected abstract DefinitionEntity
findDefinitionByDeploymentAndKey(String deploymentId, String definitionKey)
Find a definition entity by deployment id and definition key.protected abstract DefinitionEntity
findLatestDefinitionByKeyAndTenantId(String definitionKey, String tenantId)
Find the last deployed definition entity by definition key and tenant id.protected String
generateDefinitionId(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition)
create an id for the definition.protected CommandContext
getCommandContext()
protected String
getDefinitionDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix)
protected DeploymentCache
getDeploymentCache()
protected String
getDiagramResourceForDefinition(DeploymentEntity deployment, String resourceName, DefinitionEntity definition, Map<String,ResourceEntity> resources)
Returns the default name of the image resource for a certain definition.protected String[]
getDiagramSuffixes()
protected String
getGeneralDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix)
IdGenerator
getIdGenerator()
protected int
getNextVersion(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition)
per default we increment the latest definition version by one - but you might want to hook in some own logic here, e.g.protected ProcessEngineConfigurationImpl
getProcessEngineConfiguration()
protected abstract String[]
getResourcesSuffixes()
protected void
handlePersistedDefinition(DefinitionEntity definition, DefinitionEntity persistedDefinition, DeploymentEntity deployment, Properties properties)
protected boolean
isResourceHandled(ResourceEntity resource)
protected void
loadDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
protected List<DefinitionEntity>
parseDefinitionResources(DeploymentEntity deployment, Properties properties)
protected abstract void
persistDefinition(DefinitionEntity definition)
Persist definition entity into the database.protected void
persistDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
protected void
persistedDefinitionLoaded(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition)
Called when a previous version of a definition was loaded from the persistent store.protected void
postProcessDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
protected void
registerDefinition(DeploymentEntity deployment, DefinitionEntity definition, Properties properties)
void
setIdGenerator(IdGenerator idGenerator)
protected String
stripDefinitionFileSuffix(String resourceName)
protected abstract List<DefinitionEntity>
transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties)
Transform the resource entity into definition entities.protected Collection<DefinitionEntity>
transformResource(DeploymentEntity deployment, ResourceEntity resource, Properties properties)
protected void
updateDefinitionByLatestDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity latestDefinition)
protected void
updateDefinitionByPersistedDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition)
-
-
-
Field Detail
-
DIAGRAM_SUFFIXES
public static final String[] DIAGRAM_SUFFIXES
-
idGenerator
protected IdGenerator idGenerator
-
-
Method Detail
-
getIdGenerator
public IdGenerator getIdGenerator()
-
setIdGenerator
public void setIdGenerator(IdGenerator idGenerator)
-
deploy
public void deploy(DeploymentEntity deployment)
-
parseDefinitionResources
protected List<DefinitionEntity> parseDefinitionResources(DeploymentEntity deployment, Properties properties)
-
isResourceHandled
protected boolean isResourceHandled(ResourceEntity resource)
-
getResourcesSuffixes
protected abstract String[] getResourcesSuffixes()
- Returns:
- the list of resource suffixes for this cacheDeployer
-
transformResource
protected Collection<DefinitionEntity> transformResource(DeploymentEntity deployment, ResourceEntity resource, Properties properties)
-
transformDefinitions
protected abstract List<DefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties)
Transform the resource entity into definition entities.- Parameters:
deployment
- the deployment the resources belongs toresource
- the resource to transform- Returns:
- a list of transformed definition entities
-
getDiagramResourceForDefinition
protected String getDiagramResourceForDefinition(DeploymentEntity deployment, String resourceName, DefinitionEntity definition, Map<String,ResourceEntity> resources)
Returns the default name of the image resource for a certain definition. It will first look for an image resource which matches the definition specifically, before resorting to an image resource which matches the file containing the definition. Example: if the deployment contains a BPMN 2.0 xml resource called 'abc.bpmn20.xml' containing only one process with key 'myProcess', then this method will look for an image resources called 'abc.myProcess.png' (or .jpg, or .gif, etc.) or 'abc.png' if the previous one wasn't found. Example 2: if the deployment contains a BPMN 2.0 xml resource called 'abc.bpmn20.xml' containing three processes (with keys a, b and c), then this method will first look for an image resource called 'abc.a.png' before looking for 'abc.png' (likewise for b and c). Note that if abc.a.png, abc.b.png and abc.c.png don't exist, all processes will have the same image: abc.png.- Returns:
- null if no matching image resource is found.
-
getDefinitionDiagramResourceName
protected String getDefinitionDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix)
-
getGeneralDiagramResourceName
protected String getGeneralDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix)
-
getDiagramSuffixes
protected String[] getDiagramSuffixes()
-
ensureNoDuplicateDefinitionKeys
protected void ensureNoDuplicateDefinitionKeys(List<DefinitionEntity> definitions)
-
postProcessDefinitions
protected void postProcessDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
-
persistDefinitions
protected void persistDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
-
updateDefinitionByLatestDefinition
protected void updateDefinitionByLatestDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity latestDefinition)
-
loadDefinitions
protected void loadDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties)
-
handlePersistedDefinition
protected void handlePersistedDefinition(DefinitionEntity definition, DefinitionEntity persistedDefinition, DeploymentEntity deployment, Properties properties)
-
updateDefinitionByPersistedDefinition
protected void updateDefinitionByPersistedDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition)
-
persistedDefinitionLoaded
protected void persistedDefinitionLoaded(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition)
Called when a previous version of a definition was loaded from the persistent store.- Parameters:
deployment
- the deployment of the definitiondefinition
- the definition entitypersistedDefinition
- the loaded definition entity
-
findDefinitionByDeploymentAndKey
protected abstract DefinitionEntity findDefinitionByDeploymentAndKey(String deploymentId, String definitionKey)
Find a definition entity by deployment id and definition key.- Parameters:
deploymentId
- the deployment iddefinitionKey
- the definition key- Returns:
- the corresponding definition entity or null if non is found
-
findLatestDefinitionByKeyAndTenantId
protected abstract DefinitionEntity findLatestDefinitionByKeyAndTenantId(String definitionKey, String tenantId)
Find the last deployed definition entity by definition key and tenant id.- Returns:
- the corresponding definition entity or null if non is found
-
persistDefinition
protected abstract void persistDefinition(DefinitionEntity definition)
Persist definition entity into the database.- Parameters:
definition
- the definition entity
-
registerDefinition
protected void registerDefinition(DeploymentEntity deployment, DefinitionEntity definition, Properties properties)
-
addDefinitionToDeploymentCache
protected abstract void addDefinitionToDeploymentCache(DeploymentCache deploymentCache, DefinitionEntity definition)
Add a definition to the deployment cache- Parameters:
deploymentCache
- the deployment cachedefinition
- the definition to add
-
definitionAddedToDeploymentCache
protected void definitionAddedToDeploymentCache(DeploymentEntity deployment, DefinitionEntity definition, Properties properties)
Called after a definition was added to the deployment cache.- Parameters:
deployment
- the deployment of the definitiondefinition
- the definition entity
-
getNextVersion
protected int getNextVersion(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition)
per default we increment the latest definition version by one - but you might want to hook in some own logic here, e.g. to align definition versions with deployment / build versions.
-
generateDefinitionId
protected String generateDefinitionId(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition)
create an id for the definition. The default is to ask theIdGenerator
and add the definition key and version if that does not exceed 64 characters. You might want to hook in your own implementation here.
-
getProcessEngineConfiguration
protected ProcessEngineConfigurationImpl getProcessEngineConfiguration()
-
getCommandContext
protected CommandContext getCommandContext()
-
getDeploymentCache
protected DeploymentCache getDeploymentCache()
-
-