|
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 four 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.
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.
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).
|
|