Class TargetImpl

java.lang.Object
org.craftercms.deployer.impl.TargetImpl
All Implemented Interfaces:
Target

public class TargetImpl extends Object implements Target
Default implementation of Target.
Author:
avasquez
  • Field Details

    • TARGET_ID_FORMAT

      public static final String TARGET_ID_FORMAT
      See Also:
    • 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 Details

    • 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 Details

    • setCurrent

      public static void setCurrent(Target target)
    • getCurrent

      public static Target getCurrent()
    • clear

      public static void clear()
    • getId

      public static String getId(String env, String siteName)
    • getEnv

      public String getEnv()
      Description copied from interface: Target
      Returns the environment of the target.
      Specified by:
      getEnv in interface Target
    • getSiteName

      public String getSiteName()
      Description copied from interface: Target
      Returns the site name of the target.
      Specified by:
      getSiteName in interface Target
    • getId

      public String getId()
      Description copied from interface: Target
      Returns the ID of the target.
      Specified by:
      getId in interface Target
    • getLoadDate

      public ZonedDateTime getLoadDate()
      Description copied from interface: Target
      Returns the load date of the target.
      Specified by:
      getLoadDate in interface Target
    • getStatus

      public Target.Status getStatus()
      Description copied from interface: Target
      Returns the status of the target
      Specified by:
      getStatus in interface Target
    • getConfigurationFile

      public File getConfigurationFile()
      Description copied from interface: Target
      Returns the YAML configuration file of the target.
      Specified by:
      getConfigurationFile in interface Target
    • 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 interface Target
    • getApplicationContext

      public org.springframework.context.ConfigurableApplicationContext getApplicationContext()
      Description copied from interface: Target
      Returns this target's Spring application context
      Specified by:
      getApplicationContext in interface Target
    • 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.
      Specified by:
      init in interface Target
    • 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 if waitTillDone is false).
      Specified by:
      deploy in interface Target
      Parameters:
      waitTillDone - if the method should wait till the deployment is done or return immediately
      params - miscellaneous parameters that can be used by the processors.
      Returns:
      the deployment info
      Throws:
      TargetNotReadyException - if the target is not in Target.Status.INIT_COMPLETED
    • getPendingDeployments

      public Collection<Deployment> getPendingDeployments()
      Description copied from interface: Target
      Returns the pending deployments.
      Specified by:
      getPendingDeployments in interface Target
    • getCurrentDeployment

      public Deployment getCurrentDeployment()
      Description copied from interface: Target
      Returns the current deployment.
      Specified by:
      getCurrentDeployment in interface Target
    • getAllDeployments

      public Collection<Deployment> getAllDeployments()
      Description copied from interface: Target
      Returns all deployments (pending and current).
      Specified by:
      getAllDeployments in interface Target
    • cleanRepo

      public void cleanRepo()
      Performs a cleanup of the local repository.
      Specified by:
      cleanRepo in interface Target
    • 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.
      Specified by:
      close in interface Target
    • delete

      public void delete()
      Description copied from interface: Target
      Deletes the target, executing any delete hooks. Calls Target.close() too.
      Specified by:
      delete in interface Target
    • unlock

      public void unlock()
      Description copied from interface: Target
      Deletes the git lock file is present in the local repository.
      Specified by:
      unlock in interface Target
    • 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()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object