I have a small RESTful webservice, which runs fine on Tomcat. Some code
@Path("service")
public class MyService() {
private static boolean isRunning = false;
public MyService() {
if (!isRunning) {
System.out.println("Hello World");
isRunning = true:
}
}
@GET
public Response fooBar() {
/* Some code here */
}
}
When calling the GET-method on the first time, the constructor is called and prints "Hello World" to me. Is there any way to call the constructor after deploying it on Tomcat?
Well, in my case, the constructor will do some init stuff and the server itselfs should run in a singleton pattern, so it shouldn't be a big deal.
Aucun commentaire:
Enregistrer un commentaire