Package org.apache.jasper

Examples of org.apache.jasper.JspC


            classpathStr.append(System.getProperty("path.separator"));
        }

        Thread.currentThread().setContextClassLoader(ucl);

        JspC jspc = new JspC();
        jspc.setWebXmlFragment(webXmlFragment);
        jspc.setUriroot(webAppSourceDirectory);
        jspc.setPackage(packageRoot);
        jspc.setOutputDir(generatedClasses);
        jspc.setValidateXml(validateXml);
        jspc.setClassPath(classpathStr.toString());
        jspc.setCompile(true);
        jspc.setSmapSuppressed(suppressSmap);
        jspc.setSmapDumped(!suppressSmap);
        jspc.setJavaEncoding(javaEncoding);

        // JspC#setExtensions() does not exist, so
        // always set concrete list of files that will be processed.
        String jspFiles = getJspFiles(webAppSourceDirectory);
        System.err.println("Compiling "+jspFiles);
        System.err.println("Includes="+includes);
        System.err.println("Excludes="+excludes);
        jspc.setJspFiles(jspFiles);
        if (verbose)
        {
            getLog().info("Files selected to precompile: " + jspFiles);
        }
       

        try
        {
            jspc.setIgnoreJspFragmentErrors(ignoreJspFragmentErrors);
        }
        catch (NoSuchMethodError e)
        {
            getLog().debug("Tomcat Jasper does not support configuration option 'ignoreJspFragmentErrors': ignored");
        }

        try
        {
            if (schemaResourcePrefix != null)
                jspc.setSchemaResourcePrefix(schemaResourcePrefix);
        }
        catch (NoSuchMethodError e)
        {
            getLog().debug("Tomcat Jasper does not support configuration option 'schemaResourcePrefix': ignored");
        }
        if (verbose)
            jspc.setVerbose(99);
        else
            jspc.setVerbose(0);

        jspc.execute();

        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
View Full Code Here


            int indexOfPeriod = filename.indexOf(".");
            if (indexOfPeriod != -1) {
                filename = "dev" + StringUtils.randomString(4);
            }

            JspC jspc = new JspC();
            if (!jspFile.exists()) {
                return false;
            }
            try {
                jspc.setJspFiles(jspFile.getCanonicalPath());
            }
            catch (IOException e) {
                Log.error(e.getMessage(), e);
            }
            jspc.setOutputDir(compilationDir.getAbsolutePath());
            jspc.setClassName(filename);
            jspc.setCompile(true);

            jspc.setClassPath(getClasspathForPlugin(plugin));
            try {
                jspc.execute();

                try {
                    Object servletInstance = pluginManager.loadClass(plugin, "org.apache.jsp." +
                        relativeDir + filename).newInstance();
                    HttpServlet servlet = (HttpServlet)servletInstance;
View Full Code Here

  public static void main (String[] args) throws JasperException {
    if (args.length == 0) {
      System.out.println(Localizer.getMessage("jspc.usage"));
    } else {
      JspC jspc = new JspC() {
        @Override
        public String getCompilerClassName() {
            return LocalCompiler.class.getName();
        }
      };
      jspc.setArgs(args);
      jspc.setCompiler("extJavac");
      jspc.setAddWebXmlMappings(true);
      jspc.execute();
    }
  }
View Full Code Here

            classpathStr.append(System.getProperty("path.separator"));
        }

        Thread.currentThread().setContextClassLoader(ucl);

        JspC jspc = new JspC();
        jspc.setWebXmlFragment(webXmlFragment);
        jspc.setUriroot(webAppSourceDirectory);
        jspc.setPackage(packageRoot);
        jspc.setOutputDir(generatedClasses);
        jspc.setValidateXml(validateXml);
        jspc.setClassPath(classpathStr.toString());
        jspc.setCompile(true);
        jspc.setSmapSuppressed(suppressSmap);
        jspc.setSmapDumped(!suppressSmap);
        jspc.setJavaEncoding(javaEncoding);

        // JspC#setExtensions() does not exist, so
        // always set concrete list of files that will be processed.
        String jspFiles = getJspFiles(webAppSourceDirectory);
        System.err.println("Compiling "+jspFiles);
        System.err.println("Includes="+includes);
        System.err.println("Excludes="+excludes);
        jspc.setJspFiles(jspFiles);
        if (verbose)
        {
            getLog().info("Files selected to precompile: " + jspFiles);
        }
       

        try
        {
            jspc.setIgnoreJspFragmentErrors(ignoreJspFragmentErrors);
        }
        catch (NoSuchMethodError e)
        {
            getLog().debug("Tomcat Jasper does not support configuration option 'ignoreJspFragmentErrors': ignored");
        }

        try
        {
            if (schemaResourcePrefix != null)
                jspc.setSchemaResourcePrefix(schemaResourcePrefix);
        }
        catch (NoSuchMethodError e)
        {
            getLog().debug("Tomcat Jasper does not support configuration option 'schemaResourcePrefix': ignored");
        }
        if (verbose)
            jspc.setVerbose(99);
        else
            jspc.setVerbose(0);

        jspc.execute();

        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
View Full Code Here

 
  public static void compile(File inWebDir, File outWebDir,
                                   WebBundleDescriptor wbd, List classpathList)
            throws IASDeploymentException
  {
    JspC jspc = new JspC();

    if (classpathList != null)
    {
      String classpath = getClasspath(classpathList);
   
      if (classpath != null)
        jspc.setClassPath(classpath);
    }

                // START SJSAS 6311155
                String appName = wbd.getApplication().getName();
                String sysClassPath = ASClassLoaderUtil.getWebModuleClassPath(appName);
                jspc.setSystemClassPath(sysClassPath);
                // END SJSAS 6311155

    verify(inWebDir, outWebDir);

    configureJspc(jspc, wbd);
    jspc.setOutputDir(outWebDir.getAbsolutePath());
    jspc.setUriroot(inWebDir.getAbsolutePath());
    jspc.setCompile(true);
    logger.info(startMessage);

    try
    {
      jspc.execute();
    }
    catch (Exception je)
    {
      throw new IASDeploymentException("JSP Compilation Error: " + je, je);
    }
View Full Code Here

    protected List<JasperException> compile(WebBundleDescriptor descriptor) {
        String archiveUri = getAbstractArchiveUri(descriptor);
        File outDir=getVerifierContext().getOutDir();
        logger.log(Level.INFO, "Compiling JSPs in [ " +new File(archiveUri).getName()+ " ]");
        JspC jspc=new JspC();
        jspc.setUriroot(archiveUri);
        jspc.setCompile(true);
        jspc.setOutputDir(outDir.getAbsolutePath());
        jspc.setFailOnError(false);
        setClassPath(jspc);
        jspc.setSchemaResourcePrefix("/schemas/");
        jspc.setDtdResourcePrefix("/dtds/");
        if (logger.isLoggable(Level.FINEST))
            jspc.setVerbose(1);
        try {
            jspc.execute();
        } catch(JasperException je) {
            List<JasperException> errors = jspc.getJSPCompilationErrors();
            errors.add(je);
            return errors;
        }
        return jspc.getJSPCompilationErrors();
    }
View Full Code Here

    protected List<JasperException> compile(WebBundleDescriptor descriptor) {
        String archiveUri = getAbstractArchiveUri(descriptor);
        File outDir=getVerifierContext().getOutDir();
        logger.log(Level.INFO, "Compiling JSPs in [ " +new File(archiveUri).getName()+ " ]");
        JspC jspc=new JspC();
        jspc.setUriroot(new File(URI.create(archiveUri)).getAbsolutePath());
        jspc.setCompile(true);
        jspc.setOutputDir(outDir.getAbsolutePath());
        jspc.setFailOnError(false);
        setClassPath(jspc);
        jspc.setSchemaResourcePrefix("/schemas/");
        jspc.setDtdResourcePrefix("/dtds/");
        if (logger.isLoggable(Level.FINEST))
            jspc.setVerbose(1);
        try {
            jspc.execute();
        } catch(JasperException je) {
            List<JasperException> errors = jspc.getJSPCompilationErrors();
            errors.add(je);
            return errors;
        }
        return jspc.getJSPCompilationErrors();
    }
View Full Code Here

 
  public static void compile(File inWebDir, File outWebDir,
                               WebBundleDescriptor wbd, String classpath,
                               ServerContext serverContext)
            throws DeploymentException {
    JspC jspc = new JspC();

        if (classpath != null && classpath.length() >0) {
        jspc.setClassPath(classpath);
        }
       
        // START SJSAS 6311155
        String appName = wbd.getApplication().getName();

        // so far, this is not segragated per web bundle, all web-bundles will get the
        // same sysClassPath
        String sysClassPath = ASClassLoaderUtil.getModuleClassPath(
            serverContext.getDefaultServices(), appName, null);
        jspc.setSystemClassPath(sysClassPath);
        // END SJSAS 6311155

    verify(inWebDir, outWebDir);

    configureJspc(jspc, wbd);
    jspc.setOutputDir(outWebDir.getAbsolutePath());
    jspc.setUriroot(inWebDir.getAbsolutePath());
    jspc.setCompile(true);
    logger.log(Level.INFO, START_MESSAGE);

    try {
      jspc.execute();
    }
    catch (Exception je) {
      throw new DeploymentException("JSP Compilation Error: " + je, je);
    }
    finally {
View Full Code Here

    }

    Thread.currentThread().setContextClassLoader(webAppClassLoader);

    if (jspc == null)
      jspc = new JspC();

    jspc.setWebXmlFragment(webXmlFragment);
    jspc.setUriroot(webAppSourceDirectory);
    jspc.setOutputDir(generatedClasses);
    jspc.setClassPath(webAppClassPath.toString());
View Full Code Here

    instance._jspInit();
    return instance;
  }

  private File compileJsp(String forwardedUrl) throws JasperException {
    JspC jspC = new JspC();
    jspC.setUriroot(webContentPath);
    jspC.setJspFiles("." + forwardedUrl);
    jspC.setOutputDir("jsp-compilation");
    jspC.setCompile(true);
    jspC.execute();
    File compilationDir = new File("jsp-compilation");
    return compilationDir;
  }
View Full Code Here

TOP

Related Classes of org.apache.jasper.JspC

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.