Where can I embed startup initialization code in a Restlet web application, without using a ServletContextListener?
I wish to have transparent deployment of my Restlet to a web server like JBoss/Tomcat and would like to get rid of the initialization logic in the Listener - so as to be able to conveniently deploy it outside of a web server, if the need be - definitely not for heavy production use, but it's valuable nevertheless.
Would inserting it into org.restlet.Component
's constructor ensure that it'll only execute once? Is that the right place to put it?
public class MyComponent extends org.restlet.Component
{
public MyComponent() //constructor
{
//insert initialization code here that should run ONLY ONCE?
this.getDefaultHost().attach(new MyApplication()); // MyApplication extends org.restlet.Application
}
}
I went through the docs and also looked at a similar post: RESTlet startup initialization deprecated? but I'm still not sure if it's the right way. I would like to remove the dependency on the Listener if at all possible.