tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/admin/contextAdmin sessionExpire.jsp sessionState.jsp ctxDetail.jsp
Date Fri, 23 Mar 2001 02:14:17 GMT
costin      01/03/22 18:14:17

  Modified:    src/admin/WEB-INF admin.tld
               src/admin/WEB-INF/classes/tadm TomcatAdmin.java
                        TomcatAdminTEI.java TomcatIterateTEI.java
               src/admin/contextAdmin ctxDetail.jsp
  Added:       src/admin/WEB-INF/classes/tadm ContextAdmin.java
                        ModuleAdmin.java ModuleAdminTEI.java
               src/admin/contextAdmin sessionExpire.jsp sessionState.jsp
  Log:
  Added 2 pages and a tag to display informations about sessions.
  
  This was done to debug one of the bugs and to better monitor
  what was happening. You can see all active sessions for a context
  and invalidate individual sessions.
  ( of course, this is just better than nothing, a bit of HTML-formating
  and more details would be even better )
  
  Revision  Changes    Path
  1.9       +58 -0     jakarta-tomcat/src/admin/WEB-INF/admin.tld
  
  Index: admin.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/admin.tld,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- admin.tld	2001/01/29 06:46:17	1.8
  +++ admin.tld	2001/03/23 02:14:16	1.9
  @@ -55,6 +55,64 @@
       </attribute>
     </tag>
   
  +  <tag>
  +    <name>contextAdmin</name>
  +    <tagclass>tadm.ContextAdmin</tagclass>
  +    <info>
  +       Will set the "ctx" variable based on the ctxPathParam parameter
  +       and perform context actions. ( will replace adm:admin which 
  +       also declares the vars - so can't have multiple instances ).
  +    </info>
  +    <attribute>
  +      <name>action</name>
  +      <required>false</required>
  +    </attribute>
  +    <attribute>
  +      <name>ctxPathParam</name>
  +      <required>false</required>
  +    </attribute>
  +    <attribute>
  +      <name>docBaseParam</name>
  +      <required>false</required>
  +    </attribute>
  +    <attribute>
  +      <name>docBase</name>
  +      <required>false</required>
  +    </attribute>
  +    <attribute>
  +      <name>ctxPath</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>ctxHost</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>value</name>
  +      <required>false</required>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>moduleAdmin</name>
  +    <tagclass>tadm.ModuleAdmin</tagclass>
  +    <teiclass>tadm.ModuleAdminTEI</teiclass>
  +    <info>
  +      Will set the "module" variable and perform module actions.
  +    </info>
  +    <attribute>
  +      <name>type</name>
  +      <required>true</required>
  +    </attribute>
  +    <attribute>
  +      <name>var</name>
  +      <required>true</required>
  +    </attribute>
  +  </tag>
  +
  +
     <!-- this is a "generic" tag, should be moved in a separate tld -->  
     <tag>
       <name>iterate</name>
  
  
  
  1.12      +16 -15    jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdmin.java
  
  Index: TomcatAdmin.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdmin.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TomcatAdmin.java	2001/03/02 05:26:01	1.11
  +++ TomcatAdmin.java	2001/03/23 02:14:16	1.12
  @@ -9,7 +9,7 @@
   import javax.servlet.jsp.tagext.*;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.util.log.*;
  -import org.apache.tomcat.util.qlog.*;
  +//import org.apache.tomcat.util.qlog.*;
   
   /**
    * A context administration class. Contexts can be
  @@ -54,6 +54,7 @@
   		    // XXX virtual host
   		    if( ctxPath.equals( ctx.getPath())) {
   			pageContext.setAttribute("ctx", ctx);
  +			System.out.println("Found " + ctx );
   			break;
   		    }
   		}
  @@ -133,21 +134,21 @@
       private void setLogFile( Context ctx, String dest )
   	throws TomcatException
       {
  -	try {
  -	    QueueLogger logger=new QueueLogger();
  -	    System.out.println("Setting logger " + dest );
  -	    logger.setPath( dest );
  -	    logger.open();
  -	    LogManager logManager=(LogManager)ctx.getContextManager().
  -		getNote("tc.LogManager");
  +// 	try {
  +// 	    QueueLogger logger=new QueueLogger();
  +// 	    System.out.println("Setting logger " + dest );
  +// 	    logger.setPath( dest );
  +// 	    logger.open();
  +// 	    LogManager logManager=(LogManager)ctx.getContextManager().
  +// 		getNote("tc.LogManager");
   	    
  -	    logManager.addChannel("temp.log", logger );
  -	    Log log=Log.getLog( "temp.log", ctx );
  -	    ctx.setLog( log );
  -	    ctx.setServletLog( log );
  -	} catch( Exception ex ) {
  -	    ex.printStackTrace();
  -	}
  +// 	    logManager.addChannel("temp.log", logger );
  +// 	    Log log=Log.getLog( "temp.log", ctx );
  +// 	    ctx.setLog( log );
  +// 	    ctx.setServletLog( log );
  +// 	} catch( Exception ex ) {
  +// 	    ex.printStackTrace();
  +// 	}
       }
   
       private void addContext( ContextManager cm, String host, String path,
  
  
  
  1.5       +3 -0      jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdminTEI.java
  
  Index: TomcatAdminTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdminTEI.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TomcatAdminTEI.java	2000/12/31 15:39:15	1.4
  +++ TomcatAdminTEI.java	2001/03/23 02:14:16	1.5
  @@ -23,6 +23,9 @@
   	    new VariableInfo("cm", "org.apache.tomcat.core.ContextManager",
   			     true,  VariableInfo.AT_BEGIN),
   	    new VariableInfo("ctx", "org.apache.tomcat.core.Context",
  +			     true,  VariableInfo.AT_BEGIN),
  +	    new VariableInfo("module",
  +			     "org.apache.tomcat.core.BaseInterceptor",
   			     true,  VariableInfo.AT_BEGIN)
   	});
   
  
  
  
  1.5       +0 -3      jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatIterateTEI.java
  
  Index: TomcatIterateTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatIterateTEI.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TomcatIterateTEI.java	2000/12/31 15:39:15	1.4
  +++ TomcatIterateTEI.java	2001/03/23 02:14:16	1.5
  @@ -24,9 +24,6 @@
   			     data.getAttributeString( "type" ),
   			     true,
   			     VariableInfo.NESTED ), 
  -			     
  -	    new VariableInfo("ctx2", "org.apache.tomcat.core.Context",
  -			     true,  VariableInfo.NESTED)
   	});
   
       }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/ContextAdmin.java
  
  Index: ContextAdmin.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.log.*;
  
  /**
   * A context administration class. Contexts can be
   * viewed, added, and removed from the context manager.
   *
   */
  public class ContextAdmin extends TagSupport {
      private ContextManager cm;
      String ctxPath;
      String docBase;
      String ctxPathParam;
      String docBaseParam;
      String action;
      String host;
      String value;
      //    PageContext pageContext;
      
      public ContextAdmin() {}
  
      public int doStartTag() throws JspException {
  	try {
  	    HttpServletRequest req=(HttpServletRequest)pageContext.
  		getRequest();
  
  	    cm=(ContextManager)pageContext.getAttribute("cm");
  	    if( cm==null )
  		throw new JspException( "Can't find context manager" );
  
  	    Context ctx=null;
  	    if( ctxPath==null && ctxPathParam!=null ) {
  		ctxPath=req.getParameter( ctxPathParam );
  	    }
  
  	    if( docBase==null &&  docBaseParam!=null) {
  		docBase=req.getParameter( docBaseParam );
  	    }
  	    
  	    if( ctxPath != null ) {
  		if( debug>0 ) log("Finding " + ctxPath );
  		Enumeration en=cm.getContexts();
  		while( en.hasMoreElements() ) {
  		    ctx=(Context)en.nextElement();
  		    // XXX virtual host
  		    if( ctxPath.equals( ctx.getPath())) {
  			pageContext.setAttribute("ctx", ctx);
  			break;
  		    }
  		}
  	    }
  	    if( ctx==null ) {
  		throw new JspException("Can't find context " + ctxPath );
  	    }
  	    if("removeContext".equals( action ) )
  		removeContext( cm , ctx);
  	    if("setLogger".equals( action ) )
  		setLogFile(  ctx, value );
  	    if("addContext".equals( action ) )
  		addContext( cm, host, ctxPath, docBase );
  	} catch (Exception ex ) {
  	    ex.printStackTrace();
  	}
  	return EVAL_BODY_INCLUDE;
      }
  
      public int doEndTag() throws JspException {
  	return EVAL_PAGE;
      }
      
      public void setParent( Tag parent ) {
  	super.setParent( parent);
      }
  
      // -------------------- Properties --------------------
      
      public void setCtxPath( String ctx ) {
  	ctxPath=ctx;
      }
  
      public void setCtxPathParam( String ctx ) {
  	ctxPathParam=ctx;
      }
      
      public void setDocBaseParam( String ctx ) {
  	docBaseParam=ctx;
      }
  
      public void setCtxHost( String host ) {
  	this.host=host;
      }
  
      public void setAction( String action ) {
  	this.action=action;
      }
  
      public void setDocBase( String docBase ) {
  	this.docBase=docBase;
      }
  
      public void setValue( String s ) {
  	this.value=s;
      }
  
      
      private void removeContext( ContextManager cm, Context ctx)
  	throws TomcatException
      {
  	if( debug > 0 ) log("Removing " + ctx );
  	cm.removeContext( ctx );
      }
  
      private void setLogFile( Context ctx, String dest )
  	throws TomcatException
      {
  // 	try {
  // 	    QueueLogger logger=new QueueLogger();
  // 	    if( debug > 0 ) log ("Setting logger " + dest );
  // 	    logger.setPath( dest );
  // 	    logger.open();
  // 	    LogManager logManager=(LogManager)ctx.getContextManager().
  // 		getNote("tc.LogManager");
  	    
  // 	    logManager.addChannel("temp.log", logger );
  // 	    Log log=Log.getLog( "temp.log", ctx );
  // 	    ctx.setLog( log );
  // 	    ctx.setServletLog( log );
  // 	} catch( Exception ex ) {
  // 	    ex.printStackTrace();
  // 	}
      }
  
      private void addContext( ContextManager cm, String host, String path,
  			     String docBase)
  	throws TomcatException
      {
  	if( ! docBase.startsWith("/") ) {
  	    docBase=cm.getHome() + "/" + docBase;
  	}
  	if( debug > 0 )
  	    log("Adding " + path + " " + docBase);
  	Context context = new Context();
  	context.setContextManager(cm);
  	context.setPath(path);
  	context.setDocBase(docBase);
  
  	cm.addContext(context);
  	context.init();
      }
  
      // --------------------
      private static int debug=0;
      
      private void log(String s ) {
  	System.out.println(s );
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/ModuleAdmin.java
  
  Index: ModuleAdmin.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.log.*;
  
  /**
   * A context administration class. Contexts can be
   * viewed, added, and removed from the context manager.
   *
   */
  public class ModuleAdmin extends TagSupport {
      private ContextManager cm;
  
      String var;
      String moduleName;
      
      public ModuleAdmin() {}
  
      /** Will set the "module" attribute, with the instance of the
       *  named interceptor. If "ctx" attribute is set, look in that
       *  context
       */
      public int doStartTag() throws JspException {
  	try {
  	    cm=(ContextManager)pageContext.getAttribute("cm");
  	    if( cm==null )
  		throw new JspException( "Can't find context manager" );
  
  	    Context ctx=(Context)pageContext.getAttribute("ctx");
  
  	    Container ct=(ctx==null)? cm.getContainer():ctx.getContainer();
  	    BaseInterceptor bi[]=ct.getInterceptors();
  	    BaseInterceptor found=null;
  	    for( int i=0; i<bi.length; i++ ) {
  		String cn=bi[i].getClass().getName();
  		if( cn.equals( moduleName )) {
  		    found=bi[i];
  		    pageContext.setAttribute( var,bi[i],
  					      PageContext.PAGE_SCOPE );
  		    break;
  		}
  	    }
  	    if( found==null )
  		throw new JspException("Can't find module " + moduleName +
  				       " in " + ctx );
  	} catch (Exception ex ) {
  	    ex.printStackTrace();
  	}
  	return EVAL_BODY_INCLUDE;
      }
  
      // -------------------- Properties --------------------
      
      public void setVar(String m) {
  	var=m;
      }
  
      public void setType( String m ) {
  	moduleName=m;
      }
  
      // --------------------
      private static int debug=0;
      
      private void log(String s ) {
  	System.out.println(s );
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/ModuleAdminTEI.java
  
  Index: ModuleAdminTEI.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.File;
  import java.net.URL;
  import javax.servlet.http.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.tomcat.core.Request;
  import org.apache.tomcat.core.Context;
  import org.apache.tomcat.core.ContextManager;
  
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  public class ModuleAdminTEI extends TagExtraInfo {
  
      public VariableInfo[] getVariableInfo(TagData data) {
  	return (new VariableInfo[] {
  	    new VariableInfo(data.getAttributeString( "var" ),
  			     data.getAttributeString( "type" ),
  			     true,
  			     VariableInfo.AT_BEGIN ), 
  	});
  
      }
  
  
  }
  
  
  
  1.3       +2 -1      jakarta-tomcat/src/admin/contextAdmin/ctxDetail.jsp
  
  Index: ctxDetail.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/contextAdmin/ctxDetail.jsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ctxDetail.jsp	2000/12/27 21:41:31	1.2
  +++ ctxDetail.jsp	2001/03/23 02:14:17	1.3
  @@ -9,7 +9,7 @@
   
   <body bgcolor="white">
   
  -<adm:admin ctxPath='<%= request.getParameter("ctx") %>' />
  +<adm:admin ctxPathParam="ctx" />
   
   <%
     if( ctx==null ) {
  @@ -17,6 +17,7 @@
     <h1>Error, no context for <%= request.getParameter( "ctx" ) %> </h1>
   <% } else { %>
   
  +  <a href="sessionState.jsp?ctx=<%= request.getParameter( "ctx" ) %>">Session
info</a>
     <table border="0" cellpad="2" >
     <tr bgcolor="#e1e1e1">
   
  
  
  
  1.1                  jakarta-tomcat/src/admin/contextAdmin/sessionExpire.jsp
  
  Index: sessionExpire.jsp
  ===================================================================
  <html>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/tomcat_admin-1.0" 
             prefix="adm" %>
  <head>
      <title>Session info</title>
  </head>
  
  <body bgcolor="white">
  
  <adm:admin ctxPathParam="ctx"/>
  <adm:moduleAdmin var="store" 
  		 type="org.apache.tomcat.modules.session.SimpleSessionStore" />
  
    <h3>Invalidate <%= request.getParameter("id" ) %></h3>
  
  <% org.apache.tomcat.core.ServerSession s=store.findSession( ctx, 
               request.getParameter("id" ));
     s.setState( org.apache.tomcat.core.ServerSession.STATE_EXPIRED );
  %>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-tomcat/src/admin/contextAdmin/sessionState.jsp
  
  Index: sessionState.jsp
  ===================================================================
  <html>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/tomcat_admin-1.0" 
             prefix="adm" %>
  <head>
      <title>Session info</title>
  </head>
  
  <body bgcolor="white">
  
  <adm:admin ctxPathParam="ctx"/>
  <adm:moduleAdmin var="store" 
  		 type="org.apache.tomcat.modules.session.SimpleSessionStore" />
  
    <h3>Session store info</h3>
  
    <ul>
      <li>Context: <%= ctx %>
      <li>Default timeout: <%= ctx.getSessionTimeOut() %>
      <li>Active sessions: <%= store.getSessionCount(ctx) %>
      <li>Recycled sessions: <%= store.getRecycledCount(ctx) %>
    <ul>
  
      <table border>
        <tr>
  	  <th>Id</th>
  	  <th>Attrs</th>
  	  <th>St</th>
  	  <th>Creation</th>
  	  <th>Access</th>
  	  <th>Exp</th>
  	  <th>New</th>
        </tr>
       <adm:iterate name="sS" 
                    enumeration="<%= store.getSessions(ctx) %>" 
                    type="org.apache.tomcat.core.ServerSession" >
        <tr>
  	  <td><%= sS.getId().toString() %></td>
  	  <td><%= sS.getAttributeCount() %></td>
  	  <td><a href="sessionExpire.jsp?ctx=<%= request.getParameter("ctx") %>&id=<%=
sS.getId().toString() %>" >
                <%= sS.getState() %></td>
  	      </a>
  	  <td><%= sS.getTimeStamp().getCreationTime() %></td>
  	  <td><%= sS.getTimeStamp().getLastAccessedTime() %></td>
  	  <td><%= sS.getTimeStamp().getMaxInactiveInterval() %></td>
  	  <td><%= sS.getTimeStamp().isNew() %></td>
        </tr>
       </adm:iterate>
      </table>
  
  </body>
  </html>
  
  
  

Mime
View raw message