I am embedding Tomcat 7 into my Java application. In the constructor I set the variable:
this.tomcat = new Tomcat();
this.started = false;
I then have another method called at a later point to start it:
this.tomcat.start();
this.started = true;
I use the this.started
variable to keep track of whether I ever started the server. Means that the state of the server is kept multiple times (internally by Tomcat and again in the variable). Ideally, I would like to just use the Tomcat API to get the status of the server, but I have not been able to find a method to do it.
The best alternative that I have found is trying to open a connection to the server. It seems like a slow (in CPU time scale) and resource inefficient solution.