Search in sources :

Example 1 with JarScanner

use of org.apache.tomcat.JarScanner in project tomcat by apache.

the class StandardContextSF method storeChildren.

/**
     * Store the specified context element children.
     *
     * @param aWriter Current output writer
     * @param indent Indentation level
     * @param aContext Context to store
     * @param parentDesc The element description
     * @throws Exception Configuration storing error
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aContext, StoreDescription parentDesc) throws Exception {
    if (aContext instanceof StandardContext) {
        StandardContext context = (StandardContext) aContext;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = context.findLifecycleListeners();
        ArrayList<LifecycleListener> listenersArray = new ArrayList<>();
        for (LifecycleListener listener : listeners) {
            if (!(listener instanceof ThreadLocalLeakPreventionListener)) {
                listenersArray.add(listener);
            }
        }
        storeElementArray(aWriter, indent, listenersArray.toArray());
        // Store nested <Valve> elements
        Valve[] valves = context.getPipeline().getValves();
        storeElementArray(aWriter, indent, valves);
        // Store nested <Loader> elements
        Loader loader = context.getLoader();
        storeElement(aWriter, indent, loader);
        // Store nested <Manager> elements
        if (context.getCluster() == null || !context.getDistributable()) {
            Manager manager = context.getManager();
            storeElement(aWriter, indent, manager);
        }
        // Store nested <Realm> element
        Realm realm = context.getRealm();
        if (realm != null) {
            Realm parentRealm = null;
            // @TODO is this case possible?
            if (context.getParent() != null) {
                parentRealm = context.getParent().getRealm();
            }
            if (realm != parentRealm) {
                storeElement(aWriter, indent, realm);
            }
        }
        // Store nested resources
        WebResourceRoot resources = context.getResources();
        storeElement(aWriter, indent, resources);
        // Store nested <WrapperListener> elements
        String[] wLifecycles = context.findWrapperLifecycles();
        getStoreAppender().printTagArray(aWriter, "WrapperListener", indent + 2, wLifecycles);
        // Store nested <WrapperLifecycle> elements
        String[] wListeners = context.findWrapperListeners();
        getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", indent + 2, wListeners);
        // Store nested <Parameter> elements
        ApplicationParameter[] appParams = context.findApplicationParameters();
        storeElementArray(aWriter, indent, appParams);
        // Store nested naming resources elements (EJB,Resource,...)
        NamingResourcesImpl nresources = context.getNamingResources();
        storeElement(aWriter, indent, nresources);
        // Store nested watched resources <WatchedResource>
        String[] wresources = context.findWatchedResources();
        wresources = filterWatchedResources(context, wresources);
        getStoreAppender().printTagArray(aWriter, "WatchedResource", indent + 2, wresources);
        // Store nested <JarScanner> elements
        JarScanner jarScanner = context.getJarScanner();
        storeElement(aWriter, indent, jarScanner);
        // Store nested <CookieProcessor> elements
        CookieProcessor cookieProcessor = context.getCookieProcessor();
        storeElement(aWriter, indent, cookieProcessor);
    }
}
Also used : ApplicationParameter(org.apache.tomcat.util.descriptor.web.ApplicationParameter) ArrayList(java.util.ArrayList) Loader(org.apache.catalina.Loader) LifecycleListener(org.apache.catalina.LifecycleListener) Manager(org.apache.catalina.Manager) JarScanner(org.apache.tomcat.JarScanner) ThreadLocalLeakPreventionListener(org.apache.catalina.core.ThreadLocalLeakPreventionListener) CookieProcessor(org.apache.tomcat.util.http.CookieProcessor) StandardContext(org.apache.catalina.core.StandardContext) Valve(org.apache.catalina.Valve) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) Realm(org.apache.catalina.Realm) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 2 with JarScanner

use of org.apache.tomcat.JarScanner in project tomcat by apache.

the class JarScannerSF method storeChildren.

/**
     * Store the specified JarScanner properties and children
     * (JarScannerFilter)
     *
     * @param aWriter
     *            PrintWriter to which we are storing
     * @param indent
     *            Number of spaces to indent this element
     * @param aJarScanner
     *            JarScanner whose properties are being stored
     *
     * @exception Exception
     *                if an exception occurs while storing
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aJarScanner, StoreDescription parentDesc) throws Exception {
    if (aJarScanner instanceof JarScanner) {
        JarScanner jarScanner = (JarScanner) aJarScanner;
        // Store nested <JarScanFilter> element
        JarScanFilter jarScanFilter = jarScanner.getJarScanFilter();
        if (jarScanFilter != null) {
            storeElement(aWriter, indent, jarScanFilter);
        }
    }
}
Also used : JarScanFilter(org.apache.tomcat.JarScanFilter) JarScanner(org.apache.tomcat.JarScanner)

Example 3 with JarScanner

use of org.apache.tomcat.JarScanner in project tomcat by apache.

the class JarScannerFactory method getJarScanner.

/**
     * Obtain the {@link JarScanner} associated with the specified {@link
     * ServletContext}. It is obtained via a context parameter.
     * @param ctxt The Servlet context
     * @return a scanner instance
     */
public static JarScanner getJarScanner(ServletContext ctxt) {
    JarScanner jarScanner = (JarScanner) ctxt.getAttribute(JarScanner.class.getName());
    if (jarScanner == null) {
        ctxt.log(Localizer.getMessage("jsp.warning.noJarScanner"));
        jarScanner = new StandardJarScanner();
    }
    return jarScanner;
}
Also used : StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) JarScanner(org.apache.tomcat.JarScanner)

Example 4 with JarScanner

use of org.apache.tomcat.JarScanner in project tomcat by apache.

the class TldScanner method scanJars.

/**
     * Scan for TLDs in JARs in /WEB-INF/lib.
     */
public void scanJars() {
    JarScanner scanner = JarScannerFactory.getJarScanner(context);
    TldScannerCallback callback = new TldScannerCallback();
    scanner.scan(JarScanType.TLD, context, callback);
    if (callback.scanFoundNoTLDs()) {
        log.info(Localizer.getMessage("jsp.tldCache.noTldSummary"));
    }
}
Also used : JarScanner(org.apache.tomcat.JarScanner)

Example 5 with JarScanner

use of org.apache.tomcat.JarScanner in project tomee by apache.

the class TomcatHelper method configureJarScanner.

public static void configureJarScanner(final Context standardContext) {
    try {
        // override only if default
        final JarScanner originalJarScanner = standardContext.getJarScanner();
        if ("true".equalsIgnoreCase(SystemInstance.get().getProperty("tomee.tomcat.override.jar-scanner", "true")) && !TomEEJarScanner.class.isInstance(originalJarScanner) && StandardJarScanner.class.isInstance(originalJarScanner)) {
            final TomEEJarScanner jarScanner = new TomEEJarScanner();
            final Properties properties = SystemInstance.get().getProperties();
            final String scanClasspath = properties.getProperty(TomEEJarScanner.class.getName() + ".scanClassPath");
            if (scanClasspath != null) {
                jarScanner.setScanClassPath(Boolean.parseBoolean(scanClasspath));
            }
            final String scanBootstrap = properties.getProperty(TomEEJarScanner.class.getName() + ".scanBootstrapClassPath");
            if (scanBootstrap != null) {
                jarScanner.setScanBootstrapClassPath(Boolean.parseBoolean(scanBootstrap));
            }
            final JarScanFilter jarScanFilter = originalJarScanner.getJarScanFilter();
            if (jarScanFilter != null && Boolean.parseBoolean(properties.getProperty(TomEEJarScanner.class.getName() + ".useOriginalJarScannerFilter", "true"))) {
                jarScanner.setJarScanFilter(jarScanFilter);
            }
            standardContext.setJarScanner(jarScanner);
        }
    } catch (final Exception e) {
    // ignore
    }
}
Also used : StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) JarScanFilter(org.apache.tomcat.JarScanFilter) Properties(java.util.Properties) JarScanner(org.apache.tomcat.JarScanner) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner)

Aggregations

JarScanner (org.apache.tomcat.JarScanner)6 StandardContext (org.apache.catalina.core.StandardContext)2 JarScanFilter (org.apache.tomcat.JarScanFilter)2 StandardJarScanner (org.apache.tomcat.util.scan.StandardJarScanner)2 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Loader (org.apache.catalina.Loader)1 Manager (org.apache.catalina.Manager)1 Realm (org.apache.catalina.Realm)1 Valve (org.apache.catalina.Valve)1 WebResourceRoot (org.apache.catalina.WebResourceRoot)1 ThreadLocalLeakPreventionListener (org.apache.catalina.core.ThreadLocalLeakPreventionListener)1 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)1 ApplicationParameter (org.apache.tomcat.util.descriptor.web.ApplicationParameter)1 FragmentJarScannerCallback (org.apache.tomcat.util.descriptor.web.FragmentJarScannerCallback)1 CookieProcessor (org.apache.tomcat.util.http.CookieProcessor)1