Package org.apache.jasper

Examples of org.apache.jasper.JspCompilationContext$Interface1


     * Compiles and loads a tagfile.
     */
    private Class loadTagFile(Compiler compiler, String tagFilePath,
            TagInfo tagInfo, PageInfo parentPageInfo) throws JasperException {

        JspCompilationContext ctxt = compiler.getCompilationContext();
        JspRuntimeContext rctxt = ctxt.getRuntimeContext();
        JspServletWrapper wrapper = (JspServletWrapper) rctxt
                .getWrapper(tagFilePath);

        synchronized (rctxt) {
            if (wrapper == null) {
                wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
                        .getOptions(), tagFilePath, tagInfo, ctxt
                        .getRuntimeContext(), ctxt.getTagFileJarUrl(tagFilePath));
                rctxt.addWrapper(tagFilePath, wrapper);

                // Use same classloader and classpath for compiling tag files
                wrapper.getJspEngineContext().setClassLoader(
                        (URLClassLoader) ctxt.getClassLoader());
                wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
            } else {
                // Make sure that JspCompilationContext gets the latest TagInfo
                // for the tag file. TagInfo instance was created the last
                // time the tag file was scanned for directives, and the tag
                // file may have been modified since then.
                wrapper.getJspEngineContext().setTagInfo(tagInfo);
            }

            Class tagClazz;
            int tripCount = wrapper.incTripCount();
            try {
                if (tripCount > 0) {
                    // When tripCount is greater than zero, a circular
                    // dependency exists. The circularily dependant tag
                    // file is compiled in prototype mode, to avoid infinite
                    // recursion.

                    JspServletWrapper tempWrapper = new JspServletWrapper(ctxt
                            .getServletContext(), ctxt.getOptions(),
                            tagFilePath, tagInfo, ctxt.getRuntimeContext(),
                            ctxt.getTagFileJarUrl(tagFilePath));
                    tagClazz = tempWrapper.loadTagFilePrototype();
                    tempVector.add(tempWrapper.getJspEngineContext()
                            .getCompiler());
                } else {
                    tagClazz = wrapper.loadTagFile();
View Full Code Here


        public void visit(Node.CustomTag n) throws JasperException {
            TagFileInfo tagFileInfo = n.getTagFileInfo();
            if (tagFileInfo != null) {
                String tagFilePath = tagFileInfo.getPath();
                JspCompilationContext ctxt = compiler.getCompilationContext();
                if (ctxt.getTagFileJarUrl(tagFilePath) == null) {
                    // Omit tag file dependency info on jar files for now.
                    pageInfo.addDependant(tagFilePath);
                }
                Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                        pageInfo);
View Full Code Here

  this.isTagFile = false;
        this.config = config;
        this.options = options;
        this.jspUri = jspUri;
        ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
           config.getServletContext(),
           this, rctxt);
    }
View Full Code Here

  this.isTagFile = true;
        this.config = null// not used
        this.options = options;
  this.jspUri = tagFilePath;
  this.tripCount = 0;
        ctxt = new JspCompilationContext(jspUri, tagInfo, options,
           servletContext, this, rctxt,
           tagFileJarUrl);
    }
View Full Code Here

        }
       
        Object [] wrappers = jsps.values().toArray();
        for (int i = 0; i < wrappers.length; i++ ) {
            JspServletWrapper jsw = (JspServletWrapper)wrappers[i];
            JspCompilationContext ctxt = jsw.getJspEngineContext();
            // JspServletWrapper also synchronizes on this when
            // it detects it has to do a reload
            synchronized(jsw) {
                try {
                    ctxt.compile();
                } catch (FileNotFoundException ex) {
                    ctxt.incrementRemoved();
                } catch (Throwable t) {
                    jsw.getServletContext().log("Background compile failed",
            t);
                }
            }
View Full Code Here

            wrapperUri = tagFilePath;
        } else {
            wrapperUri = tagJarResouce.getEntry(tagFilePath).toString();
        }

        JspCompilationContext ctxt = compiler.getCompilationContext();
        JspRuntimeContext rctxt = ctxt.getRuntimeContext();

        synchronized (rctxt) {
            JspServletWrapper wrapper = rctxt.getWrapper(wrapperUri);
            if (wrapper == null) {
                wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
                        .getOptions(), tagFilePath, tagInfo, ctxt
                        .getRuntimeContext(), tagJarResouce);
                rctxt.addWrapper(wrapperUri, wrapper);

                // Use same classloader and classpath for compiling tag files
                wrapper.getJspEngineContext().setClassLoader(
                        ctxt.getClassLoader());
                wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
            } else {
                // Make sure that JspCompilationContext gets the latest TagInfo
                // for the tag file. TagInfo instance was created the last
                // time the tag file was scanned for directives, and the tag
                // file may have been modified since then.
                wrapper.getJspEngineContext().setTagInfo(tagInfo);
            }

            Class<?> tagClazz;
            int tripCount = wrapper.incTripCount();
            try {
                if (tripCount > 0) {
                    // When tripCount is greater than zero, a circular
                    // dependency exists. The circularly dependent tag
                    // file is compiled in prototype mode, to avoid infinite
                    // recursion.

                    JspServletWrapper tempWrapper = new JspServletWrapper(ctxt
                            .getServletContext(), ctxt.getOptions(),
                            tagFilePath, tagInfo, ctxt.getRuntimeContext(),
                            ctxt.getTagFileJarResource(tagFilePath));
                    // Use same classloader and classpath for compiling tag files
                    tempWrapper.getJspEngineContext().setClassLoader(
                            ctxt.getClassLoader());
                    tempWrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
                    tagClazz = tempWrapper.loadTagFilePrototype();
                    tempVector.add(tempWrapper.getJspEngineContext()
                            .getCompiler());
                } else {
                    tagClazz = wrapper.loadTagFile();
View Full Code Here

    {
        JspServletWrapper jsw=(JspServletWrapper) jsps.get(jspUri);
        if( jsw==null ) {
            throw new JasperException("Can't happen - JspServletWrapper=null");
        }
        JspCompilationContext ctxt = new JspEngineContext(loader, classpath,
                                                          context, jspUri,
                                                          isErrorPage, options,
                                                          req, res);
        boolean outDated = false;

        Compiler compiler = null;
        synchronized(jsw){
            /*
             * Creating a compiler opens the associated .class file (if it exists)
             * and reads the actual class name.  If we allow a compiler to be
             * created while a compile is going on then bad things can happen.
             */
            compiler = ctxt.createCompiler();
        }

        try {


            outDated = compiler.isOutDated();
            if(!jsw.isInstantiated() || outDated ) {
                synchronized(jsw){
                    outDated = compiler.compile();
                    if(!jsw.isInstantiated() || outDated) {
                        if( null ==ctxt.getServletClassName() ) {
                            compiler.computeServletClassName();
                        }
                        jsw.instantiateServlet(loader.loadClass(ctxt.getFullClassName()));
                    }
                }
            }
        } catch(FileNotFoundException ex) {
            compiler.removeGeneratedFiles();
View Full Code Here

                }
            }

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

            throws JasperException {

        this.config = config;
        this.options = options;
        this.jspUri = jspUri;
        ctxt = new JspCompilationContext( jspUri, isErrorPage,
                                          options,
                                          config.getServletContext(),
                                          this, rctxt);
        ctxt.createOutdir();
    }
View Full Code Here

     */
    private void checkCompile() {
        Iterator it = jsps.values().iterator();
        while (it.hasNext()) {
            JspServletWrapper jsw = (JspServletWrapper)it.next();
            JspCompilationContext ctxt = jsw.getJspEngineContext();
            // JspServletWrapper also synchronizes on this when
            // it detects it has to do a reload
            synchronized(jsw) {
                try {
                    ctxt.compile();
                } catch (FileNotFoundException ex) {
                    ctxt.incrementRemoved();
                } catch (Throwable t) {
                    jsw.getServletContext().log("Background compile failed",t);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jasper.JspCompilationContext$Interface1

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.