Class ProcessBuilderUtil


  • public final class ProcessBuilderUtil
    extends java.lang.Object
    Process builder util.
    • Field Detail

      • TEMP

        public static final java.lang.String TEMP
        TEMP Environment variable
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static ProcessBuilderUtil getInstance()
        Get the instance
        Returns:
        the instance
      • isProcessRunning

        public boolean isProcessRunning​(java.lang.Long pid)
        Check if a process is running
        Parameters:
        pid - the pid
        Returns:
        true if the process is still running
      • createProcessBuilders

        public java.util.List<java.lang.ProcessBuilder> createProcessBuilders​(ISystemCommandGroupList systemCommandGroupList,
                                                                              IProcessInputStream processInputStream,
                                                                              IProcessOutputStream processOut,
                                                                              IProcessOutputStream processErr,
                                                                              ISystemCommandExecuterPlatformSupport inputSystemCommandExecuterPlatformSupport,
                                                                              java.nio.file.Path scriptPath)
        Create a process builder list
        Parameters:
        systemCommandGroupList - the system command group list
        processInputStream - the process input stream
        processOut - the process output stream
        processErr - the process error stream
        inputSystemCommandExecuterPlatformSupport - the system command executer platform support
        scriptPath - the script path
        Returns:
        the process builder
        Throws:
        java.lang.IllegalArgumentException - In case of invalid parameters
      • createProcessBuilder

        public java.lang.ProcessBuilder createProcessBuilder​(ISystemCommandGroup systemCommandGroup,
                                                             ISystemCommandExecuterPlatformSupport inputSystemCommandExecuterPlatformSupport,
                                                             java.nio.file.Path scriptPath)
        Create a process builder
        Parameters:
        systemCommandGroup - the system command group
        inputSystemCommandExecuterPlatformSupport - the system command executer platform support
        scriptPath - the script path
        Returns:
        the process builder
        Throws:
        java.lang.IllegalArgumentException - In case of invalid parameters
      • createProcessBuilder

        public java.lang.ProcessBuilder createProcessBuilder​(ISystemCommandGroup systemCommandGroup,
                                                             ISystemCommandExecuterPlatformSupport inputSystemCommandExecuterPlatformSupport)
        Create a process builder
        Parameters:
        systemCommandGroup - the system command group
        inputSystemCommandExecuterPlatformSupport - the system command executer platform support
        Returns:
        the process builder
        Throws:
        java.lang.IllegalArgumentException - In case of invalid parameters
      • createScriptProcessBuilder

        public java.lang.ProcessBuilder createScriptProcessBuilder​(ISystemCommandGroup systemCommandGroup,
                                                                   ISystemCommandExecuterPlatformSupport inputSystemCommandExecuterPlatformSupport,
                                                                   java.nio.file.Path scriptPath)
        Create a process builder
        Parameters:
        systemCommandGroup - the system command group
        inputSystemCommandExecuterPlatformSupport - the system command executer platform support
        scriptPath - the script path
        Returns:
        the process builder
        Throws:
        java.lang.IllegalArgumentException - In case of invalid parameters
      • prepareEnvironmentVariables

        public java.util.Map<java.lang.String,​java.lang.String> prepareEnvironmentVariables​(ISystemCommandExecuterPlatformSupport systemCommandExecuterPlatformSupport,
                                                                                                  java.nio.file.Path file,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> currentEnv,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> newEnv)
                                                                                           throws java.io.IOException
        Prepare the environment variable
        Parameters:
        systemCommandExecuterPlatformSupport - the system command executer platform support
        file - the current temporary file
        currentEnv - the current environment
        newEnv - the new environment
        Returns:
        the new environment variables
        Throws:
        java.io.IOException - In case of write issues
      • prepareEnvironmentVariables

        public java.util.Map<java.lang.String,​java.lang.String> prepareEnvironmentVariables​(ISystemCommandExecuterPlatformSupport systemCommandExecuterPlatformSupport,
                                                                                                  java.nio.file.Path file,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> env)
                                                                                           throws java.io.IOException
        Write the environment variable
        Parameters:
        systemCommandExecuterPlatformSupport - the system command executer platform support
        file - the current temporary file
        env - the environment variable
        Returns:
        the new environment
        Throws:
        java.io.IOException - In case of write issues
      • unsetEnvironment

        public java.util.Set<java.lang.String> unsetEnvironment​(java.util.Map<java.lang.String,​java.lang.String> currentEnv,
                                                                java.util.Map<java.lang.String,​java.lang.String> newEnv)
        Compare two maps by key
        Parameters:
        currentEnv - the current environment
        newEnv - the new environment
        Returns:
        the keys to unset
      • prepareDuration

        public java.lang.String prepareDuration​(IProcess process)
        Prepare duration
        Parameters:
        process - the process
        Returns:
        the duration