Class YamlProcess

  • All Implemented Interfaces:
    ProcessSpec
    Direct Known Subclasses:
    YamlServer

    public class YamlProcess
    extends java.lang.Object
    implements ProcessSpec
    If the service is not completely implemented rather than delegates functionality to an additional process that must be started and managed along with the service.
    Author:
    Holger Eichelberger, SSE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.String> artifacts  
      private java.util.List<java.lang.String> cmdArg  
      private java.lang.String executable  
      private java.lang.String executablePath  
      private java.lang.String homePath  
      private java.lang.String locationKey  
      private boolean started  
    • Constructor Summary

      Constructors 
      Constructor Description
      YamlProcess()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> getArtifacts()
      Returns the process implementing artifacts within the containing artifact to be extracted into the process home directory.
      java.util.List<java.lang.String> getCmdArg()
      Returns the command line arguments to start the process.
      java.lang.String getExecutable()
      Returns the system command or relative path within the artifact to be executed.
      java.io.File getExecutablePath()
      Returns an optional path to be prefixed before the executable.
      java.io.File getHomePath()
      Returns the home directory of the process to be executed.
      java.lang.String getLocationKey()
      Returns the location key for lookup in InstalledDependenciesSetup.
      java.util.List<java.lang.String> getSubstCmdArg()
      Returns getCmdArg() with substitutions from toSubstFileName(String) for all arguments.
      boolean isStarted()
      Returns whether the underlying process is already started when firing up the service or it will be started through the service implementation.
      void setArtifacts​(java.util.List<java.lang.String> artifacts)
      Defines the process implementing artifacts within the containing artifact to be extracted.
      void setCmdArg​(java.util.List<java.lang.String> cmdArg)
      Defines the command line arguments.
      void setExecutable​(java.lang.String executable)
      Defines the system command or relative path to be executed.
      void setExecutablePath​(java.io.File executablePath)
      Changes the optional path to be prefixed before the executable.
      void setExecutablePath​(java.lang.String executablePath)
      Changes the optional path to be prefixed before the executable.
      void setHomePath​(java.io.File home)
      Changes the home directory of the process to be executed.
      void setHomePath​(java.lang.String homePath)
      Changes the home directory of the process to be executed.
      void setLocationKey​(java.lang.String locationKey)
      Changes the location key for lookup in InstalledDependenciesSetup.
      void setStarted​(boolean started)
      Changes whether the underlying process is already started when firing up the service.
      protected static java.lang.String toSubstFileName​(java.lang.String path)
      Substitutes "${tmp}" and "${user}" and returns a name for path.
      protected static java.io.File toSubstFilePath​(java.lang.String path)
      Substitutes "${tmp}" and "${user}" and returns a file for path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • executable

        private java.lang.String executable
      • executablePath

        private java.lang.String executablePath
      • homePath

        private java.lang.String homePath
      • locationKey

        private java.lang.String locationKey
      • cmdArg

        private java.util.List<java.lang.String> cmdArg
      • artifacts

        private java.util.List<java.lang.String> artifacts
      • started

        private boolean started
    • Constructor Detail

      • YamlProcess

        public YamlProcess()
    • Method Detail

      • getArtifacts

        public java.util.List<java.lang.String> getArtifacts()
        Description copied from interface: ProcessSpec
        Returns the process implementing artifacts within the containing artifact to be extracted into the process home directory.
        Specified by:
        getArtifacts in interface ProcessSpec
        Returns:
        the relative paths to the artifacts, shall start with "/" as part of ZIP/JAR
      • isStarted

        public boolean isStarted()
        Description copied from interface: ProcessSpec
        Returns whether the underlying process is already started when firing up the service or it will be started through the service implementation. If specified, artifacts will be extracted anyway into the process home directory, assuming that a pre-installed executable will not specify artifacts to be extracted.
        Specified by:
        isStarted in interface ProcessSpec
        Returns:
        true for started, false else (default)
      • setArtifacts

        public void setArtifacts​(java.util.List<java.lang.String> artifacts)
        Defines the process implementing artifacts within the containing artifact to be extracted.
        Parameters:
        artifacts - the relative paths to the artifacts
      • setStarted

        public void setStarted​(boolean started)
        Changes whether the underlying process is already started when firing up the service. [required by SnakeYaml]
        Parameters:
        started - true for started (default), false else
      • getExecutable

        public java.lang.String getExecutable()
        Description copied from interface: ProcessSpec
        Returns the system command or relative path within the artifact to be executed.
        Specified by:
        getExecutable in interface ProcessSpec
        Returns:
        the command or relative path
      • getLocationKey

        public java.lang.String getLocationKey()
        Returns the location key for lookup in InstalledDependenciesSetup.
        Returns:
        the location key, may be null
      • getExecutablePath

        public java.io.File getExecutablePath()
        Description copied from interface: ProcessSpec
        Returns an optional path to be prefixed before the executable. Relevance depends on the execution environment.
        Specified by:
        getExecutablePath in interface ProcessSpec
        Returns:
        the optional executable path, may be null for none
      • getHomePath

        public java.io.File getHomePath()
        Description copied from interface: ProcessSpec
        Returns the home directory of the process to be executed.
        Specified by:
        getHomePath in interface ProcessSpec
        Returns:
        the home directory, may be null to rely on extracted paths, may be given to explicitly define a home path
      • toSubstFileName

        protected static java.lang.String toSubstFileName​(java.lang.String path)
        Substitutes "${tmp}" and "${user}" and returns a name for path.
        Parameters:
        path - the path
        Returns:
        the name, may be null if path is null or empty
      • toSubstFilePath

        protected static java.io.File toSubstFilePath​(java.lang.String path)
        Substitutes "${tmp}" and "${user}" and returns a file for path.
        Parameters:
        path - the path
        Returns:
        the file, may be null if path is null or empty
      • getCmdArg

        public java.util.List<java.lang.String> getCmdArg()
        Description copied from interface: ProcessSpec
        Returns the command line arguments to start the process. The shell will be executed within the folder where the files from ProcessSpec.getHomePath() are extracted.
        Specified by:
        getCmdArg in interface ProcessSpec
        Returns:
        the command line arguments (may be empty for none)
      • getSubstCmdArg

        public java.util.List<java.lang.String> getSubstCmdArg()
        Returns getCmdArg() with substitutions from toSubstFileName(String) for all arguments.
        Returns:
        the substitutions
      • setExecutable

        public void setExecutable​(java.lang.String executable)
        Defines the system command or relative path to be executed. [required by SnakeYaml]
        Parameters:
        executable - the name/path
      • setLocationKey

        public void setLocationKey​(java.lang.String locationKey)
        Changes the location key for lookup in InstalledDependenciesSetup.
        Parameters:
        locationKey - the location key, may be null
      • setExecutablePath

        public void setExecutablePath​(java.lang.String executablePath)
        Changes the optional path to be prefixed before the executable. Relevance depends on the execution environment. May contain "${tmp}" for the system temporary directory path and "${user}" for the user directory path. [required by SnakeYaml]
        Parameters:
        executablePath - the optional executable path, may be null for none
      • setExecutablePath

        public void setExecutablePath​(java.io.File executablePath)
        Changes the optional path to be prefixed before the executable. Relevance depends on the execution environment. May contain "${tmp}" for the system temporary directory path and "${user}" for the user directory path. [required by SnakeYaml]
        Parameters:
        executablePath - the optional executable path, may be null for none
      • setHomePath

        public void setHomePath​(java.lang.String homePath)
        Changes the home directory of the process to be executed. [required by SnakeYaml] May contain "${tmp}" for the system temporary directory path and "${user}" for the user directory path.
        Parameters:
        homePath - the home directory, may be null to rely on extracted paths, may be given to explicitly define a home path
      • setHomePath

        public void setHomePath​(java.io.File home)
        Changes the home directory of the process to be executed. [required by SnakeYaml] May contain "${tmp}" for the system temporary directory path and "${user}" for the user directory path.
        Parameters:
        home - the home directory, may be null to rely on extracted paths, may be given to explicitly define a home path
      • setCmdArg

        public void setCmdArg​(java.util.List<java.lang.String> cmdArg)
        Defines the command line arguments. [required by SnakeYaml]
        Parameters:
        cmdArg - the command line arguments (may be empty for none)