How to bail out in Extension.init()

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

How to bail out in Extension.init()

Post 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.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: How to bail out in Extension.init()

Post 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().
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Re: How to bail out in Extension.init()

Post by JohnnyD »

OK that is fine, so if we simply throw a RuntimeException it will stop this extension loading?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: How to bail out in Extension.init()

Post 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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply