org.apache.tomcat.JarScanner Java Examples
The following examples show how to use
org.apache.tomcat.JarScanner.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TldLocationsCache.java From tomcatsrc with Apache License 2.0 | 6 votes |
private synchronized void init() throws JasperException { if (initialized) return; try { tldScanWebXml(); tldScanResourcePaths(WEB_INF); JarScanner jarScanner = JarScannerFactory.getJarScanner(ctxt); jarScanner.scan(ctxt, Thread.currentThread().getContextClassLoader(), new TldJarScannerCallback(), noTldJars); initialized = true; } catch (Exception ex) { throw new JasperException(Localizer.getMessage( "jsp.error.internal.tldinit", ex.getMessage()), ex); } }
Example #2
Source File: ContextConfig.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Scan /WEB-INF/lib for JARs and for each one found add it and any * /META-INF/web-fragment.xml to the resulting Map. web-fragment.xml files * will be parsed before being added to the map. Every JAR will be added and * <code>null</code> will be used if no web-fragment.xml was found. Any JARs * known not contain fragments will be skipped. * * @return A map of JAR name to processed web fragment (if any) */ protected Map<String,WebXml> processJarsForWebFragments(WebXml application) { JarScanner jarScanner = context.getJarScanner(); boolean parseRequired = true; Set<String> absoluteOrder = application.getAbsoluteOrdering(); if (absoluteOrder != null && absoluteOrder.isEmpty() && !context.getXmlValidation()) { // Skip parsing when there is an empty absolute ordering and // validation is not enabled parseRequired = false; } FragmentJarScannerCallback callback = new FragmentJarScannerCallback(parseRequired); jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), callback, pluggabilityJarsToSkip); return callback.getFragments(); }
Example #3
Source File: TldLocationsCache.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private synchronized void init() throws JasperException { if (initialized) return; try { tldScanWebXml(); tldScanResourcePaths(WEB_INF); JarScanner jarScanner = JarScannerFactory.getJarScanner(ctxt); if (jarScanner != null) { jarScanner.scan(ctxt, Thread.currentThread().getContextClassLoader(), new TldJarScannerCallback(), noTldJars); } initialized = true; } catch (Exception ex) { throw new JasperException(Localizer.getMessage( "jsp.error.internal.tldinit", ex.getMessage()), ex); } }
Example #4
Source File: ContextConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Scan /WEB-INF/lib for JARs and for each one found add it and any * /META-INF/web-fragment.xml to the resulting Map. web-fragment.xml files * will be parsed before being added to the map. Every JAR will be added and * <code>null</code> will be used if no web-fragment.xml was found. Any JARs * known not contain fragments will be skipped. * * @return A map of JAR name to processed web fragment (if any) */ protected Map<String,WebXml> processJarsForWebFragments(WebXml application) { JarScanner jarScanner = context.getJarScanner(); boolean parseRequired = true; Set<String> absoluteOrder = application.getAbsoluteOrdering(); if (absoluteOrder != null && absoluteOrder.isEmpty() && !context.getXmlValidation()) { // Skip parsing when there is an empty absolute ordering and // validation is not enabled parseRequired = false; } FragmentJarScannerCallback callback = new FragmentJarScannerCallback(parseRequired); jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), callback, pluggabilityJarsToSkip); return callback.getFragments(); }
Example #5
Source File: TomcatHelper.java From tomee with Apache License 2.0 | 5 votes |
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 } }
Example #6
Source File: ContextConfig.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Scan /WEB-INF/lib for JARs and for each one found add it and any * /META-INF/web-fragment.xml to the resulting Map. web-fragment.xml files * will be parsed before being added to the map. Every JAR will be added and * <code>null</code> will be used if no web-fragment.xml was found. Any JARs * known not contain fragments will be skipped. * * @param application The main web.xml metadata * @param webXmlParser The parser to use to process the web.xml file * @return A map of JAR name to processed web fragment (if any) */ protected Map<String,WebXml> processJarsForWebFragments(WebXml application, WebXmlParser webXmlParser) { JarScanner jarScanner = context.getJarScanner(); boolean delegate = false; if (context instanceof StandardContext) { delegate = ((StandardContext) context).getDelegate(); } boolean parseRequired = true; Set<String> absoluteOrder = application.getAbsoluteOrdering(); if (absoluteOrder != null && absoluteOrder.isEmpty() && !context.getXmlValidation()) { // Skip parsing when there is an empty absolute ordering and // validation is not enabled parseRequired = false; } FragmentJarScannerCallback callback = new FragmentJarScannerCallback(webXmlParser, delegate, parseRequired); jarScanner.scan(JarScanType.PLUGGABILITY, context.getServletContext(), callback); if (!callback.isOk()) { ok = false; } return callback.getFragments(); }
Example #7
Source File: WebContextConfiguration.java From codenjoy with GNU General Public License v3.0 | 5 votes |
@Bean public ServletContextInitializer servletContextInitializer() { return context -> context.setAttribute( JarScanner.class.getName(), new StandardJarScanner() {{ setScanManifest(false); }} ); }
Example #8
Source File: SpringBootTomcatPlusIT.java From uavstack with Apache License 2.0 | 5 votes |
public void onDeployUAVApp(Object... args) { if(UAVServer.ServerVendor.SPRINGBOOT!=UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) { return; } Tomcat tomcat=(Tomcat) args[0]; String mofRoot=(String) args[1]; //add uavApp StandardContext context=new StandardContext(); context.setName("com.creditease.uav"); context.setPath("/com.creditease.uav"); context.setDocBase(mofRoot + "/com.creditease.uav"); context.addLifecycleListener(new Tomcat.FixContextListener()); tomcat.getHost().addChild(context); //add default servlet Wrapper servlet = context.createWrapper(); servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet"); servlet.setName("default"); context.addChild(servlet); servlet.setOverridable(true); context.addServletMapping("/", "default"); //init webapp classloader context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); context.setDelegate(true); //after tomcat8, skip jarscan Object obj=ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader()); if(obj!=null) { ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); context.setJarScanner((JarScanner) obj); } }
Example #9
Source File: TldScanner.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * 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")); } }
Example #10
Source File: TesterContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { // NO-OP }
Example #11
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #12
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { /* NO-OP */ }
Example #13
Source File: MeecrowaveContextConfig.java From openwebbeans-meecrowave with Apache License 2.0 | 4 votes |
@Override protected void webConfig() { if (context.getServletContext().getAttribute("meecrowave.configuration") == null) { // redeploy context.getServletContext().setAttribute("meecrowave.configuration", Meecrowave.Builder.class.isInstance(configuration) ? configuration : new Meecrowave.Builder(configuration)); context.addServletContainerInitializer(intializer, emptySet()); } if (!configuration.isTomcatScanning()) { super.webConfig(); return; } // eagerly start CDI to scan only once and not twice (tomcat+CDI) final ClassLoader loader = context.getLoader().getClassLoader(); // should already be started at that point final Thread thread = Thread.currentThread(); final ClassLoader old = thread.getContextClassLoader(); thread.setContextClassLoader(loader); try { final OWBTomcatWebScannerService scannerService = OWBTomcatWebScannerService.class.cast(WebBeansContext.getInstance().getScannerService()); scannerService.setFilter(ofNullable(context.getJarScanner()).map(JarScanner::getJarScanFilter).orElse(null), context.getServletContext()); scannerService.setDocBase(context.getDocBase()); scannerService.setShared(configuration.getSharedLibraries()); if (configuration.getWatcherBouncing() > 0) { // note that caching should be disabled with this config in most of the times watcher = new ReloadOnChangeController(context, configuration.getWatcherBouncing()); scannerService.setFileVisitor(f -> watcher.register(f)); } scannerService.scan(); finder = scannerService.getFinder(); finder.link(); final CdiArchive archive = CdiArchive.class.cast(finder.getArchive()); Stream.of(WebServlet.class, WebFilter.class, WebListener.class) .forEach(marker -> finder.findAnnotatedClasses(marker).stream() .filter(c -> !Modifier.isAbstract(c.getModifiers()) && Modifier.isPublic(c.getModifiers())) .forEach(webComponent -> webClasses.computeIfAbsent( archive.classesByUrl().entrySet().stream() .filter(e -> e.getValue().getClassNames().contains(webComponent.getName())) .findFirst().get().getKey(), k -> new HashSet<>()) .add(webComponent))); } finally { thread.setContextClassLoader(old); } try { super.webConfig(); } finally { webClasses.clear(); finder = null; } }
Example #14
Source File: TesterContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { // NO-OP }
Example #15
Source File: TesterContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #16
Source File: TldConfig.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Scan for and configure all tag library descriptors found in this * web application. * * This supports a Tomcat-specific extension to the TLD search * order defined in the JSP spec. It allows tag libraries packaged as JAR * files to be shared by web applications by simply dropping them in a * location that all web applications have access to (e.g., * <CATALINA_HOME>/lib). It also supports some of the weird and * wonderful arrangements present when Tomcat gets embedded. * * The set of shared JARs to be scanned for TLDs is narrowed down by * the <tt>noTldJars</tt> class variable, which contains the names of JARs * that are known not to contain any TLDs. */ @SuppressWarnings("deprecation") // Context.addApplicationListener(ApplicationListener) is deprecated. public void execute() { long t1=System.currentTimeMillis(); /* * Priority order of URIs required by spec is: * 1. J2EE platform taglibs - Tomcat doesn't provide these * 2. web.xml entries * 3. JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority) * 4. Additional entries from the container * * Keep processing order in sync with o.a.j.compiler.TldLocationsCache */ // Stage 2 - web.xml entries tldScanWebXml(); // Stage 3a - TLDs under WEB-INF (not lib or classes) tldScanResourcePaths(WEB_INF); // Stages 3b & 4 JarScanner jarScanner = context.getJarScanner(); TldJarScannerCallback tldCallBack = new TldJarScannerCallback(); jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), tldCallBack, noTldJars); if(tldCallBack.scanFoundNoTLDs()){ log.info(sm.getString("tldConfig.noTldSummary")); } // Now add all the listeners we found to the listeners for this context String list[] = getTldListeners(); if( log.isDebugEnabled() ) log.debug(sm.getString("tldConfig.addListeners", Integer.valueOf(list.length))); for( int i=0; i<list.length; i++ ) { context.addApplicationListener( new ApplicationListener(list[i], true)); } long t2=System.currentTimeMillis(); if( context instanceof StandardContext ) { ((StandardContext)context).setTldScanTime(t2-t1); } }
Example #17
Source File: FailedContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { /* NO-OP */ }
Example #18
Source File: FailedContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #19
Source File: TesterContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { // NO-OP }
Example #20
Source File: TesterContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #21
Source File: StandardContextSF.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * 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); } }
Example #22
Source File: TldConfig.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Scan for and configure all tag library descriptors found in this * web application. * * This supports a Tomcat-specific extension to the TLD search * order defined in the JSP spec. It allows tag libraries packaged as JAR * files to be shared by web applications by simply dropping them in a * location that all web applications have access to (e.g., * <CATALINA_HOME>/lib). It also supports some of the weird and * wonderful arrangements present when Tomcat gets embedded. * * The set of shared JARs to be scanned for TLDs is narrowed down by * the <tt>noTldJars</tt> class variable, which contains the names of JARs * that are known not to contain any TLDs. */ @SuppressWarnings("deprecation") // Context.addApplicationListener(ApplicationListener) is deprecated. public void execute() { long t1=System.currentTimeMillis(); /* * Priority order of URIs required by spec is: * 1. J2EE platform taglibs - Tomcat doesn't provide these * 2. web.xml entries * 3. JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority) * 4. Additional entries from the container * * Keep processing order in sync with o.a.j.compiler.TldLocationsCache */ // Stage 2 - web.xml entries tldScanWebXml(); // Stage 3a - TLDs under WEB-INF (not lib or classes) tldScanResourcePaths(WEB_INF); // Stages 3b & 4 JarScanner jarScanner = context.getJarScanner(); TldJarScannerCallback tldCallBack = new TldJarScannerCallback(); jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), tldCallBack, noTldJars); if(tldCallBack.scanFoundNoTLDs()){ log.info(sm.getString("tldConfig.noTldSummary")); } // Now add all the listeners we found to the listeners for this context String list[] = getTldListeners(); if( log.isDebugEnabled() ) log.debug(sm.getString("tldConfig.addListeners", Integer.valueOf(list.length))); for( int i=0; list!=null && i<list.length; i++ ) { context.addApplicationListener( new ApplicationListener(list[i], true)); } long t2=System.currentTimeMillis(); if( context instanceof StandardContext ) { ((StandardContext)context).setTldScanTime(t2-t1); } }
Example #23
Source File: FailedContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public void setJarScanner(JarScanner jarScanner) { /* NO-OP */ }
Example #24
Source File: FailedContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #25
Source File: TesterContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public JarScanner getJarScanner() { return null; }
Example #26
Source File: JarScannerSF.java From Tomcat8-Source-Read with MIT License | 3 votes |
/** * 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); } } }
Example #27
Source File: Context.java From Tomcat8-Source-Read with MIT License | 2 votes |
/** * Set the Jar Scanner to be used to scan for JAR resources for this * context. * @param jarScanner The Jar Scanner to be used for this context. */ public void setJarScanner(JarScanner jarScanner);
Example #28
Source File: Context.java From Tomcat7.0.67 with Apache License 2.0 | 2 votes |
/** * Set the Jar Scanner to be used to scan for JAR resources for this * context. * @param jarScanner The Jar Scanner to be used for this context. */ public void setJarScanner(JarScanner jarScanner);
Example #29
Source File: Context.java From tomcatsrc with Apache License 2.0 | 2 votes |
/** * Get the Jar Scanner to be used to scan for JAR resources for this * context. * @return The Jar Scanner configured for this context. */ public JarScanner getJarScanner();
Example #30
Source File: Context.java From tomcatsrc with Apache License 2.0 | 2 votes |
/** * Set the Jar Scanner to be used to scan for JAR resources for this * context. * @param jarScanner The Jar Scanner to be used for this context. */ public void setJarScanner(JarScanner jarScanner);