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.htmlIn web.xml:
In contrast to Peter Knego’s proposal this solution is portable to any servlet container and not confined to Tomcat.