|
|
 |
 |
| Summary of Integration Methods |
Summary of Integration Methods
 |
|
There are currently four ways which an application can integrate with the Java Service Wrapper.
Three of which will work out of the box without any additional coding.
The first step is to decide which of
these four methods is best for your application.
After a brief overview of each of the three options,
we will go into detail how to integrate an application using each.
 |
 |
|
The Meethod 1 is to use the
WrapperSimpleApp helper class to
launch the application. This is by far the simplest way to integrate with the Wrapper,
and where possible, it is highly recommended.
There are some things to be aware of when using this method however.
(Note: Java version)
When the Wrapper shuts down the JVM, there is no direct call to an
application requesting that it shutdown cleanly. Rather, the Wrapper
will exit the JVM by calling System.exit()
from within the JVM. If the application has registered its own shutdown
hook, it will be invoked, giving the application a chance to shutdown cleanly.
If on the other hand, a Shutdown Hook is not registered,
then the application will suddenly exit like pressing CTRL-C in the console (command window).
Both cases, with and without a Shutdown Hook,
provide the exact same behavior as if the application was running without the Wrapper.
Detailed overview and instructions, using
JBoss as an example
(Windows
or Linux / Unix).
|
 |
 |
|
The Method 2 is to use the
WrapperStartStopApp helper class.
This method provides a way to integrate with applications like Tomcat,
which are started using one class and then stopped using another
class.
Typically, this kind of application will open a server socket
on startup whose job is to wait for a connection which triggers a shutdown.
The shutdown, or "stop", class when launched then triggers
the shutdown by connecting to application.
The Wrapper works with
this kind of application by starting up the application, as in the Meethod 1,
using the "start" class and then calling the main method of the "stop" class
when it is time for the application to be shutdown.
Detailed overview and instructions, using
Tomcat as an example
(Windows
or Linux / Unix).
|
 |
 |
|
The Method 3, while providing the most flexibility and
access to all of the Wrapper's features, is also the only one which
requires some coding to complete the integration.
This method involves creating a class which implements the
WrapperListener interface.
An instance of the user class is then instantiated and registered with
the WrapperManager.
While this method provides features that are not available with
either of the first two methods
(either WrapperSimpleApp or WrapperStartStopApp),
it does add some complexity.
This is the only method which allows user code to receive and respond
directly to system control events as well as the startup and shutdown process.
If the additional features are not required,
implementing a Shutdown Hook to enable the use of
Method 1 (WrapperSimpleApp),
or implementing a shutdown class should be considered as options.
The main method of a shutdown class can be as simple as just calling a
shutdown method in the application.
In most cases this added control is not necessary however,
as both the
Method 1 (WrapperSimpleApp)
and
Method 2 (WrapperStartStopApp)
helper classes take care of this for you by starting up and shutting
down the application at the appropriate times.
Detailed overview and instructions
(Platform Independent).
|
 |
 |
|
The fourth and final method is to use the
WrapperJarApp helper class to
launch the application. This is another simple way to integrate
with the Wrapper when the application is already configured to run
as an executable jar.
There are some things to be aware of when using this method however.
(Note: Java version)
When the Wrapper shuts down the JVM, there is no
direct call to an application requesting that it shutdown cleanly.
Rather, the Wrapper will exit the JVM by calling
System.exit() from within the JVM.
If the application has registered its own Shutdown Hook,
it will be invoked, giving the application a chance to shutdown cleanly.
If on the other hand, a Shutdown Hook is not registered,
then the application will suddenly exit like pressing CTRL-C in the console (command window).
Both cases, with and without a Shutdown Hook,
provide the exact same behavior as if the application was running without the Wrapper.
Detailed overview and instructions, using
Hudson as an example
(Windows
or Linux / Unix).
|
 |
 |
|
NOTE
|  |
To Users for Java versions 1.3.0 :
Shutdown Hooks were implemented with the 1.3.0 release of Java.
An application will be shutdown cleanly with the Shutdown Hooks in
either Method 1 (WrapperSimpleApp) or Method 4 (WrapperJarApp).
To Users for Java versions 1.2.x :
The Wrapper can be used with Java 1.2.x versions however some functions are disabled
due to this version of Java's lack of support for Shutdown Hooks.
Integration Method 1 (WrapperSimpleApp)
and Method 4 (WrapperJarApp)
can be used with Java 1.2.x versions, but the application will not be shutdown cleanly.
These methods normally rely on an application's own Shutdown Hook to handle any
work that needs to be done before the JVM shuts down.
To guarantee a clean shutdown of the application,
Method 2 (WrapperStartStopApp) or
Method 3 (WrapperListener),
which both directly allow code to be executed on shutdown must be used.
|
|
|
|
|
 | If you notice something that is incorrect, missing, or simply feel that some part of this page could be explained better, feel free to log in and add a comment. You will need to register before you can log on. |
|
|  |
|
 |
| |