Package org.apache.tomcat.util.depend

Examples of org.apache.tomcat.util.depend.Dependency


      File warFile=dInfo.srcF;
      DependManager dm=(DependManager)context.getContainer().
    getNote("DependManager");
      if( dm!=null ) {
    log( "Adding dependency " + context + " -> " +  warFile );
    Dependency dep=new Dependency();
    dep.setTarget("web.xml");
    dep.setOrigin( warFile );
    dep.setLastModified( warFile.lastModified() );
    dm.addDependency( dep );
    context.getContainer().setNote( "autoDeploy.war", dInfo);

      } else {
    log( "No reloading for " + context + " -> " +  warFile );
View Full Code Here


      getNote("DependManager");

  File inf_xml = new File(context.getAbsolutePath() +
        "/WEB-INF/web.xml");
  if( inf_xml.exists() ) {
      Dependency dep=new Dependency();
      dep.setTarget("web.xml");
      dep.setOrigin( inf_xml );
      dep.setLastModified( inf_xml.lastModified() );
      dm.addDependency( dep );
  }

  // Use a DependClassLoader to autmatically record class loader
  // deps
View Full Code Here

  // Each .jsp file is compiled to a servlet, and will
  // have a dependency to check if it's expired
  // if the jspfile is older than the class - we're ok
        // this happens if the .jsp file was compiled in a previous
  // run of tomcat.
  Dependency dep= handler.getServletInfo().getDependency();
  if( (dep==null ||  dep.isExpired()) && do_compile ) {
      // we need to compile... ( or find previous .class )
      JasperLiaison liasion=new JasperLiaison(getLog(), debug,
                        useWebAppCL);
      liasion.processJspFile(req, jspFile, handler, args);
  }
View Full Code Here

  if( debug > 10 ) log.log( "Before compile sync  " + jspFile );
  synchronized( handler ) {
     
      // double check - maybe another thread did that for us
      Dependency dep= handler.getServletInfo().getDependency();
      if( dep!=null && ! dep.isExpired() ) {
    // if the jspfile is older than the class - we're ok
    return 0;
      }

      Context ctx=req.getContext();
     
      // Mangle the names - expensive operation, but nothing
      // compared with a compilation :-)
      JasperMangler mangler=
    new JasperMangler(ctx.getWorkDir().getAbsolutePath(),
             ctx.getAbsolutePath(),
             jspFile );


            // If unsafe path or JSP file doesn't exist, return "not found"
            // Avoids creating work directories for non-existent JSP files
            String path=mangler.getJspFilePath();
            if( path == null )
                return 404;
            File f = new File( path );
            if( !f.exists() )
                return 404;
      // register the handler as dependent on the jspfile
      if( dep==null ) {
    dep=setDependency( ctx, mangler, handler );
                // if dep is null then path is unsafe, return "not found"
                if( dep == null ) {
                    return 404;
                }
               
    // update the servlet class name
    handler.setServletClassName( mangler.getServletClassName() );

    // check again - maybe we just found a compiled class from
    // a previous run
    if( ! dep.isExpired() )
        return 0;
      }

      //      if( debug > 3)
      ctx.log( "Compiling: " + jspFile + " to " +
         mangler.getServletClassName());
     
      //XXX old servlet -  destroy();
     
      // jump version number - the file needs to be recompiled
      // reset the handler error, un-initialize the servlet
      handler.setErrorException( null );
      handler.setState( Handler.STATE_ADDED );
     
      // Move to the next class name
      mangler.nextVersion();

      // record time of attempted translate-and-compile
      // if the compilation fails, we'll not try again
      // until the jsp file changes
      dep.setLastModified( System.currentTimeMillis() );

      // Update the class name in wrapper
      if( debug> 1 )
    log.log( "Update class Name " + mangler.getServletClassName());
      handler.setServletClassName( mangler.getServletClassName() );

      // May be called from include, we need to set the context class
            // loader
      // for jaxp1.1 to work using the container class loader
            //Extra test/warnings for tools.jar

            ClassLoader savedContextCL= containerCCL( ctx.getContextManager()
                                                  .getContainerLoader() );

            if( useWebAppCL ) {
                try {
                    ctx.getClassLoader().loadClass( "sun.tools.javac.Main" );
                    if(debug>0) log.log( "Found javac using context loader");
                } catch( ClassNotFoundException ex ) {
                    if(debug>0) log.log( "javac not found using context loader");
                }

                try {
                    ctx.getContextManager().getContainerLoader().
                        loadClass( "sun.tools.javac.Main" );
                    if( debug > 0 )
                        log.log( "Found javac using container loader");
                } catch( ClassNotFoundException ex ) {
                    if( debug > 0 )
                        log.log( "javac not found using container loader");
                }
            }

      try {
    Options options=new JasperOptionsImpl(args);
    JspCompilationContext ctxt=createCompilationContext(req,
                    jspFile,
                    options,
                    mangler);
    jsp2java( mangler, ctxt );

    javac( req, options, ctxt, mangler );
     
    if(debug>0)log.log( "Generated " +
            mangler.getClassFileName() );
            } catch ( java.io.FileNotFoundException fnfex ){
    containerCCL( savedContextCL );
    return 404;
      } catch( Exception ex ) {
    if( ctx!=null )
        ctx.log("compile error: req="+req, ex);
    else
        log.log("compile error: req="+req, ex);
    handler.setErrorException(ex);
    handler.setState(Handler.STATE_DISABLED);
    // until the jsp cahnges, when it'll be enabled again
    containerCCL( savedContextCL );
    return 500;
      }

      containerCCL( savedContextCL );
     
      dep.setExpired( false );
     
  }

  return 0;
    }
View Full Code Here

              ServletHandler handler )
    {
  ServletInfo info=handler.getServletInfo();
  // create a lastModified checker.
  if( debug>0) log.log("Registering dependency for " + handler );
  Dependency dep=new Dependency();
        String jspFilePath = mangler.getJspFilePath();
        // if unsafe path, return null
        if( jspFilePath == null )
            return null;
        dep.setOrigin( new File(jspFilePath) );
  dep.setTarget( handler );
  dep.setLocal( true );
  File f=new File( mangler.getClassFileName() );
  if( mangler.getVersion() > 0 ) {
      // it has a previous version
      dep.setLastModified(f.lastModified());
      // update the "expired" variable
      dep.checkExpiry();
  } else {
      dep.setLastModified( -1 );
      dep.setExpired( true );
  }
  if( debug>0 )
      log.log( "file = " + mangler.getClassFileName() + " " +
         f.lastModified() );
  if( debug>0 )
      log.log("origin = " + dep.getOrigin() + " " +
        dep.getOrigin().lastModified());
  try {
      DependManager dm=(DependManager)ctx.getContainer().
    getNote("DependManager");
      if( dm!=null ) {
    dm.addDependency( dep );
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.depend.Dependency

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.