tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ziggy <>
Subject Accessing context information remotely - Context.getAvailable() etc.
Date Thu, 06 Jan 2011 18:07:51 GMT
I was looking at the code for the Tomcat Manager application to try and find
out how it is determining whether a webapp/context is running and how many
sesions are active. Looking at the code i think it uses these two methods

Context.getAvailalbe() //check if available
Context.getManager().findSessions().length // Number of sessions.

Here is the relevant function

   protected void list(PrintWriter writer) {

        if (debug >= 1)
            log("list: Listing contexts for virtual host '" +
                host.getName() + "'");

        Container[] contexts = host.findChildren();
        for (int i = 0; i < contexts.length; i++) {
            Context context = (Context) contexts[i];
            String displayPath = context.getPath();
            if( displayPath.equals("") )
                displayPath = "/";
            if (context != null ) {
                if (context.getAvailable()) {
                                      "" +
                } else {

I was looking at the above for the above information as i am working on a
client tool that tries to find out this exact information. The tool i am
using connects to Tomcat via JMX but i am not sure if i can get the same
information via JMX. Can i access the Context class? or is there any other
way (Mbeans?) i can check if a context is running via JMX?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message