Class TargetImpl

  • All Implemented Interfaces:
    Target

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

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

        protected final org.springframework.scheduling.TaskScheduler scheduler
      • scheduledDeploymentFuture

        protected ScheduledFuture<?> scheduledDeploymentFuture
      • 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.
        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
      • 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
      • 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
      • scheduleDeployments

        protected void scheduleDeployments()
                                    throws org.craftercms.commons.config.ConfigurationException
        Throws:
        org.craftercms.commons.config.ConfigurationException
      • stopDeployments

        protected void stopDeployments()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object