org.tanukisoftware.wrapper
Class WrapperProcessConfig

java.lang.Object
  extended by org.tanukisoftware.wrapper.WrapperProcessConfig

public final class WrapperProcessConfig
extends Object

With WrapperProcessConfig Class the startup configuration for the Process can be passed to the WrapperManager.exec methods. The configuration makes it possible to control the way the OS spawns the child process, specify environment variables, working directory, and how the Wrapper should handle process when the JVM exits. Please review each of the methods a more detailed explanation of how they work.

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 ) );
 

Since:
Wrapper 3.4.0
Author:
Christian Mueller

Field Summary
static int DYNAMIC
           
static int FORK_EXEC
           
static int POSIX_SPAWN
           
static int VFORK_EXEC
           
 
Constructor Summary
WrapperProcessConfig()
          Creates a default configuration.
 
Method Summary
 Map getEnvironment()
          Returns a Map containing the environment which will be used to launch the child process.
 int getStartType()
          Returns the start type.
 File getWorkingDirectory()
          Returns the working directory.
 boolean isDetached()
          Returns the detached flag.
static boolean isSupported(int startType)
          Indicates whether the specified start type is supported on the current plattform.
 WrapperProcessConfig setDetached(boolean detached)
          Sets the detached flag.
 WrapperProcessConfig setEnvironment(Map environment)
          Sets the environment for the child process.
 WrapperProcessConfig setSoftShutdownTimeout(int softShutdownTimeout)
          Sets the timeout for the soft shtudown in seconds.
 WrapperProcessConfig setStartType(int startType)
          Sets the start type.
 WrapperProcessConfig setWorkingDirectory(File workingDirectory)
          Sets the working directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSIX_SPAWN

public static final int POSIX_SPAWN
See Also:
Constant Field Values

FORK_EXEC

public static final int FORK_EXEC
See Also:
Constant Field Values

VFORK_EXEC

public static final int VFORK_EXEC
See Also:
Constant Field Values

DYNAMIC

public static final int DYNAMIC
See Also:
Constant Field Values
Constructor Detail

WrapperProcessConfig

public WrapperProcessConfig()
Creates a default configuration.

Throws:
WrapperLicenseError - If the Professional Edition of the Wrapper is not being used.
Method Detail

isSupported

public static boolean isSupported(int startType)
                           throws WrapperLicenseError,
                                  IllegalArgumentException
Indicates whether the specified start type is supported on the current plattform.

Parameters:
startType - The start type to test.
Returns:
true if supported, false otherwise. On Windows, this method always returns true.
Throws:
WrapperLicenseError - If the function is called other than in the Professional Edition or from a Standalone JVM.
IllegalArgumentException - If the startType is invalid.

isDetached

public boolean isDetached()
Returns the detached flag.

Returns:
The detached flag.

setDetached

public WrapperProcessConfig setDetached(boolean detached)
Sets the detached flag. This makes it possible to control whether or not the Wrapper will terminate any child processes launched by a JVM when that JVM exits or crashes.

Parameters:
detached - If false the Wrapper will remember that the process was launched and then make sure that it is terminated when the JVM exits.
Returns:
This configration to allow chaining.

getStartType

public int getStartType()
Returns the start type.

Returns:
The start type.

setStartType

public WrapperProcessConfig setStartType(int startType)
                                  throws IllegalArgumentException
Sets the start type.

The start type is used to control how the subprocess will be started by the OS. This property has no effect on Windows.

Parameters:
startType - The start type to use when launching the child process.
Returns:
This configration to allow chaining.
Throws:
IllegalArgumentException - If the startType is invalid.

getWorkingDirectory

public File getWorkingDirectory()
Returns the working directory.

Returns:
The working directory.

setWorkingDirectory

public WrapperProcessConfig setWorkingDirectory(File workingDirectory)
                                         throws IOException
Sets the working directory.

Parameters:
workingDirectory - The working directory of the subprocess, or null if the subprocess should inherit the working directory of the JVM. Please note, 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.
Returns:
This configration to allow chaining.
Throws:
IOException - If the specified working directory can not be resolved.

getEnvironment

public Map getEnvironment()
                   throws WrapperLicenseError
Returns a Map containing the environment which will be used to launch the child process.

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.

Throws:
WrapperLicenseError - If the function is called other than in the Professional Edition or from a Standalone JVM.

setEnvironment

public WrapperProcessConfig setEnvironment(Map environment)
Sets the environment for the child process.

Parameters:
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.
Returns:
This configration to allow chaining.
Throws:
IllegalArgumentException - If any of the names or values are not Strings or if a name is empty.

setSoftShutdownTimeout

public WrapperProcessConfig setSoftShutdownTimeout(int softShutdownTimeout)
                                            throws IOException
Sets the timeout for the soft shtudown in seconds. When WrapperProcess.destroy() is called the wrapper will first try to stop the application softly giving it time to stop itself properly. If the specified timeout however ellapsed, the Child Process will be terminated by hard. If 0 was specified, the wrapper will instantly force the termination. If -1 was specified, the wrapper will wait indefinitely for the child to perform the stop. The default value of this property is 5 - giving a process 5 sec to react on the shutdown request.

Parameters:
softShutdownTimeout - The max timeout for an application to stop, before killing forcibly
Returns:
This configration to allow chaining.
Throws:
IllegalArgumentException - If the value of the specified timeout is invalid.
IOException


Copyright 1999, 2010 Tanuki Software Inc., All Rights Reserved.