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-jasper/jasper2/src/share/org/apache/jasper/compiler Compiler.java
Date Tue, 20 Aug 2002 19:35:25 GMT
costin      2002/08/20 12:35:25

  Modified:    jasper2/src/share/org/apache/jasper/compiler Compiler.java
  Log:
  Switch to commons-logging instead of jasper's own logging.
  
  To enable debugging - use log4j.properties or the jdk1.4 config.
  Right now it uses the 'class name' convention - i.e. the name of
  the logger where you can enable debug is the class name.
  
  We could use a single logger for all jasper.
  
  I also added code to log the translation and compilation times -
  if they are more than 500ms. It can be removed before release ( or
  made configurable ), but for now it's good to know.
  
  Revision  Changes    Path
  1.29      +37 -12    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Compiler.java	20 Aug 2002 03:52:18 -0000	1.28
  +++ Compiler.java	20 Aug 2002 19:35:24 -0000	1.29
  @@ -1,7 +1,4 @@
   /*
  - * $Header$
  - * $Revision$
  - * $Date$
    *
    * ====================================================================
    * 
  @@ -98,7 +95,8 @@
    * @author Mark Roth
    */
   public class Compiler {
  -
  +    private static org.apache.commons.logging.Log log=
  +        org.apache.commons.logging.LogFactory.getLog( Compiler.class );
   
       // ----------------------------------------------------------------- Static
   
  @@ -158,10 +156,14 @@
           } else {
               bl.setMessageOutputLevel( Project.MSG_INFO );
           }
  +        if( log.isTraceEnabled() ) {
  +            bl.setMessageOutputLevel( Project.MSG_VERBOSE );
  +        }
           project.addBuildListener( bl );
           
           if( options.getCompiler() != null ) {
  -            Constants.jasperLog.log("Compiler " + options.getCompiler(), Logger.ERROR );
  +            if( log.isDebugEnabled() )
  +                log.debug("Compiler " + options.getCompiler() );
               project.setProperty("build.compiler", options.getCompiler() );
           }
           project.init();
  @@ -175,12 +177,13 @@
       }
   
       static class JasperAntLogger extends DefaultLogger {
  +        private static org.apache.commons.logging.Log log=
  +            org.apache.commons.logging.LogFactory.getLog( Compiler.class );
           protected void printMessage(final String message,
                                       final PrintStream stream,
                                       final int priority) {
  -            Constants.jasperLog.log( message, Logger.INFORMATION );
  +            log.info( message );
           }
  -
       }
   
       // --------------------------------------------------------- Public Methods
  @@ -192,6 +195,7 @@
       public void generateJava()
           throws FileNotFoundException, JasperException, Exception
       {
  +        long t1=System.currentTimeMillis();
   	// Setup page info area
   	pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader()));
   	JspConfig jspConfig = options.getJspConfig();
  @@ -255,6 +259,7 @@
   	// Validate and process attributes
   	Validator.validate(this, pageNodes);
   
  +        long t2=System.currentTimeMillis();
   	// Dump out the page (for debugging)
   	// Dumper.dump(pageNodes);
   
  @@ -265,6 +270,8 @@
   	// this compilation unit.
   	TagFileProcessor.loadTagFiles(this, pageNodes);
   
  +        long t3=System.currentTimeMillis();
  +        
   	// Determine which custom tag needs to declare which scripting vars
   	ScriptingVariabler.set(pageNodes);
   
  @@ -272,6 +279,12 @@
   	Generator.generate(writer, this, pageNodes);
           writer.close();
   
  +        long t4=System.currentTimeMillis();
  +        if( t4-t1 > 500 ) {
  +            log.info("Generated "+ javaFileName + " total=" +
  +                     (t4-t1) + " generate=" + ( t4-t3 ) + " validate=" + ( t2-t1 ));
  +        }
  +        
           //JSR45 Support - note this needs to be checked by a JSR45 guru
   	SmapUtil.generateSmap(ctxt, pageNodes, true);
       }
  @@ -282,6 +295,7 @@
       public void generateClass()
           throws FileNotFoundException, JasperException, Exception
       {
  +        long t1=System.currentTimeMillis();
   	String javaEncoding = "UTF8"; 
           String javaFileName = ctxt.getServletJavaFileName();
           String classpath = ctxt.getClassPath(); 
  @@ -303,6 +317,10 @@
           path.setPath(System.getProperty("java.class.path") + sep
                        + classpath);
   
  +        if( log.isDebugEnabled() )
  +            log.debug( "Using classpath: " + System.getProperty("java.class.path") + sep
  +                       + classpath);
  +        
           // Initializing sourcepath
           Path srcPath = new Path(project);
           srcPath.setPath(options.getScratchDir().getAbsolutePath());
  @@ -328,8 +346,7 @@
                   javac.execute();
               }
           } catch (BuildException e) {
  -            //   System.out.println("Javac execption ");
  -            //   e.printStackTrace(System.out);
  +            log.error( "Javac execption ", e);
               success = false;
           }
   
  @@ -342,12 +359,15 @@
           }
   
           if (!success) {
  -            Constants.jasperLog.log( "Error compiling file: " + javaFileName + " " + errorReport,
  -                                     Logger.ERROR);
  +            log.error( "Error compiling file: " + javaFileName + " " + errorReport);
               if(errorReport!=null ) 
                   errDispatcher.javacError(errorReport, javaFileName, pageNodes);
           }
   
  +        long t2=System.currentTimeMillis();
  +        if( t2-t1 > 500 ) {
  +            log.info( "Compiled " + javaFileName + " " + (t2-t1));
  +        }
           //JSR45 Support - note this needs to be checked by a JSR45 guru
   	SmapUtil.installSmap(ctxt);
       }
  @@ -408,7 +428,8 @@
           }
           targetLastModified = targetFile.lastModified();
           if (targetLastModified < jspRealLastModified) {
  -            //System.out.println("Compiler: outdated, " + targetFile + " " + targetLastModified
);
  +            if( log.isDebugEnabled() )
  +                log.debug("Compiler: outdated: " + targetFile + " " + targetLastModified
);
               return true;
           }
   
  @@ -495,6 +516,8 @@
               String classFileName = ctxt.getServletClassName();
               if (classFileName != null) {
                   File classFile = new File(classFileName);
  +                if( log.isDebugEnabled() )
  +                    log.debug( "Deleting " + classFile );
                   classFile.delete();
               }
           } catch (Exception e) {
  @@ -504,6 +527,8 @@
               String javaFileName = ctxt.getServletJavaFileName();
               if (javaFileName != null) {
                   File javaFile = new File(javaFileName);
  +                if( log.isDebugEnabled() )
  +                    log.debug( "Deleting " + javaFile );
                   javaFile.delete();
               }
           } catch (Exception e) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message