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 forDeploymentProcessor
s. Inclusion/exclusion of files is handled by this class, through YAML configuration propertiesincludeFiles
andexcludeFiles
. 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 thealwaysRun
property in the YAML configuration.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
alwaysRun
protected String
env
protected String[]
excludeFiles
protected String[]
includeFiles
static String
JUMPING_TO_PARAM_NAME
protected String
jumpTo
protected String
label
protected String
name
protected String
siteName
protected String
targetId
-
Constructor Summary
Constructors Constructor Description AbstractDeploymentProcessor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroys the processor, closing and releasing any used resources.protected abstract void
doDestroy()
Allows extending classes perform any custom cleanupprotected abstract ChangeSet
doExecute(Deployment deployment, ChangeSet filteredChangeSet, ChangeSet originalChangeSet)
Triggers the execution of the processor for the givenDeployment
andChangeSet
protected abstract void
doInit(org.apache.commons.configuration2.Configuration config)
Allows extending classes perform any custom initializationvoid
execute(Deployment deployment)
Executes the processorprotected ChangeSet
getFilteredChangeSet(ChangeSet changeSet)
void
init(org.apache.commons.configuration2.Configuration config)
Initializes the bean using the specified configuration.protected boolean
isJumpToActive(Deployment deployment)
boolean
isPostDeployment()
Returns true if this processor runs after the deployment has finalized.void
setBeanName(String name)
Sets the bean name of the processor.void
setEnv(String env)
Sets the environment of the site.void
setSiteName(String siteName)
Sets the site name.void
setTargetId(String targetId)
Sets the target ID.protected abstract boolean
shouldExecute(Deployment deployment, ChangeSet filteredChangeSet)
Indicates if the processor should be executed for the givenDeployment
andChangeSet
protected boolean
shouldIncludeFile(String file)
protected void
startJumpTo(Deployment deployment)
boolean
supportsMode(Deployment.Mode mode)
Indicates if the processor should be included in the given deployment mode
-
-
-
Field Detail
-
JUMPING_TO_PARAM_NAME
public static final String JUMPING_TO_PARAM_NAME
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
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 interfaceorg.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 interfaceDeploymentProcessor
-
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 interfaceInitializableByConfigBean
- Parameters:
config
- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException
- if there's configuration related exceptionDeployerException
- 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 interfaceDeploymentProcessor
- 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 interfaceDeploymentProcessor
- 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 interfaceDeploymentProcessor
- Parameters:
deployment
- the current deployment info
-
shouldIncludeFile
protected boolean shouldIncludeFile(String file)
-
isJumpToActive
protected boolean isJumpToActive(Deployment deployment)
-
startJumpTo
protected void startJumpTo(Deployment deployment)
-
shouldExecute
protected abstract boolean shouldExecute(Deployment deployment, ChangeSet filteredChangeSet)
Indicates if the processor should be executed for the givenDeployment
andChangeSet
- Parameters:
deployment
- theDeployment
to checkfilteredChangeSet
- theChangeSet
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 exceptionDeployerException
- 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 givenDeployment
andChangeSet
- Parameters:
deployment
- the current deploymentfilteredChangeSet
- the filtered change set (as returned bygetFilteredChangeSet(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 theChangeSet
-
-