I have a Tomcat server deployed that receives observations transmitted from sensors in JSON format. I also have a sensor describing ontology that I want to make use of.
However, I'd like to load the ontology before any sensor observations are received by the server. How can I instantiate an object as soon as Tomcat is loaded?
To execute actions when your application starts or stops you should use a ServletContextListener
: http://download.oracle.com/javaee/6/api/javax/servlet/ServletContextListener.html
In web.xml:
<web-app>
...
<listener>
<listener-class>com.example.Listener</listener-class>
</listener>
...
</web-app>
In contrast to Peter Knego's proposal this solution is portable to any servlet container and not confined to Tomcat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With