Source Code Cross Referenced for ContainerAdapterSession.java in  » J2EE » Enhydra-Application-Framework » com » lutris » appserver » server » sessionContainerAdapter » 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 » J2EE » Enhydra Application Framework » com.lutris.appserver.server.sessionContainerAdapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.lutris.appserver.server.sessionContainerAdapter;
002:
003:        import java.io.Serializable;
004:        import java.util.Date;
005:
006:        import javax.servlet.http.HttpSession;
007:        import javax.servlet.http.HttpSessionActivationListener;
008:        import javax.servlet.http.HttpSessionBindingEvent;
009:        import javax.servlet.http.HttpSessionBindingListener;
010:        import javax.servlet.http.HttpSessionEvent;
011:
012:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
013:        import com.lutris.appserver.server.session.SessionData;
014:        import com.lutris.appserver.server.session.SessionException;
015:        import com.lutris.appserver.server.session.SessionManager;
016:        import com.lutris.appserver.server.user.User;
017:
018:        /**
019:         * <p>Description: </p>
020:         * Session object, used to keep the session data
021:         * @version 1.0
022:         */
023:        public class ContainerAdapterSession implements 
024:                com.lutris.appserver.server.session.Session,
025:                HttpSessionActivationListener, HttpSessionBindingListener,
026:                Serializable {
027:
028:            /**
029:             * user object
030:             */
031:            private User user;
032:            /**
033:             * Session dat, must be serializable since the servlet container really manages
034:             * the sessions, and Tomcat's standard manager implementation needs serializable objects
035:             */
036:            private SerializableSessionData sessionData;
037:            /**
038:             * SessionManager that is used to create this Session object
039:             */
040:            private transient SessionManager sessionManager;
041:
042:            private transient HttpSession httpSession;
043:
044:            /**
045:             * Name of the session object in the HttpSession
046:             */
047:            protected String SESSION = "session";
048:
049:            /**
050:             * Default constructor
051:             */
052:            public ContainerAdapterSession() {
053:            }
054:
055:            /**
056:             *
057:             * @param sessionManager SessionManager that is used to create this Session object
058:             * @param sessionKey The identifiction of the session
059:             */
060:            public ContainerAdapterSession(
061:                    ContainerAdapterSessionManager sessionManager,
062:                    HttpSession httpSession) {
063:
064:                this .sessionManager = sessionManager;
065:                this .httpSession = httpSession;
066:                sessionData = new SerializableSessionData();
067:                user = null;
068:            }
069:
070:            /**
071:             * @return the User object;
072:             */
073:            public User getUser() {
074:                return user;
075:            }
076:
077:            /**
078:             * Sets the user
079:             * @param user - the user object of the session
080:             * @throws SessionException
081:             */
082:            public void setUser(User user)
083:                    throws com.lutris.appserver.server.session.SessionException {
084:                this .user = user;
085:            }
086:
087:            /**
088:             * clears the user object
089:             * @throws SessionException
090:             */
091:            public void clearUser()
092:                    throws com.lutris.appserver.server.session.SessionException {
093:                user = null;
094:            }
095:
096:            /**
097:             *
098:             * @return the session identification
099:             */
100:            public String getSessionKey() {
101:                if (httpSession != null)
102:                    return httpSession.getId();
103:                else
104:                    return null;
105:            }
106:
107:            /**
108:             *
109:             * @return the session creation time
110:             */
111:            public long getTimeCreated() {
112:                if (httpSession != null)
113:                    return httpSession.getCreationTime();
114:                else
115:                    return -1;
116:            }
117:
118:            /**
119:             * Obtain the time of last use for this object.  The time is in
120:             * milliseconds since Midnight, Jan 1, 1970 (epoch).
121:             *
122:             * @return The time of last use since epoch for this object.
123:             */
124:
125:            public long getTimeLastUsed() {
126:                if (httpSession != null)
127:                    return httpSession.getLastAccessedTime();
128:                else
129:                    return -1;
130:            }
131:
132:            protected void setTimeCreated(long cTime) {
133:            }
134:
135:            /**
136:             * Obtain the maximum idle time for this object. Zero (or negative)
137:             * indicates that sessions may be idle indefinetly.
138:             *
139:             * @return The maximum number of milliseconds this session
140:             *      may be idle.
141:             */
142:            public long getMaxIdleTime() {
143:                if (httpSession != null)
144:                    return httpSession.getMaxInactiveInterval();
145:                else
146:                    return -1;
147:            }
148:
149:            /**
150:             * Set the maximum idle time for this object. Set this to zero
151:             * (or negative) to disable idle checking.
152:             *
153:             * @param maxIdleTime The maximum number of milliseconds this
154:             *  session may be idle, or zero (or negative) to allow sessions to be idle
155:             *  indefinetly.
156:             */
157:            public void setMaxIdleTime(int maxIdleTime) {
158:                if (httpSession != null)
159:                    httpSession.setMaxInactiveInterval(maxIdleTime);
160:            }
161:
162:            /**
163:             *
164:             * @return the <code> SessionManager </code>used to create this session
165:             */
166:            public SessionManager getSessionManager() {
167:                return sessionManager;
168:
169:            }
170:
171:            public void setSessionManager(SessionManager sessionManager) {
172:                this .sessionManager = sessionManager;
173:            }
174:
175:            /**
176:             *
177:             * @return the <code> SessionData </code>
178:             */
179:            public SessionData getSessionData() {
180:                return sessionData;
181:            }
182:
183:            /**
184:             * puts the <code> SessionData </code> into this session
185:             * @param sessionData
186:             */
187:            public void setSessionData(SessionData sessionData) {
188:                this .sessionData = (SerializableSessionData) sessionData;
189:            }
190:
191:            public boolean isNew() {
192:                if (httpSession != null)
193:                    return (httpSession.getCreationTime() == httpSession
194:                            .getLastAccessedTime());
195:                else
196:                    return true;
197:            }
198:
199:            public String toString() {
200:
201:                StringBuffer result = new StringBuffer();
202:                Date ct = new Date(getTimeCreated());
203:                result.append("CreationTime:");
204:                result.append(" ");
205:                result.append(ct.toString());
206:
207:                if (getUser() != null) {
208:                    result.append("\n");
209:                    result.append("User:");
210:                    result.append(" ");
211:                    result.append(getUser().getName());
212:
213:                }
214:                if (getSessionData() != null) {
215:                    String data = getSessionData().toString();
216:                    if (data != null) {
217:                        result.append("\n");
218:                        result.append("SessionData:");
219:                        result.append(" ");
220:                        result.append(data);
221:                    }
222:                }
223:                return result.toString();
224:
225:            }
226:
227:            public HttpSession getHttpSession() {
228:                return httpSession;
229:            }
230:
231:            public void setHttpSession(HttpSession httpSession) {
232:                this .httpSession = httpSession;
233:                //this.httpSession.setAttribute(SESSION,this);
234:            }
235:
236:            public void valueBound(HttpSessionBindingEvent event) {
237:
238:            }
239:
240:            public void valueUnbound(HttpSessionBindingEvent event) {
241:                if (SESSION.equals(event.getName())) {
242:                    sessionManager = null;
243:                    httpSession = null;
244:                    user = null;
245:                    sessionData = null;
246:                }
247:            }
248:
249:            public void sessionWillPassivate(HttpSessionEvent event) {
250:                sessionManager = null;
251:                httpSession = null;
252:            }
253:
254:            public void sessionDidActivate(HttpSessionEvent event) {
255:                httpSession = event.getSession();
256:            }
257:
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.