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 2002/11/05 22:35:00 UTC

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

costin      2002/11/05 13:35:00

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  Use commons-logging.
  
  Add a short message for servlets that take a long time to load
  ( right now it's 200 ms - we can increase it, but no need to
  make it configurable, it's mostly do debug perf. ).
  
  I used idea to edit the file - and it removed unused imports and
  forced me to fix some name mismatches... Probably should go back
  to emacs...
  
  Revision  Changes    Path
  1.7       +40 -53    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StandardWrapper.java	16 Oct 2002 15:42:09 -0000	1.6
  +++ StandardWrapper.java	5 Nov 2002 21:35:00 -0000	1.7
  @@ -65,43 +65,17 @@
   package org.apache.catalina.core;
   
   
  -import java.io.File;
  -import java.io.IOException;
  -import java.io.PrintStream;
  -import java.net.URL;
  -import java.util.Enumeration;
  -import java.util.HashMap;
  -import java.util.Stack;
  -import javax.servlet.Servlet;
  -import javax.servlet.ServletConfig;
  -import javax.servlet.ServletContext;
  -import javax.servlet.ServletException;
  -import javax.servlet.SingleThreadModel;
  -import javax.servlet.UnavailableException;
  -import javax.servlet.http.HttpServletResponse;
  -import org.apache.catalina.Container;
  -import org.apache.catalina.ContainerServlet;
  -import org.apache.catalina.Context;
  -import org.apache.catalina.InstanceEvent;
  -import org.apache.catalina.InstanceListener;
  -import org.apache.catalina.Lifecycle;
  -import org.apache.catalina.LifecycleException;
  -import org.apache.catalina.Loader;
  -import org.apache.catalina.Logger;
  -import org.apache.catalina.Request;
  -import org.apache.catalina.Response;
  -import org.apache.catalina.Wrapper;
  -import javax.servlet.ServletRequest;
  -import javax.servlet.ServletResponse;
  -import org.apache.catalina.loader.StandardClassLoader;
  +import org.apache.catalina.*;
  +import org.apache.catalina.security.SecurityUtil;
   import org.apache.catalina.util.Enumerator;
   import org.apache.catalina.util.InstanceSupport;
  -import org.apache.catalina.security.SecurityUtil;
   import org.apache.tomcat.util.log.SystemLogHandler;
   
  -import java.security.PrivilegedActionException;
  -import java.security.PrivilegedExceptionAction;
  -import javax.security.auth.Subject;
  +import javax.servlet.*;
  +import java.io.PrintStream;
  +import java.util.Enumeration;
  +import java.util.HashMap;
  +import java.util.Stack;
   /**
    * Standard implementation of the <b>Wrapper</b> interface that represents
    * an individual servlet definition.  No child Containers are allowed, and
  @@ -116,7 +90,8 @@
       extends ContainerBase
       implements ServletConfig, Wrapper {
   
  -
  +    private static org.apache.commons.logging.Log log=
  +        org.apache.commons.logging.LogFactory.getLog( StandardWrapper.class );
       // ----------------------------------------------------------- Constructors
   
   
  @@ -440,7 +415,7 @@
        * Set the maximum number of instances that will be allocated when a single
        * thread model servlet is used.
        *
  -     * @param maxInstnces New value of maxInstances
  +     * @param maxInstances New value of maxInstances
        */
       public void setMaxInstances(int maxInstances) {
   
  @@ -481,7 +456,7 @@
       /**
        * Set the run-as identity for this servlet.
        *
  -     * @param value New run-as identity value
  +     * @param runAs New run-as identity value
        */
       public void setRunAs(String runAs) {
   
  @@ -642,8 +617,8 @@
        */
       public Servlet allocate() throws ServletException {
   
  -        if (debug >= 1)
  -            log("Allocating an instance");
  +        if (log.isDebugEnabled())
  +            log.debug("Allocating an instance");
   
           // If we are currently unloading this servlet, throw an exception
           if (unloading)
  @@ -670,8 +645,8 @@
               }
   
               if (!singleThreadModel) {
  -                if (debug >= 2)
  -                    log("  Returning non-STM instance");
  +                if (log.isTraceEnabled())
  +                    log.trace("  Returning non-STM instance");
                   countAllocated++;
                   return (instance);
               }
  @@ -700,8 +675,8 @@
                       }
                   }
               }
  -            if (debug >= 2)
  -                log("  Returning allocated STM instance");
  +            if (log.isTraceEnabled())
  +                log.trace("  Returning allocated STM instance");
               countAllocated++;
               return (Servlet) instancePool.pop();
   
  @@ -833,6 +808,7 @@
           SystemLogHandler.startCapture();
           Servlet servlet;
           try {
  +            long t1=System.currentTimeMillis();
               // If this "servlet" is really a JSP file, get the right class.
               // HOLD YOUR NOSE - this is a kludge that avoids having to do special
               // case Catalina-specific code in Jasper - it also requires that the
  @@ -866,8 +842,11 @@
               // Special case class loader for a container provided servlet
               if (isContainerProvidedServlet(actualClass)) {
                   classLoader = this.getClass().getClassLoader();
  -                log(sm.getString
  -                      ("standardWrapper.containerServlet", getName()));
  +                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
  @@ -880,6 +859,7 @@
                   }
               } catch (ClassNotFoundException e) {
                   unavailable(null);
  +                log.error( "Error loading " + classLoader + " " + actualClass, e );
                   throw new ServletException
                       (sm.getString("standardWrapper.missingClass", actualClass),
                        e);
  @@ -919,7 +899,10 @@
                   ((ContainerServlet) servlet).setWrapper(this);
               }
       
  -    
  +            if( System.currentTimeMillis() -t1 > 100 ) {
  +                log.info("Created servlet class " + actualClass + " " +
  +                         (System.currentTimeMillis() - t1 ) );
  +            }
               // Call the initialization method of this servlet
               try {
                   instanceSupport.fireInstanceEvent(InstanceEvent.BEFORE_INIT_EVENT,
  @@ -985,6 +968,10 @@
                       instancePool = new Stack();
               }
               fireContainerEvent("load", this);
  +            if( System.currentTimeMillis() -t1 > 100 ) {
  +                log.info("Loaded servlet  " + actualClass + " " +
  +                         (System.currentTimeMillis() - t1 ) );
  +            }
           } finally {
               String log = SystemLogHandler.stopCapture();
               if (log != null && log.length() > 0) {
  @@ -1068,7 +1055,7 @@
        *  to mark this servlet as permanently unavailable
        */
       public void unavailable(UnavailableException unavailable) {
  -        log(sm.getString("standardWrapper.unavailable", getName()));
  +        log.info(sm.getString("standardWrapper.unavailable", getName()));
           if (unavailable == null)
               setAvailable(Long.MAX_VALUE);
           else if (unavailable.isPermanent())
  @@ -1107,7 +1094,7 @@
               int nRetries = 0;
               while (nRetries < 10) {
                   if (nRetries == 0) {
  -                    log("Waiting for " + countAllocated +
  +                    log.info("Waiting for " + countAllocated +
                           " instance(s) to be deallocated");
                   }
                   try {
  @@ -1269,7 +1256,7 @@
        * container provided servlet class that should be loaded by the
        * server class loader.
        *
  -     * @param name Name of the class to be checked
  +     * @param classname Name of the class to be checked
        */
       private boolean isContainerProvidedServlet(String classname) {
   
  @@ -1357,7 +1344,7 @@
           try {
               unload();
           } catch (ServletException e) {
  -            log(sm.getString("standardWrapper.unloadException", getName()), e);
  +            log.error(sm.getString("standardWrapper.unloadException", getName()), e);
           }
   
           // Shut down this component
  
  
  

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


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

Posted by Henri Gomez <hg...@apache.org>.
Tim Funk wrote:
> In case you weren't joking ...
> 
> It can easily break compatibility if someone introduces a new class with 
> the same class name as another class in a different package.
> 
> ex:
> import foo.*; /* has class A */
> import bar.*; /* has class B */
> 
> class Foo {
>     A a;
>     B b;
> }
> 
> Imagine time going by and another developer creates another class called 
> A in the bar package. The code above will not recompile because of the 
> abiguous class name.

I think costin is speaking about importing java.io.*
or org.apache.*.

BTW, there is ant task, for example CheckStyle 
(http://checkstyle.sourceforge.net/) which could be used
and which may be integrated in build/gump to clean code....




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


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

Posted by Bob Herrmann <bo...@hue.jadn.com>.
On Wed, 2002-11-06 at 06:55, Tim Funk wrote:
> In case you weren't joking ...
> 
> It can easily break compatibility if someone introduces a new class with 
> the same class name as another class in a different package.


IMHO, the more important reason to not use "import xx.*" is because it
is harder for a developer to figure out where a class is coming from... 
So I see it as a code readability issue.

Cheers,
-bob

> 
> ex:
> import foo.*; /* has class A */
> import bar.*; /* has class B */
> 
> class Foo {
>      A a;
>      B b;
> }
> 
> Imagine time going by and another developer creates another class called 
> A in the bar package. The code above will not recompile because of the 
> abiguous class name.
> 
> -Tim
> 
> 
> Costin Manolache wrote:
> > BTW - what's evil in import * ? I never understood.
> > 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


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


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

Posted by Tim Funk <fu...@joedog.org>.
In case you weren't joking ...

It can easily break compatibility if someone introduces a new class with 
the same class name as another class in a different package.

ex:
import foo.*; /* has class A */
import bar.*; /* has class B */

class Foo {
     A a;
     B b;
}

Imagine time going by and another developer creates another class called 
A in the bar package. The code above will not recompile because of the 
abiguous class name.

-Tim


Costin Manolache wrote:
> BTW - what's evil in import * ? I never understood.
> 


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


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

Posted by Costin Manolache <cm...@yahoo.com>.
Remy Maucherat wrote:

> costin@apache.org wrote:
> 
>> costin      2002/11/05 13:35:00
>>
>>   Modified:    catalina/src/share/org/apache/catalina/core
>>                         StandardWrapper.java
>>   Log:
>>   Use commons-logging.
>>
>>   Add a short message for servlets that take a long time to load
>>   ( right now it's 200 ms - we can increase it, but no need to
>>   make it configurable, it's mostly do debug perf. ).
>>
>>   I used idea to edit the file - and it removed unused imports and
>>   forced me to fix some name mismatches... Probably should go back
>>   to emacs...
> 
> 
> Especially since it converted the imports to * imports (evil, evil).
> Please stop using it or disable the feature (and can you revert the
> changes on the imports ?).

I can revert the change - I just had it on my computer for a long
while, it's really not that important. I would like to slowly move
all the logging to c-l, but there is no urgency.

Regarding Idea - it warned me that about 10 imports
were not beeing used - and I let it 'fix' it. It seems it uses * if
more than 5 files in the same package are used.

Overall I'm really impressed with idea - I don't think I'll be able
to return to emacs. The code completion and runtime correction is
great, and the speed is decent. 

And with few fixes I was able to even run tomcat inside and debug
it... I still have 20 more days to evaluate it, but so far it seems
its worth the money. I'll just try once more with netbeans and eclipse.

BTW - what's evil in import * ? I never understood.

Costin



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


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

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message -----
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Wednesday, November 06, 2002 12:13 AM
Subject: Re: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core
StandardWrapper.java


> costin@apache.org wrote:
>
> > costin      2002/11/05 13:35:00
> >
> >   Modified:    catalina/src/share/org/apache/catalina/core
> >                         StandardWrapper.java
> >   Log:
> >   Use commons-logging.
> >
> >   Add a short message for servlets that take a long time to load
> >   ( right now it's 200 ms - we can increase it, but no need to
> >   make it configurable, it's mostly do debug perf. ).
> >
> >   I used idea to edit the file - and it removed unused imports and
> >   forced me to fix some name mismatches... Probably should go back
> >   to emacs...
>
>
> Especially since it converted the imports to * imports (evil, evil).
> Please stop using it or disable the feature (and can you revert the
> changes on the imports ?).

+1

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


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


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

Posted by Remy Maucherat <re...@apache.org>.
costin@apache.org wrote:

> costin      2002/11/05 13:35:00
>
>   Modified:    catalina/src/share/org/apache/catalina/core
>                         StandardWrapper.java
>   Log:
>   Use commons-logging.
>
>   Add a short message for servlets that take a long time to load
>   ( right now it's 200 ms - we can increase it, but no need to
>   make it configurable, it's mostly do debug perf. ).
>
>   I used idea to edit the file - and it removed unused imports and
>   forced me to fix some name mismatches... Probably should go back
>   to emacs...


Especially since it converted the imports to * imports (evil, evil). 
Please stop using it or disable the feature (and can you revert the 
changes on the imports ?).

Remy


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