public final class WrapperProcessConfig
extends java.lang.Object
The setter methods are designed to be optionally be chained as follows:
WrapperProcess proc = WrapperManager.exec( "command", new WrapperProcessConfig().setDetached( true ).setStartType( WrapperProcessConfig.POSIX_SPAWN ) );
Modifier and Type | Field and Description |
---|---|
static int |
DYNAMIC |
static int |
FORK_EXEC |
static int |
POSIX_SPAWN |
static int |
VFORK_EXEC |
Constructor and Description |
---|
WrapperProcessConfig()
Creates a default configuration.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map |
getEnvironment()
Returns a Map containing the environment which will be used to launch
the child process.
|
int |
getSoftShutdownTimeout()
Returns the soft shutdown timeout value.
|
int |
getStartType()
Returns the start type.
|
java.io.File |
getWorkingDirectory()
Returns the working directory.
|
boolean |
isAutoCloseInputStreams()
Returns whether the input streams of the process should be read in 'auto-close' mode.
|
boolean |
isCreateForActiveUser()
Tells if the CreateForActiveUser feature was enabled.
|
boolean |
isDetached()
Returns the detached flag.
|
boolean |
isNewProcessGroup()
Returns the new process group flag.
|
static boolean |
isSupported(int startType)
Indicates whether the specified start type is supported on the current
plattform.
|
WrapperProcessConfig |
setAutoCloseInputStreams(boolean isAutoCloseInputStreams)
Specifies how the pipes of the process should be read.
|
WrapperProcessConfig |
setCreateForActiveUser(boolean isInteractive)
Specifies if the ChildProcesses should be launched
in the current session.
|
WrapperProcessConfig |
setDetached(boolean detached)
Sets the detached flag.
|
WrapperProcessConfig |
setEnvironment(java.util.Map environment)
Sets the environment for the child process.
|
WrapperProcessConfig |
setNewProcessGroup(boolean newProcessGroup)
Sets the new process group flag.
|
WrapperProcessConfig |
setSoftShutdownTimeout(int softShutdownTimeout)
Sets the timeout for the soft shtudown in seconds.
|
WrapperProcessConfig |
setStartType(int startType)
Sets the start type.
|
WrapperProcessConfig |
setWorkingDirectory(java.io.File workingDirectory)
Sets the working directory.
|
public static final int POSIX_SPAWN
public static final int FORK_EXEC
public static final int VFORK_EXEC
public static final int DYNAMIC
public WrapperProcessConfig()
WrapperLicenseError
- If the function is called other than in
the Professional Edition or if the native
library has not been loaded.public static boolean isSupported(int startType) throws WrapperLicenseError, java.lang.IllegalArgumentException
startType
- The start type to test.WrapperLicenseError
- If the function is called other than in
the Professional Edition or if the native
library has not been loaded.java.lang.IllegalArgumentException
- If the startType is invalid.public boolean isDetached()
public WrapperProcessConfig setDetached(boolean detached)
detached
- If false the Wrapper will remember that the process was
launched and then make sure that it is terminated when
the JVM exits.public int getStartType()
public WrapperProcessConfig setStartType(int startType) throws java.lang.IllegalArgumentException
The start type is used to control how the subprocess will be started by the OS. This property has no effect on Windows.
startType
- The start type to use when launching the child process.java.lang.IllegalArgumentException
- If the startType is invalid.public boolean isNewProcessGroup()
public WrapperProcessConfig setNewProcessGroup(boolean newProcessGroup)
When a process is created as a new process group, the Wrapper will monitor and terminate all processes in the new process group.
When false, the process will be a member of the same process group as Java. The Wrapper will only monitor the process which was directly launched.
Defaults to true.
On Windows, this value is ignored. A new process group is required to make sure console events are handled correctly.
newProcessGroup
- True to create a new process group, false to inherit the process group.public boolean isAutoCloseInputStreams()
public WrapperProcessConfig setAutoCloseInputStreams(boolean isAutoCloseInputStreams)
Two modes are possible:
With the 'auto-close' mode, which is the default, the input stream will be closed when the process ends and there is nothing else to read from the std[out/err] to which it is connected.
In the other mode, the input stream will wait for data to be read even if the process is gone as long as the other end of the stream is open.
While the second mode might be slightly more efficient during the process of reading data, it can cause to block longer after the process termination in case other sub-processes using the same standard streams were initiated. These sub-processes may indeed force the standard streams to stay open.
The 'auto-close' mode is also more reliable in the event of the process crashing.
Defaults to true.
On z/OS, this value is ignored. The 'auto-close' mode is required to make sure the pipes are read correctly. On Windows, this value is ignored. The 'auto-close' mode is not needed.
isAutoCloseInputStreams
- true to enable 'auto-close' mode, false to disable it.public java.io.File getWorkingDirectory()
public WrapperProcessConfig setWorkingDirectory(java.io.File workingDirectory) throws java.io.IOException
workingDirectory
- The working directory of the subprocess, or null
if the subprocess should inherit the working
directory of the JVM.
On Unix, when using the POSIX_SPAWN or DYNAMIC start
type, it is not possible to set the working
directory. Doing so will result in an error when running exec.
On Windows, it is always possible to set the working directly.java.io.IOException
- If the specified working directory can not be resolved.public java.util.Map getEnvironment() throws WrapperLicenseError
If this Map is modified those changes will be reflected when the process is launched. Alternately, the environment can be set with the setEnvironment method. Clearing the Map will result in an empty environment being used.
WrapperLicenseError
- If the function is called other than in
the Professional Edition or from a Standalone JVM.public WrapperProcessConfig setEnvironment(java.util.Map environment)
environment
- A Map containing the environment to use when launching
the process. Passing in an empty Map will result in
an empty Environment being used. A null native will
cause the process to be launched using the same
environment as the JVM.java.lang.IllegalArgumentException
- If any of the names or values are not
Strings or if a name is empty.public int getSoftShutdownTimeout()
public WrapperProcessConfig setSoftShutdownTimeout(int softShutdownTimeout)
softShutdownTimeout
- The max timeout for an application to stop, before
killing forciblyjava.lang.IllegalArgumentException
- If the value of the specified timeout is invalid.public WrapperProcessConfig setCreateForActiveUser(boolean isInteractive)
isInteractive
- true to enable the feature.public boolean isCreateForActiveUser()
Copyright 1999, 2024 Tanuki Software Inc., All Rights Reserved.