|
From: Riyaz S. <riy...@mi...> - 2009-10-12 06:39:11
|
Hi,
I tried extending WrapperSimpleApp to implement stop method and added some
debugging statements. It seems to be not executing. What is the best way to
implement shutdown hook?
class:
public class MyWrapperApplication extends WrapperSimpleApp
{
....
....
@Override
public int stop ( int exitCode )
{
if ( logService.isInfoEnabled ( ) )
{
logService.info ( "Print Service Shutting down." );
}
return super.stop ( exitCode );
}
}
configuration:
#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
wrapper.java.command=java
# Java Main class. This class must implement the WrapperListener interface
# or guarantee that the WrapperManager class is initialized. Helper
# classes are provided to do this for you. See the Integration section
# of the documentation for details.
wrapper.java.mainclass=printservice.bootstrap.MyWrapperApplication
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=../wrapperLib/wrapper.jar
wrapper.java.classpath.2=../applicationLib/*.jar
wrapper.java.library.path.1=../wrapperLib
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
# Java Additional Parameters
# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3
# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=64
-----
Regards,
Riyaz..
--
View this message in context: http://www.nabble.com/How-to-implement-shutdown-hook-tp25851139p25851139.html
Sent from the Java Service Wrapper mailing list archive at Nabble.com.
|
|
From: Leif M. <lei...@ta...> - 2009-10-13 08:42:44
|
Riyaz,
Looking over your code, it appears to be written correctly with one
exception. The problem is that your MyWrapperApplication class does
not define its own main method. This means that it falls back to the
WrapperSimpleApp class's main method which creates a WrapperSimpleApp
instance, not a MyWrapperApplication instance.
Please add a method like the following to your class and it should
start working:
public static void main( String args[] )
{
new MyWrapperApplication( args );
}
Please let me know if you still have problems getting it work and I
will take another look.
Cheers,
Leif
On Mon, Oct 12, 2009 at 3:38 PM, Riyaz Saiyed <riy...@mi...> wrote:
>
> Hi,
>
> I tried extending WrapperSimpleApp to implement stop method and added some
> debugging statements. It seems to be not executing. What is the best way to
> implement shutdown hook?
>
> class:
> public class MyWrapperApplication extends WrapperSimpleApp
> {
> ....
> ....
> @Override
> public int stop ( int exitCode )
> {
> if ( logService.isInfoEnabled ( ) )
> {
> logService.info ( "Print Service Shutting down." );
> }
> return super.stop ( exitCode );
> }
> }
>
> configuration:
> #********************************************************************
> # Wrapper Properties
> #********************************************************************
> # Java Application
> wrapper.java.command=java
>
> # Java Main class. This class must implement the WrapperListener interface
> # or guarantee that the WrapperManager class is initialized. Helper
> # classes are provided to do this for you. See the Integration section
> # of the documentation for details.
> wrapper.java.mainclass=printservice.bootstrap.MyWrapperApplication
>
> # Java Classpath (include wrapper.jar) Add class path elements as
> # needed starting from 1
> wrapper.java.classpath.1=../wrapperLib/wrapper.jar
> wrapper.java.classpath.2=../applicationLib/*.jar
> wrapper.java.library.path.1=../wrapperLib
>
> # Java Library Path (location of Wrapper.DLL or libwrapper.so)
>
> # Java Additional Parameters
>
> # Initial Java Heap Size (in MB)
> #wrapper.java.initmemory=3
>
> # Maximum Java Heap Size (in MB)
> wrapper.java.maxmemory=64
>
>
> -----
> Regards,
> Riyaz..
|
|
From: Riyaz S. <riy...@mi...> - 2009-10-13 14:46:49
|
Hi,
Actually I switched back to the previous approach (integration method 1) and
adding shutdown hook in my main class.
...
Runtime.getRuntime ( ).addShutdownHook ( new Thread ( )
{
public void run ( )
{
if ( logService.isInfoEnabled ( ) )
{
logService.info ( "shutting down the print service"
);
}
try
{
printService.stop();
}
catch ( ApplicationException e )
{
if ( logService.isErrorEnabled ( ) )
{
logService.error ( "error stopping print
service", null, null, e );
}
}
}
} );
...
Everything is working fine now.
Leif Mortenson-3 wrote:
>
> Riyaz,
> Looking over your code, it appears to be written correctly with one
> exception. The problem is that your MyWrapperApplication class does
> not define its own main method. This means that it falls back to the
> WrapperSimpleApp class's main method which creates a WrapperSimpleApp
> instance, not a MyWrapperApplication instance.
>
> Please add a method like the following to your class and it should
> start working:
> public static void main( String args[] )
> {
> new MyWrapperApplication( args );
> }
>
> Please let me know if you still have problems getting it work and I
> will take another look.
>
> Cheers,
> Leif
>
> On Mon, Oct 12, 2009 at 3:38 PM, Riyaz Saiyed <riy...@mi...>
> wrote:
>>
>> Hi,
>>
>> I tried extending WrapperSimpleApp to implement stop method and added
>> some
>> debugging statements. It seems to be not executing. What is the best way
>> to
>> implement shutdown hook?
>>
>> class:
>> public class MyWrapperApplication extends WrapperSimpleApp
>> {
>> ....
>> ....
>> @Override
>> public int stop ( int exitCode )
>> {
>> if ( logService.isInfoEnabled ( ) )
>> {
>> logService.info ( "Print Service Shutting down." );
>> }
>> return super.stop ( exitCode );
>> }
>> }
>>
>> configuration:
>> #********************************************************************
>> # Wrapper Properties
>> #********************************************************************
>> # Java Application
>> wrapper.java.command=java
>>
>> # Java Main class. This class must implement the WrapperListener
>> interface
>> # or guarantee that the WrapperManager class is initialized. Helper
>> # classes are provided to do this for you. See the Integration section
>> # of the documentation for details.
>> wrapper.java.mainclass=printservice.bootstrap.MyWrapperApplication
>>
>> # Java Classpath (include wrapper.jar) Add class path elements as
>> # needed starting from 1
>> wrapper.java.classpath.1=../wrapperLib/wrapper.jar
>> wrapper.java.classpath.2=../applicationLib/*.jar
>> wrapper.java.library.path.1=../wrapperLib
>>
>> # Java Library Path (location of Wrapper.DLL or libwrapper.so)
>>
>> # Java Additional Parameters
>>
>> # Initial Java Heap Size (in MB)
>> #wrapper.java.initmemory=3
>>
>> # Maximum Java Heap Size (in MB)
>> wrapper.java.maxmemory=64
>>
>>
>> -----
>> Regards,
>> Riyaz..
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Wrapper-user mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
>
-----
Regards,
Riyaz..
--
View this message in context: http://www.nabble.com/How-to-implement-shutdown-hook-tp25851139p25874277.html
Sent from the Java Service Wrapper mailing list archive at Nabble.com.
|