Package com.googlecode.psiprobe.model

Examples of com.googlecode.psiprobe.model.ApplicationSession


            Context ctx = (Context) it.next();
            if (ctx != null && ctx.getManager() != null && (!searchInfo.isApply() || searchInfo.isUseSearch())) {
                Session[] sessions = ctx.getManager().findSessions();
                for (int i = 0; i < sessions.length; i++) {
                    Session session = sessions[i];
                    ApplicationSession appSession = ApplicationUtils.getApplicationSession(
                            session, calcSize, searchInfo.isUseAttr());
                    if (appSession != null && matchSession(appSession, searchInfo)) {
                        if (ctx.getName() != null) {
                            appSession.setApplicationName(ctx.getName().length() > 0 ? ctx.getName() : "/");
                        }
                        sessionList.add(appSession);
                    }
                }
            }
View Full Code Here


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

        ApplicationSession appSession = ApplicationUtils.getApplicationSession(
                context.getManager().findSession(sid), calcSize, true);

        if (appSession != null) {
            appSession.setAllowedToViewValues(privileged);
            return new ModelAndView(getViewName(), "session", appSession);
        } else {
            return new ModelAndView(getViewName());
        }
    }
View Full Code Here

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

        }
        return scores;
    }

    public static ApplicationSession getApplicationSession(Session session, boolean calcSize, boolean addAttributes) {
        ApplicationSession sbean = null;
        if (session != null && session.isValid()) {
            sbean = new ApplicationSession();

            sbean.setId(session.getId());
            sbean.setCreationTime(new Date(session.getCreationTime()));
            sbean.setLastAccessTime(new Date(session.getLastAccessedTime()));
            sbean.setMaxIdleTime(session.getMaxInactiveInterval() * 1000);
            sbean.setManagerType(session.getManager().getClass().getName());
            sbean.setInfo(session.getInfo());

            boolean sessionSerializable = true;
            int attributeCount = 0;
            long size = 0;

            HttpSession httpSession = session.getSession();
            Set processedObjects = new HashSet(1000);
            try {
                for (Enumeration e = httpSession.getAttributeNames(); e.hasMoreElements();) {
                    String name = (String) e.nextElement();
                    Object o = httpSession.getAttribute(name);
                    sessionSerializable = sessionSerializable && o instanceof Serializable;

                    long oSize = 0;
                    if (calcSize) {
                        try {
                            oSize += Instruments.sizeOf(name, processedObjects);
                            oSize += Instruments.sizeOf(o, processedObjects);
                        } catch (Throwable th) {
                            logger.error("Cannot estimate size of attribute \"" + name + "\"", th);
                            //
                            // make sure we always re-throw ThreadDeath
                            //
                            if (e instanceof ThreadDeath) {
                                throw (ThreadDeath) e;
                            }
                        }
                    }

                    if (addAttributes) {
                        Attribute saBean = new Attribute();
                        saBean.setName(name);
                        saBean.setType(ClassUtils.getQualifiedName(o.getClass()));
                        saBean.setValue(o);
                        saBean.setSize(oSize);
                        saBean.setSerializable(o instanceof Serializable);
                        sbean.addAttribute(saBean);
                    }
                    attributeCount++;
                    size += oSize;
                }
                String lastAccessedIP = (String) httpSession.getAttribute(ApplicationSession.LAST_ACCESSED_BY_IP);
                if (lastAccessedIP != null) {
                    sbean.setLastAccessedIP(lastAccessedIP);
                }
                try {
                    sbean.setLastAccessedIPLocale(InetAddressLocator.getLocale(InetAddress.getByName(lastAccessedIP).getAddress()));
                } catch (Throwable e) {
                    logger.error("Cannot determine Locale of "+lastAccessedIP);
                    //
                    // make sure we always re-throw ThreadDeath
                    //
                    if (e instanceof ThreadDeath) {
                        throw (ThreadDeath) e;
                    }
                }


            } catch (IllegalStateException e) {
                logger.info("Session appears to be invalidated, ignore");
            }

            sbean.setObjectCount(attributeCount);
            sbean.setSize(size);
            sbean.setSerializable(sessionSerializable);
        }

        return sbean;
    }
View Full Code Here

TOP

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

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.