private static void load(String className, StandardContext standardContext) { final ClassLoader classLoader = standardContext.getLoader().getClassLoader(); try { classLoader.loadClass(className); } catch (ClassNotFoundException e) { } catch (LinkageError e) { try { classLoader.loadClass(className); } catch (ClassNotFoundException e2) { } } }
@SuppressWarnings("unchecked") private Class<? extends Servlet> loadServletClass(String className) throws ClassNotFoundException { return (Class <? extends Servlet>) ctx.getLoader().getClassLoader().loadClass(className); } }
private static void load(final String className, final StandardContext standardContext) { final ClassLoader classLoader = standardContext.getLoader().getClassLoader(); try { classLoader.loadClass(className); } catch (final ClassNotFoundException e) { // no-op } catch (final LinkageError e) { try { classLoader.loadClass(className); } catch (final ClassNotFoundException e2) { // no-op } } }
/** * Gets the class loader of the web application represented by this * ServletContext. */ @Override public ClassLoader getClassLoader() { ClassLoader webappLoader = (getLoader() != null) ? getLoader().getClassLoader() : null; if (webappLoader == null) { return null; } if (mySecurityManager != null) { mySecurityManager.checkGetClassLoaderPermission(webappLoader); } return webappLoader; }
/** * Bind current thread, both for CL purposes and for JNDI ENC support * during : startup, shutdown and realoading of the context. * * @return the previous context class loader */ protected ClassLoader bindThread() { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); if ((getLoader() != null) && getLoader().getClassLoader() != null) { Thread.currentThread().setContextClassLoader (getLoader().getClassLoader()); } threadBindingListener.bind(); lifecycle.fireLifecycleEvent(BIND_THREAD_EVENT, null); return oldContextClassLoader; }
@Override public ClassLoader getClassLoader() { ClassLoader result = context.getLoader().getClassLoader(); if (Globals.IS_SECURITY_ENABLED) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); ClassLoader parent = result; while (parent != null) { if (parent == tccl) { break; } parent = parent.getParent(); } if (parent == null) { System.getSecurityManager().checkPermission( new RuntimePermission("getClassLoader")); } } return result; }
public ClassLoader getClassLoader() { if (restricted) { throw new UnsupportedOperationException(sm.getString("applicationContext.restricted")); } return context.getLoader().getClassLoader(); }
@Override public ClassLoader getClassLoader() { ClassLoader result = context.getLoader().getClassLoader(); if (Globals.IS_SECURITY_ENABLED) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); ClassLoader parent = result; while (parent != null) { if (parent == tccl) { break; } parent = parent.getParent(); } if (parent == null) { System.getSecurityManager().checkPermission( new RuntimePermission("getClassLoader")); } } return result; }
@Override public ClassLoader getClassLoader() { ClassLoader result = context.getLoader().getClassLoader(); if (Globals.IS_SECURITY_ENABLED) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); ClassLoader parent = result; while (parent != null) { if (parent == tccl) { break; } parent = parent.getParent(); } if (parent == null) { System.getSecurityManager().checkPermission( new RuntimePermission("getClassLoader")); } } return result; }
@Override public ClassLoader getClassLoader() { ClassLoader result = context.getLoader().getClassLoader(); if (Globals.IS_SECURITY_ENABLED) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); ClassLoader parent = result; while (parent != null) { if (parent == tccl) { break; } parent = parent.getParent(); } if (parent == null) { System.getSecurityManager().checkPermission( new RuntimePermission("getClassLoader")); } } return result; }
/** * Get resource from META-INF/resources/ in jars. */ private File getExtractedMetaInfResourcePath(String path) { path = Globals.META_INF_RESOURCES + path; ClassLoader cl = getLoader().getClassLoader(); if (cl instanceof WebappClassLoader) { return ((WebappClassLoader)cl).getExtractedResourcePath(path); } return null; } }
public ClassLoader getClassLoader() { if (restricted) { throw MESSAGES.restrictedListenerCannotCallMethod(); } return context.getLoader().getClassLoader(); }
private void setClassLoaderProperty(String name, boolean value) { ClassLoader cl = getLoader().getClassLoader(); if (!IntrospectionUtils.setProperty(cl, name, Boolean.toString(value))) { // Failed to set log.info(sm.getString( "standardContext.webappClassLoader.missingProperty", name, Boolean.toString(value))); } }
private void setClassLoaderProperty(String name, boolean value) { ClassLoader cl = getLoader().getClassLoader(); if (!IntrospectionUtils.setProperty(cl, name, Boolean.toString(value))) { // Failed to set log.info(sm.getString( "standardContext.webappClassLoader.missingProperty", name, Boolean.toString(value))); } }
private void setClassLoaderProperty(String name, boolean value) { ClassLoader cl = getLoader().getClassLoader(); if (!IntrospectionUtils.setProperty(cl, name, Boolean.toString(value))) { // Failed to set log.info(sm.getString( "standardContext.webappClassLoader.missingProperty", name, Boolean.toString(value))); } }
private void wrapInstanceManager(StandardContext context) { if (context.getInstanceManager() instanceof TomcatInstanceManager) { return; } InstanceManager processor = context.getInstanceManager(); InstanceManager custom = new TomcatInstanceManager(context.getLoader().getClassLoader(), processor); context.setInstanceManager(custom); context.getServletContext().setAttribute(InstanceManager.class.getName(), custom); }
private List<URL> getUrls(StandardContext standardContext) { List<URL> urls = null; try { ClassLoader classLoader = standardContext.getLoader().getClassLoader(); UrlSet urlSet = new UrlSet(classLoader); urlSet = urlSet.exclude(classLoader.getParent()); urls = urlSet.getUrls(); } catch (IOException e) { logger.warning("Unable to determine URLs in web application " + standardContext.getPath(), e); } return urls; }
@Override public void configureStart(StandardContext standardContext) { if (TomcatHelper.isTomcat7()) { TomcatHelper.configureJarScanner(standardContext); ContextTransaction contextTransaction = new ContextTransaction(); contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName()); standardContext.getNamingResources().setTransaction(contextTransaction); startInternal(standardContext); } // clear a bit log for default case addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext()); }
@Override public void configureStart(final LifecycleEvent event, final StandardContext standardContext) { final ContextTransaction contextTransaction = new ContextTransaction(); contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName()); standardContext.getNamingResources().setTransaction(contextTransaction); if (event != null) { // ensure NamingContext is available for eager usage (@Observes @Initialized(ApplicationScoped) for instance) standardContext.getNamingContextListener().lifecycleEvent(event); } TomcatHelper.configureJarScanner(standardContext); startInternal(standardContext); // clear a bit log for default case addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext()); // breaks cdi standardContext.setTldValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.tld.validation", "false"))); // breaks jstl standardContext.setXmlValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.xml.validation", "false"))); }