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 Details

    • DIAGRAM_SUFFIXES

      public static final String[] DIAGRAM_SUFFIXES
    • idGenerator

      protected IdGenerator idGenerator
  • Constructor Details

    • AbstractDefinitionDeployer

      public AbstractDefinitionDeployer()
  • Method Details

    • getIdGenerator

      public IdGenerator getIdGenerator()
    • setIdGenerator

      public void setIdGenerator(IdGenerator idGenerator)
    • deploy

      public void deploy(DeploymentEntity deployment)
      Specified by:
      deploy in interface Deployer
    • 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 to
      resource - 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)
    • stripDefinitionFileSuffix

      protected String stripDefinitionFileSuffix(String resourceName)
    • 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 definition
      definition - the definition entity
      persistedDefinition - 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 id
      definitionKey - 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 cache
      definition - 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 definition
      definition - 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 the IdGenerator 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()