Search in sources :

Example 1 with StandardJarScanFilter

use of org.apache.tomcat.util.scan.StandardJarScanFilter in project tomcat by apache.

the class TomcatBaseTest method getTomcatInstanceTestWebapp.

/**
     * Make the Tomcat instance preconfigured with test/webapp available to
     * sub-classes.
     * @param addJstl Should JSTL support be added to the test webapp
     * @param start   Should the Tomcat instance be started
     *
     * @return A Tomcat instance pre-configured with the web application located
     *         at test/webapp
     *
     * @throws LifecycleException If a problem occurs while starting the
     *                            instance
     */
public Tomcat getTomcatInstanceTestWebapp(boolean addJstl, boolean start) throws LifecycleException {
    File appDir = new File("test/webapp");
    Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
    StandardJarScanner scanner = (StandardJarScanner) ctx.getJarScanner();
    StandardJarScanFilter filter = (StandardJarScanFilter) scanner.getJarScanFilter();
    filter.setTldSkip(filter.getTldSkip() + ",testclasses");
    filter.setPluggabilitySkip(filter.getPluggabilitySkip() + ",testclasses");
    if (addJstl) {
        File lib = new File("webapps/examples/WEB-INF/lib");
        ctx.setResources(new StandardRoot(ctx));
        ctx.getResources().createWebResourceSet(WebResourceRoot.ResourceSetType.POST, "/WEB-INF/lib", lib.getAbsolutePath(), null, "/");
    }
    if (start) {
        tomcat.start();
    }
    return tomcat;
}
Also used : Context(org.apache.catalina.Context) ServletContext(javax.servlet.ServletContext) StandardRoot(org.apache.catalina.webresources.StandardRoot) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) File(java.io.File) StandardJarScanFilter(org.apache.tomcat.util.scan.StandardJarScanFilter)

Example 2 with StandardJarScanFilter

use of org.apache.tomcat.util.scan.StandardJarScanFilter in project tomcat by apache.

the class JspCServletContext method scanForFragments.

private Map<String, WebXml> scanForFragments(WebXmlParser webXmlParser) throws JasperException {
    StandardJarScanner scanner = new StandardJarScanner();
    // TODO - enabling this means initializing the classloader first in JspC
    scanner.setScanClassPath(false);
    // TODO - configure filter rules from Ant rather then system properties
    scanner.setJarScanFilter(new StandardJarScanFilter());
    FragmentJarScannerCallback callback = new FragmentJarScannerCallback(webXmlParser, false, true);
    scanner.scan(JarScanType.PLUGGABILITY, this, callback);
    if (!callback.isOk()) {
        throw new JasperException(Localizer.getMessage("jspc.error.invalidFragment"));
    }
    return callback.getFragments();
}
Also used : JasperException(org.apache.jasper.JasperException) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) FragmentJarScannerCallback(org.apache.tomcat.util.descriptor.web.FragmentJarScannerCallback) StandardJarScanFilter(org.apache.tomcat.util.scan.StandardJarScanFilter)

Example 3 with StandardJarScanFilter

use of org.apache.tomcat.util.scan.StandardJarScanFilter in project tomcat by apache.

the class TomcatBaseTest method skipTldsForResourceJars.

public static void skipTldsForResourceJars(Context context) {
    StandardJarScanner scanner = (StandardJarScanner) context.getJarScanner();
    StandardJarScanFilter filter = (StandardJarScanFilter) scanner.getJarScanFilter();
    filter.setTldSkip(filter.getTldSkip() + ",resources*.jar");
}
Also used : StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) StandardJarScanFilter(org.apache.tomcat.util.scan.StandardJarScanFilter)

Aggregations

StandardJarScanFilter (org.apache.tomcat.util.scan.StandardJarScanFilter)3 StandardJarScanner (org.apache.tomcat.util.scan.StandardJarScanner)3 File (java.io.File)1 ServletContext (javax.servlet.ServletContext)1 Context (org.apache.catalina.Context)1 StandardRoot (org.apache.catalina.webresources.StandardRoot)1 JasperException (org.apache.jasper.JasperException)1 FragmentJarScannerCallback (org.apache.tomcat.util.descriptor.web.FragmentJarScannerCallback)1