Package org.craftercms.deployer.impl
Class TargetImpl
- java.lang.Object
-
- org.craftercms.deployer.impl.TargetImpl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TargetImpl.DeploymentTask
protected class
TargetImpl.ScheduledDeploymentTask
-
Nested classes/interfaces inherited from interface org.craftercms.deployer.api.Target
Target.Status
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ConfigurableApplicationContext
applicationContext
protected org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>
configuration
protected File
configurationFile
protected Deployment
currentDeployment
protected Lock
deploymentLock
protected DeploymentPipeline
deploymentPipeline
protected DeploymentPipelineFactory
deploymentPipelineFactory
protected String
env
protected ExecutorService
executor
protected ZonedDateTime
loadDate
protected String
localRepoPath
protected Queue<Deployment>
pendingDeployments
protected ScheduledFuture<?>
scheduledDeploymentFuture
protected org.springframework.scheduling.TaskScheduler
scheduler
protected String
siteName
protected Target.Status
status
static String
TARGET_ID_FORMAT
protected TargetLifecycleHooksResolver
targetLifecycleHooksResolver
-
Fields inherited from interface org.craftercms.deployer.api.Target
AUTHORING_ENV
-
-
Constructor Summary
Constructors Constructor Description TargetImpl(String env, String siteName, String localRepoPath, File configurationFile, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration, org.springframework.context.ConfigurableApplicationContext applicationContext, ExecutorService executor, org.springframework.scheduling.TaskScheduler scheduler, TargetLifecycleHooksResolver targetLifecycleHooksResolver, DeploymentPipelineFactory deploymentPipelineFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanRepo()
Performs a cleanup of the local repository.static void
clear()
void
close()
Closes the target, releases any open resources and stops any running threads associated to the target.void
delete()
Deletes the target, executing any delete hooks.Deployment
deploy(boolean waitTillDone, Map<String,Object> params)
Starts a new deployment for the target (asynchronous operation ifwaitTillDone
is false).boolean
equals(Object o)
Collection<Deployment>
getAllDeployments()
Returns all deployments (pending and current).org.springframework.context.ConfigurableApplicationContext
getApplicationContext()
Returns this target's Spring application contextorg.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>
getConfiguration()
Returns the configuration of the target.File
getConfigurationFile()
Returns the YAML configuration file of the target.static Target
getCurrent()
Deployment
getCurrentDeployment()
Returns the current deployment.protected List<TargetLifecycleHook>
getDeleteHooks()
String
getEnv()
Returns the environment of the target.String
getId()
Returns the ID of the target.static String
getId(String env, String siteName)
protected List<TargetLifecycleHook>
getInitHooks()
ZonedDateTime
getLoadDate()
Returns the load date of the target.Collection<Deployment>
getPendingDeployments()
Returns the pending deployments.String
getSiteName()
Returns the site name of the target.Target.Status
getStatus()
Returns the status of the targetint
hashCode()
void
init()
Starts the initialization of the target (asynchronous operation).protected void
scheduleDeployments()
static void
setCurrent(Target target)
protected void
stopDeployments()
String
toString()
void
unlock()
Deletes the git lock file is present in the local repository.
-
-
-
Field Detail
-
TARGET_ID_FORMAT
public static final String TARGET_ID_FORMAT
- See Also:
- Constant Field Values
-
loadDate
protected final ZonedDateTime loadDate
-
env
protected final String env
-
siteName
protected final String siteName
-
localRepoPath
protected final String localRepoPath
-
configurationFile
protected final File configurationFile
-
configuration
protected final org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration
-
applicationContext
protected final org.springframework.context.ConfigurableApplicationContext applicationContext
-
executor
protected final ExecutorService executor
-
scheduler
protected final org.springframework.scheduling.TaskScheduler scheduler
-
targetLifecycleHooksResolver
protected final TargetLifecycleHooksResolver targetLifecycleHooksResolver
-
deploymentPipelineFactory
protected final DeploymentPipelineFactory deploymentPipelineFactory
-
status
protected volatile Target.Status status
-
deploymentPipeline
protected DeploymentPipeline deploymentPipeline
-
scheduledDeploymentFuture
protected ScheduledFuture<?> scheduledDeploymentFuture
-
pendingDeployments
protected final Queue<Deployment> pendingDeployments
-
currentDeployment
protected volatile Deployment currentDeployment
-
deploymentLock
protected final Lock deploymentLock
-
-
Constructor Detail
-
TargetImpl
public TargetImpl(@Value("${target.env}") String env, @Value("${target.siteName}") String siteName, @Value("${target.localRepoPath}") String localRepoPath, @Value("${target.configFile}") File configurationFile, @Autowired org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration, @Autowired org.springframework.context.ConfigurableApplicationContext applicationContext, @Autowired ExecutorService executor, @Autowired org.springframework.scheduling.TaskScheduler scheduler, @Autowired TargetLifecycleHooksResolver targetLifecycleHooksResolver, @Autowired DeploymentPipelineFactory deploymentPipelineFactory)
-
-
Method Detail
-
setCurrent
public static void setCurrent(Target target)
-
getCurrent
public static Target getCurrent()
-
clear
public static void clear()
-
getEnv
public String getEnv()
Description copied from interface:Target
Returns the environment of the target.
-
getSiteName
public String getSiteName()
Description copied from interface:Target
Returns the site name of the target.- Specified by:
getSiteName
in interfaceTarget
-
getLoadDate
public ZonedDateTime getLoadDate()
Description copied from interface:Target
Returns the load date of the target.- Specified by:
getLoadDate
in interfaceTarget
-
getStatus
public Target.Status getStatus()
Description copied from interface:Target
Returns the status of the target
-
getConfigurationFile
public File getConfigurationFile()
Description copied from interface:Target
Returns the YAML configuration file of the target.- Specified by:
getConfigurationFile
in interfaceTarget
-
getConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> getConfiguration()
Description copied from interface:Target
Returns the configuration of the target.- Specified by:
getConfiguration
in interfaceTarget
-
getApplicationContext
public org.springframework.context.ConfigurableApplicationContext getApplicationContext()
Description copied from interface:Target
Returns this target's Spring application context- Specified by:
getApplicationContext
in interfaceTarget
-
init
public void init()
Description copied from interface:Target
Starts the initialization of the target (asynchronous operation). Called when the create target API is called or the target config is loaded.
-
deploy
public Deployment deploy(boolean waitTillDone, Map<String,Object> params) throws TargetNotReadyException
Description copied from interface:Target
Starts a new deployment for the target (asynchronous operation ifwaitTillDone
is false).- Specified by:
deploy
in interfaceTarget
- Parameters:
waitTillDone
- if the method should wait till the deployment is done or return immediatelyparams
- miscellaneous parameters that can be used by the processors.- Returns:
- the deployment info
- Throws:
TargetNotReadyException
- if the target is not inTarget.Status.INIT_COMPLETED
-
getPendingDeployments
public Collection<Deployment> getPendingDeployments()
Description copied from interface:Target
Returns the pending deployments.- Specified by:
getPendingDeployments
in interfaceTarget
-
getCurrentDeployment
public Deployment getCurrentDeployment()
Description copied from interface:Target
Returns the current deployment.- Specified by:
getCurrentDeployment
in interfaceTarget
-
getAllDeployments
public Collection<Deployment> getAllDeployments()
Description copied from interface:Target
Returns all deployments (pending and current).- Specified by:
getAllDeployments
in interfaceTarget
-
cleanRepo
public void cleanRepo()
Performs a cleanup of the local repository.
-
close
public void close()
Description copied from interface:Target
Closes the target, releases any open resources and stops any running threads associated to the target.
-
delete
public void delete()
Description copied from interface:Target
Deletes the target, executing any delete hooks. CallsTarget.close()
too.
-
unlock
public void unlock()
Description copied from interface:Target
Deletes the git lock file is present in the local repository.
-
getInitHooks
protected List<TargetLifecycleHook> getInitHooks() throws DeployerException, org.craftercms.commons.config.ConfigurationException
- Throws:
DeployerException
org.craftercms.commons.config.ConfigurationException
-
getDeleteHooks
protected List<TargetLifecycleHook> getDeleteHooks() throws DeployerException, org.craftercms.commons.config.ConfigurationException
- Throws:
DeployerException
org.craftercms.commons.config.ConfigurationException
-
scheduleDeployments
protected void scheduleDeployments() throws org.craftercms.commons.config.ConfigurationException
- Throws:
org.craftercms.commons.config.ConfigurationException
-
stopDeployments
protected void stopDeployments()
-
-