You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/12/27 00:02:00 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/context DefaultCMSetter.java LogEvents.java

costin      00/12/26 15:02:00

  Modified:    src/share/org/apache/tomcat/context DefaultCMSetter.java
                        LogEvents.java
  Log:
  Better log messages, make sure LogEvents reportst all events ( it's a great tool
  in tracing the server activity )
  
  Revision  Changes    Path
  1.59      +5 -3      jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
  
  Index: DefaultCMSetter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- DefaultCMSetter.java	2000/11/02 21:14:36	1.58
  +++ DefaultCMSetter.java	2000/12/26 23:02:00	1.59
  @@ -101,7 +101,7 @@
   	if( home!= null ) {
   	    home=FileUtil.getCanonicalPath( home );
   	    cm.setHome( home );
  -	    log( "Setting server home to " + home );
  +	    log( "engineInit: home= " + home );
   	}
   	
   	
  @@ -109,7 +109,7 @@
   	if( installDir!= null ) {
   	    installDir=FileUtil.getCanonicalPath( installDir );
   	    cm.setInstallDir( installDir );
  -	    log( "Setting server install dir to " + installDir );
  +	    log( "engineInit: install= " + installDir );
   	}
   
   	// if only one is set home==installDir
  @@ -186,7 +186,9 @@
   	}
   	if( debug > 0 ) {
   	    String h=ctx.getHost();
  -	    log( ((h==null) ? "":h) + ":" + ctx.getPath() + " " + docBase + " " + absPath + " " +cm.getHome());
  +	    log( "addContext: " + ((h==null) ? "":h) + ":" +
  +		 ctx.getPath() + " " + docBase + " " + absPath + " " +
  +		 cm.getHome());
   	}
   	
   	// this would belong to a logger interceptor ?
  
  
  
  1.7       +94 -32    jakarta-tomcat/src/share/org/apache/tomcat/context/LogEvents.java
  
  Index: LogEvents.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/LogEvents.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LogEvents.java	2000/11/02 21:18:54	1.6
  +++ LogEvents.java	2000/12/26 23:02:00	1.7
  @@ -66,7 +66,9 @@
   import java.net.*;
   import java.util.*;
   
  -/** Log all Context events
  +/** Log all hook events during tomcat execution.
  + *  Use debug>0 to log addContainer ( since this generates a lot of
  + *  output )
    */
   public class LogEvents extends BaseInterceptor {
       
  @@ -75,74 +77,110 @@
   
       // -------------------- Request notifications --------------------
       public int requestMap(Request request ) {
  -	request.getContext().log( "Request map " + request);
  +	log( "requestMap " + request);
   	return 0;
       }
   
       public int contextMap( Request request ) {
  +	log( "contextMap " + request);
   	return 0;
       }
   
       public int preService(Request request, Response response) {
  -	request.getContext().log( "Pre service " + request);
  +	log( "preService " + request);
   	return 0;
       }
   
  +    public int authenticate(Request request, Response response) {
  +	log( "authenticate " + request);
  +	return 0;
  +    }
  +
  +    public int authorize(Request request, Response response,
  +			 String reqRoles[])
  +    {
  +	StringBuffer sb=new StringBuffer();
  +	appendSA( sb, reqRoles, " ");
  +	log( "authorize " + request + " " + sb.toString() );
  +	return 0;
  +    }
  +
       public int beforeBody( Request request, Response response ) {
  -	request.getContext().log( "Before body " + request);
  +	log( "beforeBody " + request);
   	return 0;
       }
   
       public int beforeCommit( Request request, Response response) {
  -	request.getContext().log( "Before commit " + request);
  +	log( "beforeCommit " + request);
   	return 0;
       }
   
   
       public int afterBody( Request request, Response response) {
  -	request.getContext().log( "After Body " + request);
  +	log( "afterBody " + request);
   	return 0;
       }
   
  +    public int postRequest( Request request, Response response) {
  +	log( "postRequest " + request);
  +	return 0;
  +    }
  +
  +    public int handleError( Request request, Response response, Throwable t) {
  +	log( "handleError " + request +  " " + t);
  +	return 0;
  +    }
  +
       public int postService(Request request, Response response) {
  -	request.getContext().log( "Post service " + request);
  +	log( "postService " + request);
   	return 0;
       }
   
  +    public int newSessionRequest( Request req, Response res ) {
  +	log( "newSessionRequest " + req );
  +	return 0;
  +    }
  +    
       // -------------------- Context notifications --------------------
       public void contextInit(Context ctx) throws TomcatException {
  -	ctx.log( "Context Init ");
  +	log( "contextInit " + ctx);
       }
   
       public void contextShutdown(Context ctx) throws TomcatException {
  -	ctx.log( "Context Shutdown ");
  +	log( "contextShutdown " + ctx);
       }
   
       /** Notify when a new servlet is added
        */
       public void addServlet( Context ctx, Handler sw) throws TomcatException {
  -	ctx.log( "Add servlet " + sw);
  +	log( "addServlet " + ctx + " " + sw );
       }
       
       /** Notify when a servlet is removed from context
        */
       public void removeServlet( Context ctx, Handler sw) throws TomcatException {
  -	ctx.log( "Remove servlet " + sw);
  +	log( "removeServlet " + ctx + " " + sw);
       }
   
       public void addMapping( Context ctx, String path, Handler servlet)
   	throws TomcatException
       {
  -	ctx.log( "Add mapping " + path + "->" + servlet);
  +	log( "addMapping " + ctx + " " + path + "->" + servlet);
       }
   
   
       public void removeMapping( Context ctx, String path )
   	throws TomcatException
       {
  -	ctx.log( "Remove mapping ");
  +	log( "removeMapping " + ctx + " " + path);
       }
   
  +    private void appendSA( StringBuffer sb, String s[], String sep) {
  +	for( int i=0; i<s.length; i++ ) {
  +	    sb.append( sep ).append( s[i] );
  +	}
  +    }
  +    
       /** 
        */
       public void addSecurityConstraint( Context ctx, String path[],
  @@ -151,40 +189,45 @@
   	throws TomcatException
       {
   	StringBuffer sb=new StringBuffer();
  -	sb.append("Add security constraint ");
  +	sb.append("addSecurityConstraint " + ctx + " " );
   	if( methods!=null ) {
   	    sb.append("Methods: ");
  -	    for( int i=0; i< methods.length; i++ ) {
  -		sb.append(" " + methods[i]);
  -	    }
  +	    appendSA( sb, methods, " " );
   	}
   	if( path!=null) {
   	    sb.append(" Paths: ");
  -	    for( int i=0; i< path.length; i++ ) {
  -		sb.append(" " + path[i]);
  -	    }
  +	    appendSA( sb, path, " " );
   	}
   	if( roles!=null) {
   	    sb.append(" Roles: ");
  -	    for( int i=0; i< roles.length; i++ ) {
  -		sb.append(" " + roles[i]);
  -	    }
  +	    appendSA( sb, roles, " " );
   	}
   	sb.append(" Transport " + transport );
  -	ctx.log(sb.toString());
  +	log(sb.toString());
       }
   
  +    public void addInterceptor( ContextManager cm, Context ctx,
  +				BaseInterceptor i )
  +	throws TomcatException
  +    {
  +	if( ctx==null)
  +	    log( "addInterceptor " + i );
  +	else {
  +	    log( "addInterceptor " + ctx + " " + i);
  +	}
  +    }
  +    
       /** Called when the ContextManger is started
        */
       public void engineInit(ContextManager cm) throws TomcatException {
  -	cm.log( "Engine init");
  +	log( "engineInit ");
       }
   
       /** Called before the ContextManager is stoped.
        *  You need to stop any threads and remove any resources.
        */
       public void engineShutdown(ContextManager cm) throws TomcatException {
  -	cm.log( "Engine shutdown");
  +	log( "engineShutdown ");
       }
   
   
  @@ -192,8 +235,27 @@
        */
       public void addContext( ContextManager cm, Context ctx )
   	throws TomcatException
  +    {
  +	log( "addContext " + ctx );
  +    }
  +
  +    public void addContainer( Container ct )
  +	throws TomcatException
  +    {
  +	if( debug > 0 )
  +	    log( "addContainer " + ct.getContext() + " " + ct );
  +    }
  +
  +    public void engineState( ContextManager cm , int state )
  +	throws TomcatException
  +    {
  +	log( "engineState " + state );
  +    }
  +
  +    public void engineStart( ContextManager cm )
  +	throws TomcatException
       {
  -	ctx.log( "Add context");
  +	log( "engineStart " );
       }
   
       /** Called when a context is removed from a CM
  @@ -201,7 +263,7 @@
       public void removeContext( ContextManager cm, Context ctx )
   	throws TomcatException
       {
  -	ctx.log( "Remove context");
  +	log( "removeContext" + ctx);
       }
   
       /** Servlet Init  notification
  @@ -209,14 +271,14 @@
       public void preServletInit( Context ctx, Handler sw )
   	throws TomcatException
       {
  -	ctx.log( "Pre servlet init " + sw);
  +	log( "preServletInit " + ctx + " " + sw);
       }
   
       
       public void postServletInit( Context ctx, Handler sw )
   	throws TomcatException
       {
  -	ctx.log( "Post servlet init " + sw);
  +	log( "postServletInit " + ctx + " " + sw);
       }
   
       /** Servlet Destroy  notification
  @@ -224,14 +286,14 @@
       public void preServletDestroy( Context ctx, Handler sw )
   	throws TomcatException
       {
  -	ctx.log( "Pre servlet destroy " + sw);
  +	log( "preServletDestroy " + ctx + " " + sw);
       }
   
       
       public void postServletDestroy( Context ctx, Handler sw )
   	throws TomcatException
       {
  -	ctx.log( "Post servlet destroy " + sw);
  +	log( "postServletDestroy " + ctx +  " " + sw);
       }
   
   }