|
From: Jan B. <jb...@pr...> - 2004-03-26 09:55:02
|
Hi,
> I see in the docs it is possible to request a restart with
> WrapperManager.restart(), but I cannot have a compile decency on the
> wrapper code.
> So I wonder if it's possible to configure the wrapper so it catches a
> System.exit(X) where X == Y todo a restart?
>
> In my case I want a restart when I quit with System.exit(99)
>
> It would be awesome when I could specify:
>
> # Makes the wrapper restart when System.exit(99) is executed
> wrapper.restart.on_exitcode=99
>
>> Messageas far as i know System.exit () is terminal: no callbacks, no
>> override, and it does not even come back.
>> so use reflection instead and you won't have the compile-time
>> dependency:
>>
>> final String wrapperManagerClassName =
>> "org.tanukisoftware.wrapper.WrapperManager";
>> final Class wrapperManagerClass = ClassUtil.forName
>> (wrapperManagerClassName);
>> final Method restartMethod =
>> wrapperManagerClass.getDeclaredMethod (
>> "restart",
>> new Class [] {});
>> restartMethod.invoke (null, new Object[] {});
To make myself more clear, I EXIT my application with special exit code,
the wrapper receives this exit code and if it is the code indicated in
the properties as restart code, it restarts the JVM.
The problem with "WrapperManager.restart()" is that my application can
also be started on the command line from a shell script which already
catches the exitcode and restarts the JVM, so in that case I'm not using
the wrapper (code) at all.
In my opinion is "System.exit(restart_code)" also more elegant than
"WrapperManager.restart()"...
Kind Regards
Jan Blok
|