Refine search
File store = sessionStore(context.getPath()); if (store == null) { getLogger().debug("No session store file found"); return; if (getLogger().isDebugEnabled()) { getLogger().debug("Loading sessions from " + store.getAbsolutePath()); bis = new BufferedInputStream(fis); if (getTheContext() != null) { loader = getTheContext().getLoader(); classLoader = loader.getClassLoader();
/** * Attempt to load a class using the given Container's class loader. If the * class cannot be loaded, a debug level log message will be written to the * Container's log and null will be returned. * @param context The class loader of this context will be used to attempt * to load the class * @param className The class name * @return the loaded class or <code>null</code> if loading failed */ public static Class<?> loadClass(Context context, String className) { ClassLoader cl = context.getLoader().getClassLoader(); Log log = context.getLogger(); Class<?> clazz = null; try { clazz = cl.loadClass(className); } catch (ClassNotFoundException | NoClassDefFoundError | ClassFormatError e) { log.debug(sm.getString("introspection.classLoadFailed", className), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.debug(sm.getString("introspection.classLoadFailed", className), t); } return clazz; }
private StandardContext startWebApp(Host host) throws Exception { StandardContext context = new StandardContext(); try { context.setPath(contextRoot); context.addLifecycleListener(new ContextConfig()); File docBase = new File(serverTempDir, contextRoot); if (!docBase.exists()) { loader.setContainer(host); context.setLoader(loader); context.setInstanceManager(new LocalInstanceManager());
protected void processChildren(Container container, ClassLoader cl) { try { if (container.getLoader() != null) { Thread.currentThread().setContextClassLoader (container.getLoader().getClassLoader()); } container.backgroundProcess(); } catch (Throwable t) { log.log(Level.SEVERE, LogFacade.EXCEPTION_INVOKES_PERIODIC_OP, t); } finally { Thread.currentThread().setContextClassLoader(cl); } Container[] children = container.findChildren(); for (int i = 0; i < children.length; i++) { if (children[i].getBackgroundProcessorDelay() <= 0) { processChildren(children[i], cl); } } }
@Override public void backgroundProcess() { if (!getState().isAvailable()) return; Loader loader = getLoader(); if (loader != null) { try { loader.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString( "standardContext.backgroundProcess.loader", loader), e); Manager manager = getManager(); if (manager != null) { try { manager.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString( "standardContext.backgroundProcess.manager", manager), e); resources.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString( "standardContext.backgroundProcess.resources", resources), e);
/** * Create an <code>ObjectName</code> for this * <code>Loader</code> object. * * @param domain Domain in which this name is to be created * @param loader The Loader to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Loader loader) throws MalformedObjectNameException { ObjectName name = null; Container container = loader.getContainer(); if (container instanceof Engine) { name = new ObjectName(domain + ":type=Loader"); } else if (container instanceof Host) { name = new ObjectName(domain + ":type=Loader,host=" + container.getName()); } else if (container instanceof Context) { Context context = ((Context)container); ContextName cn = new ContextName(context.getName()); Container host = context.getParent(); name = new ObjectName(domain + ":type=Loader,context=" + cn.getDisplayName() + ",host=" + host.getName()); } return (name); }
@Override public void listContextJsps(Context context, Summary summary, boolean compile) { ServletConfig servletConfig = (ServletConfig) context.findChild("jsp"); if (servletConfig != null) { synchronized (servletConfig) { ServletContext sctx = context.getServletContext(); Options opt = new EmbeddedServletOptions(servletConfig, sctx); new URLClassLoader(new URL[0], context.getLoader().getClassLoader())) {
Loader loader = ctx.getLoader(); ClassLoader classLoader = loader.getClassLoader(); Log4J2WebLoggerContextUtilsAccessor webLoggerContextUtilsAccessor = new Log4J2WebLoggerContextUtilsAccessor(classLoader); Log4J2LoggerContextAccessor loggerContextAccessor = webLoggerContextUtilsAccessor.getWebLoggerContext(ctx.getServletContext()); List<Object> loggerContexts = getLoggerContexts(classLoader); Object loggerConfig = null;
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))); } }
cluster.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.cluster", cluster), e); loader.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.loader", loader), e); manager.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.manager", manager), e);
@Override public ClassLoader getContainerClassLoader() { return getContainer().getLoader().getClassLoader(); }
ClassLoader cl = ctx.getLoader().getClassLoader(); Object contextLogger = ctx.getLogger(); if (contextLogger != null) { if (contextLogger.getClass().getName().startsWith("org.apache.commons.logging")) { ServletContext servletContext = ctx.getServletContext(); try { Log4J2LoggerContextAccessor loggerContextAccessor = null;
@SuppressWarnings("unchecked") private Class<? extends Servlet> loadServletClass(String className) throws ClassNotFoundException { return (Class <? extends Servlet>) ctx.getLoader().getClassLoader().loadClass(className); } }
TC7WebAppContext(Context context) throws Exception { super(context.getServletContext(), context.getLoader().getClassLoader(), context.getPath()); this.context = context; }
/** * Attempt to load a class using the given Container's class loader. If the * class cannot be loaded, a debug level log message will be written to the * Container's log and null will be returned. */ public static Class<?> loadClass(Container container, String className) { ClassLoader cl = container.getLoader().getClassLoader(); Log log = container.getLogger(); Class<?> clazz = null; try { clazz = cl.loadClass(className); } catch (ClassNotFoundException e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (NoClassDefFoundError e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (ClassFormatError e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.debug(sm.getString("introspection.classLoadFailed"), t); } return clazz; }
} catch (Exception e) { logger.error("can't parse context xml for webapp " + webApp.path, e); standardContext = new StandardContext(); } finally { CONTEXT_DIGESTER.reset(); standardContext = new StandardContext(); if (standardContext.getPath() != null) { webApp.contextRoot = standardContext.getPath(); standardContext.setDelegate(true); standardContext.setLoader(new TomEEWebappLoader(appInfo.path, classLoader)); standardContext.getLoader().setDelegate(true);
private static StandardContext startWebApp(Host host, WSEndpointDeploymentUnit unit) throws Exception { StandardContext context = new StandardContext(); try { JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY); context.setPath(jbwebMD.getContextRoot()); context.addLifecycleListener(new ContextConfig()); ServerConfigService config = (ServerConfigService)unit.getServiceRegistry().getService(WSServices.CONFIG_SERVICE).getService(); File docBase = new File(config.getValue().getServerTempDir(), jbwebMD.getContextRoot()); if (!docBase.exists()) { docBase.mkdirs(); } context.setDocBase(docBase.getPath()); final Loader loader = new WebCtxLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY)); loader.setContainer(host); context.setLoader(loader); context.setInstanceManager(new LocalInstanceManager()); addServlets(jbwebMD, context); host.addChild(context); context.create(); } catch (Exception e) { throw MESSAGES.createContextPhaseFailed(e); } try { context.start(); } catch (LifecycleException e) { throw MESSAGES.startContextPhaseFailed(e); } return context; }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { Context context = request.getContext(); if (context == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, sm.getString("standardHost.noContext")); return; } Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader()); boolean processed = false; try { if (ignorePattern == null || !ignorePattern.matcher(request.getRequestURI()).matches()) { processed = true; if (log.isTraceEnabled()) { log.trace("Will save to redis after request for [" + getQueryString(request) + "]"); } } else { if (log.isTraceEnabled()) { log.trace("Ignoring [" + getQueryString(request) + "]"); } } getNext().invoke(request, response); } finally { manager.afterRequest(processed); } }
@Override public ClassLoader getContainerClassLoader() { return getContext().getLoader().getClassLoader(); }
((Lifecycle) oldLoader).stop(); } catch (LifecycleException e) { log.error("ContainerBase.setLoader: stop: ", e); loader.setContainer(this); if (getState().isAvailable() && (loader != null) && (loader instanceof Lifecycle)) { ((Lifecycle) loader).start(); } catch (LifecycleException e) { log.error("ContainerBase.setLoader: start: ", e);