JRun lets you control the way your application behaves if it is running in the same virtual machine (VM) as JRun when JRun exits. You can use a custom exit handler to provide your own error messages or clean up files in the event of an unplanned exit or fatal error.
By default, JRun calls the System.exit method with an exit code when exiting from JRun.
You can implement the JRunExitHandler interface to control the JRun exit behavior and prevent the VM from exiting when JRun stops.
Note: Only use the JRunExitHandler interface if your application is running in the same virtual machine as JRun.
The JRunExitHandler interface is in the jrunx.kernel package. It has a single method with the following signature:
void exitJRun(int exitCode)
After implementing JRunExitHandler, use the handler class by calling the JRun.setExitHandler method.
The following class implements JRunExitHandler:
import java.io.*;
import jrunx.kernel.*;
/**
* Extend the base JRunExitHandler class and ignore exits
**/
public class MyJRun implements JRunExitHandler {
��public static void main(String[] args) throws IOException {
����JRun.setExitHandler(new MyJRun());
����JRun.main(args);
��}
��public void exitJRun(int exitCode) {
����// Put your exit handling code here
��}
}
The main method instantiates the class, sets the exit handler, and then invokes JRun. If JRun terminates abnormally or receives a restart request, JRun invokes the custom exitJRun method. To compile and run this class, you must include jrun_root/lib/jrun.jar in your classpath.
The following exit codes are valid:
The normal execution of JRun commands (other than restart and status) do not produce an exit code or call the exit handler.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/JRun_SDK_Guide/embedding7.htm