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);
}
}
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);
}
}
}
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;
}
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"));
}
}
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
}
}
Aggregations