Page 1 of 1
How to bail out in Extension.init()
Posted: 14 Dec 2012, 12:16
by JohnnyD
If I find a serious problem when the server is starting up in init() override, is there a way I can force SFS to fail and exit? An example might be if my custom DB code can't connect to the DB, or some critical data is not found, etc.
Re: How to bail out in Extension.init()
Posted: 14 Dec 2012, 19:57
by rjgtav
Hi,
When you throw an exception on the init of your extension, only the extension is disabled, and the server finishes booting with no problems.
As a result, if you want so stop the server completely, then I think that the only solution is to shutdown the JVM, by calling Runtime.exit().
Re: How to bail out in Extension.init()
Posted: 15 Dec 2012, 15:04
by JohnnyD
OK that is fine, so if we simply throw a RuntimeException it will stop this extension loading?
Re: How to bail out in Extension.init()
Posted: 15 Dec 2012, 15:53
by rjgtav
If you throw a RuntimeException, if I'm not mistaken, it will prevent the extension from loading, but you won't also be able to communicate with it.
You can try it by simply throwing an exception on the init of your extension.