Class AbstractDeploymentProcessor

java.lang.Object
org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
All Implemented Interfaces:
DeploymentProcessor, InitializableByConfigBean, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
AbstractMainDeploymentProcessor, AbstractPostDeploymentProcessor

public abstract class AbstractDeploymentProcessor extends Object implements DeploymentProcessor, org.springframework.beans.factory.BeanNameAware
Base class for DeploymentProcessors. Inclusion/exclusion of files is handled by this class, through YAML configuration properties includeFiles and excludeFiles. So basically each processor instance can have its own set of inclusions/exclusions.

This class also handles processor "jumping", which is triggered when a processor explicitly indicates that after a successful execution the pipeline should skip directly to executing a processor with a certain label.

It is also possible to make sure a processor is always executed even if the current ChangeSet is empty, this can be accomplished with the alwaysRun property in the YAML configuration.

Author:
avasquez
  • Field Details

    • JUMPING_TO_PARAM_NAME

      public static final String JUMPING_TO_PARAM_NAME
      See Also:
    • env

      protected String env
    • siteName

      protected String siteName
    • targetId

      protected String targetId
    • name

      protected String name
    • label

      protected String label
    • jumpTo

      protected String jumpTo
    • includeFiles

      protected String[] includeFiles
    • excludeFiles

      protected String[] excludeFiles
    • alwaysRun

      protected boolean alwaysRun
  • Constructor Details

    • AbstractDeploymentProcessor

      public AbstractDeploymentProcessor()
  • Method Details

    • setEnv

      public void setEnv(String env)
      Sets the environment of the site.
    • setSiteName

      public void setSiteName(String siteName)
      Sets the site name.
    • setTargetId

      public void setTargetId(String targetId)
      Sets the target ID.
    • setBeanName

      public void setBeanName(String name)
      Sets the bean name of the processor.
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • isPostDeployment

      public boolean isPostDeployment()
      Description copied from interface: DeploymentProcessor
      Returns true if this processor runs after the deployment has finalized.
      Specified by:
      isPostDeployment in interface DeploymentProcessor
    • init

      public void init(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationException, DeployerException
      Description copied from interface: InitializableByConfigBean
      Initializes the bean using the specified configuration.
      Specified by:
      init in interface InitializableByConfigBean
      Parameters:
      config - the bean's configuration
      Throws:
      org.craftercms.commons.config.ConfigurationException - if there's configuration related exception
      DeployerException - if there's a general exception on init
    • destroy

      public void destroy() throws DeployerException
      Description copied from interface: DeploymentProcessor
      Destroys the processor, closing and releasing any used resources.
      Specified by:
      destroy in interface DeploymentProcessor
      Throws:
      DeployerException - if an error occurs
    • supportsMode

      public boolean supportsMode(Deployment.Mode mode)
      Description copied from interface: DeploymentProcessor
      Indicates if the processor should be included in the given deployment mode
      Specified by:
      supportsMode in interface DeploymentProcessor
      Parameters:
      mode - the deployment mode to check
      Returns:
      true if the processor should be included
    • execute

      public void execute(Deployment deployment)
      Description copied from interface: DeploymentProcessor
      Executes the processor
      Specified by:
      execute in interface DeploymentProcessor
      Parameters:
      deployment - the current deployment info
    • getFilteredChangeSet

      protected ChangeSet getFilteredChangeSet(ChangeSet changeSet)
    • shouldIncludeFile

      protected boolean shouldIncludeFile(String file)
    • isJumpToActive

      protected boolean isJumpToActive(Deployment deployment)
    • startJumpTo

      protected void startJumpTo(Deployment deployment)
    • getDeploymentParam

      protected Object getDeploymentParam(String param)
      Get a param from the current deployment
      Parameters:
      param - the param name
      Returns:
      the param value, or null if the param is not set or current deployment is null
    • shouldExecute

      protected abstract boolean shouldExecute(Deployment deployment, ChangeSet filteredChangeSet)
      Indicates if the processor should be executed for the given Deployment and ChangeSet
      Parameters:
      deployment - the Deployment to check
      filteredChangeSet - the ChangeSet to check
      Returns:
      true if the processor should be executed
    • doInit

      protected abstract void doInit(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationException, DeployerException
      Allows extending classes perform any custom initialization
      Parameters:
      config - the bean's configuration
      Throws:
      org.craftercms.commons.config.ConfigurationException - if there's configuration related exception
      DeployerException - if there's a general exception on init
    • doDestroy

      protected abstract void doDestroy() throws DeployerException
      Allows extending classes perform any custom cleanup
      Throws:
      DeployerException - if an error occurs
    • doExecute

      protected abstract ChangeSet doExecute(Deployment deployment, ChangeSet filteredChangeSet, ChangeSet originalChangeSet) throws Exception
      Triggers the execution of the processor for the given Deployment and ChangeSet
      Parameters:
      deployment - the current deployment
      filteredChangeSet - the filtered change set (as returned by getFilteredChangeSet(ChangeSet))
      originalChangeSet - the original change set (as returned by the previous processors in the pipeline)
      Returns:
      a new ChangeSet or null
      Throws:
      Exception - if there is any error processing the ChangeSet