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...@apache.org on 2003/01/16 22:41:45 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapper.java

costin      2003/01/16 13:41:45

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  The servlet wrapper will register itself using the JSR77 name.
  The app and server name are taken from the context.
  
  The load time, processing time and other nice data is exposed via JMX
   (collected in the valve - to not affect the performance ).
  
  Revision  Changes    Path
  1.11      +72 -15    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StandardWrapper.java	8 Dec 2002 13:42:09 -0000	1.10
  +++ StandardWrapper.java	16 Jan 2003 21:41:45 -0000	1.11
  @@ -90,6 +90,7 @@
   import org.apache.catalina.util.Enumerator;
   import org.apache.catalina.util.InstanceSupport;
   import org.apache.tomcat.util.log.SystemLogHandler;
  +import org.apache.commons.modeler.Registry;
   /**
    * Standard implementation of the <b>Wrapper</b> interface that represents
    * an individual servlet definition.  No child Containers are allowed, and
  @@ -115,7 +116,8 @@
       public StandardWrapper() {
   
           super();
  -        pipeline.setBasic(new StandardWrapperValve());
  +        swValve=new StandardWrapperValve();
  +        pipeline.setBasic(swValve);
   
       }
   
  @@ -246,6 +248,10 @@
        */
       private boolean swallowOutput = false;
   
  +    // To support jmx attributes
  +    private StandardWrapperValve swValve;
  +    private long loadTime=0;
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -867,11 +873,6 @@
               // Special case class loader for a container provided servlet
               if (isContainerProvidedServlet(actualClass)) {
                   classLoader = this.getClass().getClassLoader();
  -                long t2=System.currentTimeMillis();
  -                if( t2-t1 > 200 )
  -                    log.info(sm.getString
  -                             ("standardWrapper.containerServlet", getName()) +
  -                             " " + (t2 - t1 ));
               }
       
               // Load the specified servlet class from the appropriate class loader
  @@ -993,10 +994,8 @@
                       instancePool = new Stack();
               }
               fireContainerEvent("load", this);
  -            if( System.currentTimeMillis() -t1 > 200 ) {
  -                log.info("Loaded servlet  " + actualClass + " " +
  -                         (System.currentTimeMillis() - t1 ) );
  -            }
  +
  +            loadTime=System.currentTimeMillis() -t1;
           } finally {
               if (swallowOutput) {
                   String log = SystemLogHandler.stopCapture();
  @@ -1009,6 +1008,7 @@
                   }
               }
           }
  +        registerJMX((ContainerBase)getParent(), this);
           return servlet;
   
       }
  @@ -1274,7 +1274,45 @@
   
       }
   
  +    public long getProcessingTime() {
  +        return swValve.getProcessingTime();
  +    }
  +
  +    public void setProcessingTime(long processingTime) {
  +        swValve.setProcessingTime(processingTime);
  +    }
  +
  +    public long getMaxTime() {
  +        return swValve.getMaxTime();
  +    }
  +
  +    public void setMaxTime(long maxTime) {
  +        swValve.setMaxTime(maxTime);
  +    }
  +
  +    public int getRequestCount() {
  +        return swValve.getRequestCount();
  +    }
   
  +    public void setRequestCount(int requestCount) {
  +        swValve.setRequestCount(requestCount);
  +    }
  +
  +    public int getErrorCount() {
  +        return swValve.getErrorCount();
  +    }
  +
  +    public void setErrorCount(int errorCount) {
  +           swValve.setErrorCount(errorCount);
  +    }
  +
  +    public long getLoadTime() {
  +        return loadTime;
  +    }
  +
  +    public void setLoadTime(long loadTime) {
  +        this.loadTime = loadTime;
  +    }
       // -------------------------------------------------------- Package Methods
   
   
  @@ -1400,5 +1438,24 @@
   
       }
   
  -
  +    void registerJMX(ContainerBase ctx, StandardWrapper wrapper) {
  +        try {
  +            String name=wrapper.getJspFile();
  +            if( name==null ) {
  +                name=wrapper.getServletName();
  +            }
  +            // it should be full name
  +            String parentName=ctx.getName();
  +            String hostName=ctx.getParent().getName();
  +            String webMod=((hostName==null)? "DEFAULT" :hostName ) +
  +                    (("".equals(parentName) ) ? "/" : parentName );
  +            String oname="j2eeType=Servlet,name=" + name + ",WebModule=" +
  +                    webMod + ctx.getJSR77Suffix();
  +
  +            Registry.getRegistry().registerComponent(wrapper,
  +                    ctx.getDomain(), "Servlet", oname);
  +        } catch( Exception ex ) {
  +            log.info("Error registering servlet with jmx " + this);
  +        }
  +    }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>