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


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         *
021:         * $Id: PagedSessionHandle.java,v 1.2 2006-06-15 13:44:07 sinisa Exp $
022:         */
023:
024:        package com.lutris.appserver.server.sessionEnhydra;
025:
026:        import com.lutris.appserver.server.session.SessionException;
027:        import com.lutris.util.PersistentStore;
028:
029:        /**
030:         * A lightweight handle to a session which has been paged to disk.
031:         * Referenced to the session manger and user associated with the
032:         * session are not paged.  Instead they are heald by this object
033:         * until the session and corresponding session data are read
034:         * back from disk.
035:         *
036:         * @see         PagedSessionHome
037:         * @version	$Revision: 1.2 $
038:         * @author	Kyle Clark
039:         */
040:        class PagedSessionHandle {
041:
042:            /**
043:             * Keep track if the session object that is paged to disk
044:             * is new.
045:             */
046:            private boolean sessionIsNew;
047:
048:            /**
049:             * Keep track of time session was created.
050:             */
051:            private long sessionTimeCreate;
052:
053:            /**
054:             * The store interface.
055:             */
056:            private PersistentStore store;
057:
058:            /**
059:             * The session that is being paged.
060:             */
061:            private PagedSession session;
062:
063:            /**
064:             * The session key.
065:             */
066:            private String sessionKey;
067:
068:            /**
069:             * Reference to transient data that should be
070:             * held by the handle.
071:             */
072:            private Object[] transientData;
073:
074:            /**
075:             * Creates an instance of PagedSessionHandle.
076:             *
077:             * @param config
078:             *   configuration settings required by this object.
079:             * @param session
080:             *   the session represented by this object.
081:             */
082:            PagedSessionHandle(PagedSession session, PersistentStore store) {
083:                this .session = session;
084:                this .store = store;
085:
086:                // Convenience - performance
087:                this .sessionIsNew = session.isNew();
088:                this .sessionTimeCreate = session.getTimeCreated();
089:                this .sessionKey = session.getSessionKey();
090:                /**DACHA & TUFA
091:                 * need for restoring transient data when restart application
092:                 */
093:                this .transientData = session.getTransientData();
094:            }
095:
096:            /**
097:             * Pages the session to the file system.
098:             *
099:             * @exception SessionException if an error occurs.
100:             */
101:            synchronized void write() throws SessionException {
102:                try {
103:                    transientData = session.getTransientData();
104:                    store.store(sessionKey, session);
105:                    // delete reference to session
106:                    // can be cleaned up via garbage collector.
107:                    session = null;
108:                } catch (Exception e) {
109:                    throw new SessionException(
110:                            "Unable to write session to persistent store.", e);
111:                }
112:            }
113:
114:            /**
115:             * Reads the session from the file system.  The session is
116:             * deleted from the file system.  May return null.
117:             *
118:             * @return the session.
119:             * @exception SessionException if an error occurs.
120:             */
121:            synchronized PagedSession read() throws SessionException {
122:                if (session != null) {
123:                    return session;
124:                }
125:                try {
126:                    session = (PagedSession) store.remove(sessionKey);
127:                    session.restoreTransientData(transientData);
128:                    return session;
129:                } catch (Exception e) {
130:                    throw new SessionException(
131:                            "Unable to read session from persistent store.", e);
132:                }
133:            }
134:
135:            /**
136:             * Deletes the paged session.
137:             *
138:             * @exception SessionException if an error occurs.
139:             */
140:            synchronized void delete() throws SessionException {
141:                try {
142:                    store.delete(sessionKey);
143:                } catch (Exception e) {
144:                    throw new SessionException(
145:                            "Unable to delete session from persistent store.",
146:                            e);
147:                }
148:            }
149:
150:            /**
151:             * Returns true if the session referenced by this handle is new.
152:             *
153:             * @return
154:             *   true if the session referenced by this handle is new.
155:             */
156:            boolean isNew() {
157:                return sessionIsNew;
158:            }
159:
160:            /**
161:             * Returns the time the session referenced by this handle
162:             * was created.
163:             *
164:             * @return
165:             *   the time the session referenced by this handle
166:             *   was created.
167:             */
168:            long getTimeCreated() {
169:                return sessionTimeCreate;
170:            }
171:
172:            /**
173:             * Returns the session key associated with this object.
174:             *
175:             * @return
176:             *   the session key.
177:             */
178:            String getSessionKey() {
179:                return sessionKey;
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.