Package org.apache.catalina

Examples of org.apache.catalina.Context


        }
        return null;
    }

    public LogDestination getLogDestination(String logType, String webapp, boolean context, boolean root, String logName, String logIndex) {
        Context ctx = null;
        Application application = null;
        if (webapp != null) {
            ctx = getContainerWrapper().getTomcatContainer().findContext(webapp);
            if (ctx != null) {
                application = ApplicationUtils.getApplication(ctx);
            }
        }

        if ("stdout".equals(logType) && logName != null) {
            return getStdoutLogDestination(logName);
        } else if ("catalina".equals(logType) && ctx != null) {
            return getCatalinaLogDestination(ctx, application);
        } else if (logIndex != null
                && ("jdk".equals(logType)
                || "log4j".equals(logType)
                || "logback".equals(logType))) {
            if (context && ctx != null) {
                return getCommonsLogDestination(ctx, application, logIndex);
            }
            ClassLoader cl;
            ClassLoader prevCl = null;
            if (ctx != null) {
                cl = ctx.getLoader().getClassLoader();
                prevCl = ClassUtils.overrideThreadContextClassLoader(cl);
            } else {
                cl = Thread.currentThread().getContextClassLoader().getParent();
            }
            try {
View Full Code Here


    }

    private void interrogateApplicationClassLoaders(List contexts, List allAppenders) {
        for (int i = 0; i < contexts.size(); i++) {

            Context ctx = (Context) contexts.get(i);
            Application application = ApplicationUtils.getApplication(ctx);

            ClassLoader cl = ctx.getLoader().getClassLoader();

            try {
                Object contextLogger = getContainerWrapper().getTomcatContainer().getLogger(ctx);
                if (contextLogger != null) {
                    if (contextLogger.getClass().getName().startsWith("org.apache.commons.logging")) {
                        CommonsLoggerAccessor commonsAccessor = new CommonsLoggerAccessor();
                        commonsAccessor.setTarget(contextLogger);
                        commonsAccessor.setApplication(application);
                        allAppenders.addAll(commonsAccessor.getDestinations());
                    } else if (contextLogger.getClass().getName().startsWith("org.apache.catalina.logger")) {
                        CatalinaLoggerAccessor catalinaAccessor = new CatalinaLoggerAccessor();
                        catalinaAccessor.setApplication(application);
                        catalinaAccessor.setTarget(contextLogger);
                        allAppenders.add(catalinaAccessor);
                    }
                }
            } catch (Throwable e) {
                logger.error("Could not interrogate context logger for " + ctx.getName() + ". Enable debug logging to see the trace stack");
                logger.debug(e);
                //
                // make sure we always re-throw ThreadDeath
                //
                if (e instanceof ThreadDeath) {
                    throw (ThreadDeath) e;
                }
            }

            if (application.isAvailable()) {
                ClassLoader prevCl = ClassUtils.overrideThreadContextClassLoader(cl);
                try {
                    interrogateClassLoader(cl, application, allAppenders);
                } catch (Exception e) {
                    logger.error("Could not interrogate classloader loggers for " + ctx.getName() + ". Enable debug logging to see the trace stack");
                    logger.debug(e);
                } finally {
                    if (prevCl != null) {
                        ClassUtils.overrideThreadContextClassLoader(prevCl);
                    }
View Full Code Here

                long totalAvgProcTime = 0;
                int participatingAppCount = 0;

                List contexts = tomcatContainer.findContexts();
                for (Iterator i = contexts.iterator(); i.hasNext(); ) {
                    Context ctx = (Context) i.next();

                    if (ctx != null && ctx.getName() != null) {
                        Application app = new Application();
                        ApplicationUtils.collectApplicationServletStats(ctx, app);

                        String appName = "".equals(ctx.getName()) ? "/" : ctx.getName();

                        long reqDelta = buildDeltaStats("app.requests." + appName, app.getRequestCount(), currentTime);
                        long procTimeDelta = buildDeltaStats("app.proc_time." + appName, app.getProcessingTime(), currentTime);
                        buildDeltaStats("app.errors." + appName, app.getErrorCount());
View Full Code Here

        } else {
            TomcatContainer tomcatContainer = getContainerWrapper().getTomcatContainer();
            if (tomcatContainer != null) {
                List contexts = tomcatContainer.findContexts();
                for (Iterator i = contexts.iterator(); i.hasNext(); ) {
                    Context ctx = (Context) i.next();

                    if (ctx != null && ctx.getName() != null) {
                        String appName = "".equals(ctx.getName()) ? "/" : ctx.getName();
                        reset(appName);
                    }
                }
            }
        }
View Full Code Here

            ctxs.add(context);
        }

        List servletMaps = new ArrayList();
        for (Iterator i = ctxs.iterator(); i.hasNext();) {
            Context ctx = (Context) i.next();
            servletMaps.addAll(ApplicationUtils.getApplicationServletMaps(ctx));
        }

        return new ModelAndView(getViewName(), "servletMaps", servletMaps);
    }
View Full Code Here

            ctxs.add(context);
        }

        List servlets = new ArrayList();
        for (Iterator i = ctxs.iterator(); i.hasNext();) {
            Context ctx = (Context) i.next();
            if (ctx != null) {
                List appServlets = ApplicationUtils.getApplicationServlets(ctx);
                for (Iterator j = appServlets.iterator(); j.hasNext();) {
                    ServletInfo svlt = (ServletInfo) j.next();
                    Collections.sort(svlt.getMappings());
View Full Code Here

        return findContext(contextName) != null;
    }

    public void remove(String contextName) throws Exception {
        contextName = formatContextName(contextName);
        Context ctx = findContext(contextName);

        if (ctx != null) {

            try {
                stop(contextName);
            } catch (Throwable e) {
                logger.info("Stopping " + contextName + " threw this exception:", e);
                //
                // make sure we always re-throw ThreadDeath
                //
                if (e instanceof ThreadDeath) {
                    throw (ThreadDeath) e;
                }
            }

            File appDir;
            File docBase = new File(ctx.getDocBase());

            if (!docBase.isAbsolute()) {
                appDir = new File(getAppBase(), ctx.getDocBase());
            } else {
                appDir = docBase;
            }

            logger.debug("Deleting " + appDir.getAbsolutePath());
View Full Code Here

        Container[] containers = host.findChildren();
        return Arrays.asList(containers);
    }

    public void stop(String name) throws Exception {
        Context ctx = findContext(name);
        if (ctx != null) {
            ((Lifecycle) ctx).stop();
        }
    }
View Full Code Here

            ((Lifecycle) ctx).stop();
        }
    }

    public void start(String name) throws Exception {
        Context ctx = findContext(name);
        if (ctx != null) {
            ((Lifecycle) ctx).start();
        }
    }
View Full Code Here

            if (sidWebApps[i] != null) {
                String[] ss = sidWebApps[i].split(";");
                if (ss.length == 2) {
                    String sessionId = ss[0];
                    String appName = ss[1];
                    Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
                    if (context != null) {
                        Manager manager = context.getManager();
                        Session session = manager.findSession(sessionId);
                        if (session != null && session.isValid()) {
                            session.expire();
                        }
                    } else {
View Full Code Here

TOP

Related Classes of org.apache.catalina.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.