Source Code Cross Referenced for PortletSessionManager.java in  » Portal » gridsphere » org » gridsphere » portletcontainer » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » gridsphere » org.gridsphere.portletcontainer.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gridsphere.portletcontainer.impl;
002:
003:        import org.apache.commons.logging.Log;
004:        import org.apache.commons.logging.LogFactory;
005:        import org.gridsphere.portletcontainer.PortletSessionListener;
006:
007:        import javax.servlet.http.HttpSession;
008:        import javax.servlet.http.HttpSessionEvent;
009:        import javax.servlet.http.HttpSessionListener;
010:        import java.util.*;
011:
012:        /**
013:         * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
014:         * @version $Id: PortletSessionManager.java 6425 2008-02-29 11:23:10Z wehrens $
015:         */
016:        public class PortletSessionManager implements  HttpSessionListener {
017:
018:            private static PortletSessionManager instance = new PortletSessionManager();
019:            private Log log = LogFactory.getLog(PortletSessionManager.class);
020:
021:            private Hashtable<String, HttpSession> sessions = new Hashtable<String, HttpSession>();
022:            private Hashtable<String, List<PortletSessionListener>> sessionListeners = new Hashtable<String, List<PortletSessionListener>>();
023:
024:            private PortletSessionManager() {
025:
026:            }
027:
028:            public static PortletSessionManager getInstance() {
029:                return instance;
030:            }
031:
032:            public int getNumSessions() {
033:                return sessions.size();
034:            }
035:
036:            public Collection<HttpSession> getSessions() {
037:                return sessions.values();
038:            }
039:
040:            public Set<String> getSessionIds() {
041:                return sessions.keySet();
042:            }
043:
044:            /**
045:             * Record the fact that a session has been created.
046:             *
047:             * @param event The session event
048:             */
049:            public void sessionCreated(HttpSessionEvent event) {
050:                log.debug("sessionCreated('" + event.getSession().getId()
051:                        + "')");
052:                String id = event.getSession().getId();
053:                sessions.put(id, event.getSession());
054:                dumpSessions();
055:            }
056:
057:            /**
058:             * Record the fact that a session has been destroyed.
059:             *
060:             * @param event The session event
061:             */
062:            public void sessionDestroyed(HttpSessionEvent event) {
063:                log.debug("sessionDestroyed('" + event.getSession().getId()
064:                        + "')");
065:                HttpSession httpSession = event.getSession();
066:                if (httpSession != null) {
067:                    String id = event.getSession().getId();
068:
069:                    List<PortletSessionListener> listeners = sessionListeners
070:                            .get(id);
071:                    if (listeners != null) {
072:                        Iterator<PortletSessionListener> it = listeners
073:                                .iterator();
074:                        while (it.hasNext()) {
075:                            PortletSessionListener sessionListener = (PortletSessionListener) it
076:                                    .next();
077:
078:                            log.info("logging a session listener out: "
079:                                    + sessionListener.getClass());
080:                            sessionListener.logout(httpSession);
081:
082:                        }
083:                        log.info("Removing session: " + httpSession.getId());
084:                        sessions.remove(id);
085:                        sessionListeners.remove(id);
086:                    }
087:                } else {
088:                    log
089:                            .info("Not sure why sessionDestroyed listener provides null session id!");
090:                }
091:                dumpSessions();
092:            }
093:
094:            public void addSessionListener(String sessionId,
095:                    PortletSessionListener sessionListener) {
096:                log.debug("adding session listener for : " + sessionId + " "
097:                        + sessionListener.getClass());
098:                HttpSession session = (HttpSession) sessions.get(sessionId);
099:                if (session != null) {
100:                    List<PortletSessionListener> listeners = sessionListeners
101:                            .get(sessionId);
102:                    if (listeners == null)
103:                        listeners = new ArrayList<PortletSessionListener>();
104:                    listeners.add(sessionListener);
105:                    System.err.println("adding session listener for : "
106:                            + sessionId + " " + sessionListener.getClass());
107:                    sessionListeners.put(sessionId, listeners);
108:                }
109:                dumpSessions();
110:            }
111:
112:            public void dumpSessions() {
113:                log.debug("PortletSessionManager Session information:");
114:                log.debug("# current sessions: " + sessions.size());
115:                Set<String> keySet = sessions.keySet();
116:                Iterator<String> it = keySet.iterator();
117:                while (it.hasNext()) {
118:                    log.debug("session #id: " + (String) it.next());
119:                }
120:            }
121:
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.