Class XvfbManager


  • public class XvfbManager
    extends Object
    Class that helps manage the creation of virtual framebuffer processes.
    • Constructor Detail

      • XvfbManager

        public XvfbManager​(XvfbConfig xvfbConfig)
        Constructs an instance of the class with a given configuration.
        Parameters:
        xvfbConfig - the configuration
        See Also:
        createXvfbExecutableResolver()
      • XvfbManager

        public XvfbManager​(File xvfbExecutable,
                           XvfbConfig xvfbConfig)
        Constructs an instance of the class that will launch the given executable with the given configuration.
        Parameters:
        xvfbExecutable - pathname of the Xvfb executable
        xvfbConfig - virtual framebuffer configuration
      • XvfbManager

        public XvfbManager​(Supplier<File> xvfbExecutableSupplier,
                           XvfbConfig xvfbConfig)
        Constructs an instance of the class that will launch the given executable with the given configuration.
        Parameters:
        xvfbExecutableSupplier - supplier of the pathname of the Xvfb executable
        xvfbConfig - virtual framebuffer configuration
      • XvfbManager

        public XvfbManager​(io.github.mike10004.subprocess.ProcessTracker processTracker)
      • XvfbManager

        public XvfbManager​(Supplier<File> xvfbExecutableSupplier,
                           XvfbConfig xvfbConfig,
                           io.github.mike10004.subprocess.ProcessTracker processTracker)
    • Method Detail

      • toDisplayValue

        protected static String toDisplayValue​(int displayNumber)
      • createXvfbExecutableResolver

        protected static Supplier<File> createXvfbExecutableResolver()
        Creates a supplier that returns a valid executable or null if none was found.
        Returns:
        a supplier
      • createSleeper

        protected Sleeper createSleeper()
      • start

        public XvfbController start​(int displayNumber,
                                    Path scratchDir)
                             throws IOException
        Starts Xvfb on the specified display using the specified executor service, writing temp files to the specified directory.
        Parameters:
        displayNumber - the display number
        scratchDir - the temp directory
        Returns:
        the process controller
        Throws:
        IOException - if the files and directories the process requires cannot be created or written to
      • start

        public XvfbController start​(int displayNumber)
                             throws IOException
        Starts Xvfb on the specified display using the specified executor service. A directory for temp files is created and deleted when the process is stopped.
        Parameters:
        displayNumber - the display number
        Returns:
        the process controller
        Throws:
        IOException - if the files and directories the process requires cannot be created or written to
      • start

        public XvfbController start()
                             throws IOException
        Starts Xvfb on a vacant display. A directory for temp files will be created and deleted when the process is stopped.
        Returns:
        the process controller
        Throws:
        IOException - if the files and directories the process requires cannot be created or written to
      • start

        public XvfbController start​(Path scratchDir)
                             throws IOException
        Starts Xvfb on a vacant display using the specified executor service and writing temp files to the given directory.
        Parameters:
        scratchDir - the temp directory
        Returns:
        the process controller
        Throws:
        IOException - if the files and directories the process requires cannot be created or written to
      • getCallbackExecutor

        protected Executor getCallbackExecutor()
      • nonDeletingExistingDirectoryProvider

        protected static com.github.mike10004.xvfbmanager.XvfbManager.ScratchDirProvider nonDeletingExistingDirectoryProvider​(Path directory)
      • newTempDirProvider

        protected static com.github.mike10004.xvfbmanager.XvfbManager.ScratchDirProvider newTempDirProvider​(Path parent)
      • pollForDisplayNumber

        protected int pollForDisplayNumber​(com.google.common.io.CharSource cs)
      • getProcessTracker

        public io.github.mike10004.subprocess.ProcessTracker getProcessTracker()