Package com.github.mike10004.xvfbmanager
Class XvfbManager
- java.lang.Object
-
- com.github.mike10004.xvfbmanager.XvfbManager
-
public class XvfbManager extends Object
Class that helps manage the creation of virtual framebuffer processes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceXvfbManager.DisplayReadinessCheckerInterface for classes that can check whether the display has reached a ready state.
-
Constructor Summary
Constructors Constructor Description XvfbManager()Constructs a default instance of the class.XvfbManager(XvfbConfig xvfbConfig)Constructs an instance of the class with a given configuration.XvfbManager(io.github.mike10004.subprocess.ProcessTracker processTracker)XvfbManager(File xvfbExecutable, XvfbConfig xvfbConfig)Constructs an instance of the class that will launch the given executable with the given configuration.XvfbManager(Supplier<File> xvfbExecutableSupplier, XvfbConfig xvfbConfig)Constructs an instance of the class that will launch the given executable with the given configuration.XvfbManager(Supplier<File> xvfbExecutableSupplier, XvfbConfig xvfbConfig, io.github.mike10004.subprocess.ProcessTracker processTracker)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DefaultXvfbControllercreateController(io.github.mike10004.subprocess.ProcessMonitor<File,File> future, String display, File framebufferDir)protected XvfbManager.DisplayReadinessCheckercreateDisplayReadinessChecker(io.github.mike10004.subprocess.ProcessTracker tracker, String display, File framebufferDir)protected Screenshooter<?>createScreenshooter(String display, File framebufferDir)protected SleepercreateSleeper()protected static Supplier<File>createXvfbExecutableResolver()Creates a supplier that returns a valid executable or null if none was found.protected ExecutorgetCallbackExecutor()io.github.mike10004.subprocess.ProcessTrackergetProcessTracker()protected static com.github.mike10004.xvfbmanager.XvfbManager.ScratchDirProvidernewTempDirProvider(Path parent)protected static com.github.mike10004.xvfbmanager.XvfbManager.ScratchDirProvidernonDeletingExistingDirectoryProvider(Path directory)protected intpollForDisplayNumber(com.google.common.io.CharSource cs)protected static FileresolveXvfbExecutable()protected static FileselectCorrespondingFile(int fd, File stdoutFile, File stderrFile)XvfbControllerstart()Starts Xvfb on a vacant display.XvfbControllerstart(int displayNumber)Starts Xvfb on the specified display using the specified executor service.XvfbControllerstart(int displayNumber, Path scratchDir)Starts Xvfb on the specified display using the specified executor service, writing temp files to the specified directory.XvfbControllerstart(Path scratchDir)Starts Xvfb on a vacant display using the specified executor service and writing temp files to the given directory.protected static StringtoDisplayValue(int displayNumber)StringtoString()
-
-
-
Constructor Detail
-
XvfbManager
public XvfbManager()
Constructs a default instance of the class.- See Also:
createXvfbExecutableResolver()
-
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 theXvfbexecutablexvfbConfig- 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 theXvfbexecutablexvfbConfig- 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
-
resolveXvfbExecutable
protected static File resolveXvfbExecutable() throws FileNotFoundException
- Throws:
FileNotFoundException
-
createScreenshooter
protected Screenshooter<?> createScreenshooter(String display, File framebufferDir)
-
createSleeper
protected Sleeper createSleeper()
-
createDisplayReadinessChecker
protected XvfbManager.DisplayReadinessChecker createDisplayReadinessChecker(io.github.mike10004.subprocess.ProcessTracker tracker, String display, File framebufferDir)
-
createController
protected DefaultXvfbController createController(io.github.mike10004.subprocess.ProcessMonitor<File,File> future, String display, File framebufferDir)
-
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 numberscratchDir- 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()
-
selectCorrespondingFile
protected static File selectCorrespondingFile(int fd, File stdoutFile, File stderrFile) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
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()
-
-