Class AppClientWrapper

  • All Implemented Interfaces:
    AutoCloseable

    public class AppClientWrapper
    extends Object
    implements AutoCloseable
    A wrapper for an application client process. Allows interacting with the application client process.
    Author:
    Dominik Pospisil , Stuart Douglas, James R. Perkins
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Kills the application client.
      List<String> readAll​(long timeout)
      Consumes all available output from application client using the output queue filled by the process standard out reader thread.
      void run()
      Starts the application client in a new process and creates two thread to read the process output (stdout) and error streams (stderr).
      boolean waitForExit​(long timeout, TimeUnit unit)
      If the application client has started, causes the current thread to wait, if necessary, until the application client terminates or the specified wait has been reached.
    • Constructor Detail

      • AppClientWrapper

        protected AppClientWrapper​(ManagedContainerConfiguration config,
                                   org.jboss.logging.Logger log)
        Creates a new application client wrapper.
        Parameters:
        config - the configuration for the container
        log - the logger to use
    • Method Detail

      • waitForExit

        public boolean waitForExit​(long timeout,
                                   TimeUnit unit)
                            throws InterruptedException
        If the application client has started, causes the current thread to wait, if necessary, until the application client terminates or the specified wait has been reached.

        If the application client has not started a value of false is returned and an error message logged indicating the application client has not started.

        If the application client has started and the process has terminated, this method returns true immediately.

        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        true if the application client process has exited and false if the waiting time elapsed before the process has exited
        Throws:
        InterruptedException - if the current thread is interrupted while waiting
        NullPointerException - if unit is null
        See Also:
        Process.waitFor(long, TimeUnit)
      • readAll

        public List<String> readAll​(long timeout)
        Consumes all available output from application client using the output queue filled by the process standard out reader thread.
        Parameters:
        timeout - number of milliseconds to wait for each subsequent line
        Returns:
        list of application client output lines
      • run

        public void run()
                 throws IOException
        Starts the application client in a new process and creates two thread to read the process output (stdout) and error streams (stderr).
        Throws:
        IOException - if there is a failure to start the application client process
      • close

        public void close()
        Kills the application client.
        Specified by:
        close in interface AutoCloseable