Package com.googlecode.psiprobe.model

Examples of com.googlecode.psiprobe.model.Application


        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);
            }
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");
View Full Code Here

            File f1 = d1.getFile();
            File f2 = d2.getFile();
            String name1 = (f1 == null ? "" : f1.getAbsolutePath());
            String name2 = (f2 == null ? "" : f2.getAbsolutePath());
            if (all) {
                Application a1 = d1.getApplication();
                Application a2 = d2.getApplication();
            if (a1 == null || a2 == null) {
                a1 = null;
                a2 = null;
            }
                String appName1 = (a1 == null ? "" : a1.getName());
                String appName2 = (a2 == null ? "" : a2.getName());
                String context1 = (d1.isContext() ? "is" : "not");
                String context2 = (d2.isContext() ? "is" : "not");
                String root1 = (d1.isRoot() ? "is" : "not");
                String root2 = (d2.isRoot() ? "is" : "not");
                String logType1 = d1.getLogType();
View Full Code Here

            LogDestination d2 = (LogDestination) o2;
            File f1 = d1.getFile();
            File f2 = d2.getFile();
            String filename1 = (f1 == null ? "" : f1.getAbsolutePath());
            String filename2 = (f2 == null ? "" : f2.getAbsolutePath());
            Application a1 = d1.getApplication();
            Application a2 = d2.getApplication();
            if (a1 == null || a2 == null) {
                a1 = null;
                a2 = null;
            }
            String appName1 = (a1 == null ? "" : a1.getName());
            String appName2 = (a2 == null ? "" : a2.getName());
            String logType1 = d1.getLogType();
            String logType2 = d1.getLogType();
            String context1 = (d1.isContext() ? "is" : "not");
            String context2 = (d2.isContext() ? "is" : "not");
            String root1 = (d1.isRoot() ? "is" : "not");
View Full Code Here

                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());

                        long avgProcTime = reqDelta == 0 ? 0 : procTimeDelta / reqDelta;
                        buildAbsoluteStats( "app.avg_proc_time." + appName, avgProcTime, currentTime);

                        // make sure applications that did not serve any requests
View Full Code Here

                                         HttpServletRequest request, HttpServletResponse response) throws Exception {

        boolean calcSize = ServletRequestUtils.getBooleanParameter(request, "size", false)
                && SecurityUtils.hasAttributeValueRole(getServletContext(), request);

        Application app = ApplicationUtils.getApplication(
                context, isExtendedInfo() ? getContainerWrapper().getResourceResolver() : null, calcSize);

        if (isExtendedInfo() && getStatsCollection() != null) {
            String avgStatisticName = "app.avg_proc_time." + app.getName();
            app.setAvgTime(getStatsCollection().getLastValueForStat(avgStatisticName));
        }

        return new ModelAndView(getViewName())
                .addObject("app", app)
                .addObject("no_resources", Boolean.valueOf(!getContainerWrapper().getResourceResolver().supportsPrivateResources()))
View Full Code Here

     */
    public static Application getApplication(Context context, ResourceResolver resourceResolver, boolean calcSize) {

        logger.debug("Querying webapp: " + context.getName());

        Application app = new Application();
        app.setName(context.getName().length() > 0 ? context.getName() : "/");
        app.setDocBase(context.getDocBase());
        app.setDisplayName(context.getDisplayName());
        app.setAvailable(context.getAvailable());
        app.setDistributable(context.getDistributable());
        app.setSessionTimeout(context.getSessionTimeout());
        app.setServletVersion(context.getServletContext().getMajorVersion() + "." + context.getServletContext().getMinorVersion());

        if (resourceResolver != null) {
            logger.debug("counting servlet attributes");

            int ctxAttrCount = 0;
            for (Enumeration e = context.getServletContext().getAttributeNames(); e.hasMoreElements(); e.nextElement()) {
                ctxAttrCount++;
            }
            app.setContextAttributeCount(ctxAttrCount);

            if (app.isAvailable()) {
                logger.debug("collecting session information");

                app.setSessionCount(context.getManager().findSessions().length);

                boolean serializable = true;
                int sessionAttributeCount = 0;
                long size = 0;

                Session[] sessions = context.getManager().findSessions();
                for (int i = 0; i < sessions.length; i++) {
                    ApplicationSession appSession = getApplicationSession(sessions[i], calcSize, false);
                    if (appSession != null) {
                        sessionAttributeCount += appSession.getObjectCount();
                        serializable = serializable && appSession.isSerializable();
                        size += appSession.getSize();
                    }
                }
                app.setSerializable(serializable);
                app.setSessionAttributeCount(sessionAttributeCount);
                app.setSize(size);
            }

            logger.debug("aggregating servlet stats");

            collectApplicationServletStats(context, app);

            if (resourceResolver.supportsPrivateResources() && app.isAvailable()) {
                int[] scores = getApplicationDataSourceUsageScores(context, resourceResolver);
                app.setDataSourceBusyScore(scores[0]);
                app.setDataSourceEstablishedScore(scores[1]);
            }
        }

        return app;
    }
View Full Code Here

TOP

Related Classes of com.googlecode.psiprobe.model.Application

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.