Source Code Cross Referenced for SessionManager.java in  » XML-UI » xui32 » com » xoetrope » service » servlet » 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 » XML UI » xui32 » com.xoetrope.service.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.service.servlet;
002:
003:        import com.xoetrope.carousel.build.BuildProperties;
004:        import com.xoetrope.service.LicenceCheck;
005:        import java.awt.Frame;
006:        import java.util.Hashtable;
007:        import java.util.Vector;
008:        import javax.swing.JOptionPane;
009:        import net.xoetrope.optional.service.ServiceContext;
010:        import net.xoetrope.optional.service.ServiceProxy;
011:        import net.xoetrope.optional.service.ServiceProxyArgs;
012:        import net.xoetrope.optional.service.ServiceProxyException;
013:        import net.xoetrope.optional.service.XRouteManager;
014:        import net.xoetrope.xui.XProject;
015:
016:        import net.xoetrope.xui.XProjectManager;
017:        import net.xoetrope.xui.data.XModel;
018:
019:        /**
020:         * Description ServiceProxy Object for handling session management on the server
021:         * To be used with servlet engines. The session can be managed automatically or
022:         * manually depending on the 'selfmanaged' attribute of the XML declaration.
023:         *
024:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
025:         * the GNU Public License (GPL), please see license.txt for more details. If
026:         * you make commercial use of this software you must purchase a commercial
027:         * license from Xoetrope.</p>
028:         * <p> $Revision: 1.14 $</p>
029:         */
030:        public class SessionManager extends ServiceProxy {
031:            private String sessionKey;
032:            private XModel sessIdMdl;
033:
034:            public static final String INVALID_SESSION = "INVALID_SESSION";
035:            public static final String NEW_SESSION = "NEW_SESSION";
036:            public static final String VALID_SESSION = "VALID_SESSION";
037:
038:            public static final String ARG_NAME_SESSION_STATE = "session:state";
039:
040:            /**
041:             * The error which is returned in case the session has expired
042:             */
043:            public static final String ERR_SESSION_EXPIRED = "sessionerror:sessionexpired";
044:
045:            /**
046:             * The name of the parameter which will be used to check the session validity
047:             */
048:            public static final String ARG_NAME_CHECKPARAM = "session:checkparam";
049:
050:            /**
051:             * The session argument to be passes to the servlet engine
052:             */
053:            public static final String ARG_NAME_PASS_SESSION = ";jsessionid";
054:
055:            /**
056:             * The returned session key
057:             */
058:            public static final String ARG_NAME_RETURN_SESSION = "session:sessionkey";
059:
060:            /**
061:             * If the sessionmanager is selfmanaged and this parameter is set it sets and
062:             * retrieves the session key in this node in the model.
063:             */
064:            public static final String ARG_NAME_MODELSESSID = "session:modelsessionid";
065:
066:            /**
067:             * Indicates whether the session key is managed automatically by an instance of this object
068:             */
069:            protected boolean selfManaged = false;
070:
071:            /**
072:             * The owner project and the context in which this object operates.
073:             */
074:            protected XProject currentProject = XProjectManager
075:                    .getCurrentProject();
076:
077:            /**
078:             * The overloaded call for the ServiceProxy
079:             * Syntax for servler SessionID...
080:             * ;jsessionid=789ec62424e5865edf3ceec4f0976bdf
081:             * @param method The name of the service
082:             * @param context The ServiceContext containing arguments
083:             * @throws net.xoetrope.optional.service.ServiceProxyException Throw ServiceProxyException if the call fails
084:             * @return The result of the call
085:             */
086:            public Object call(String method, ServiceContext context)
087:                    throws ServiceProxyException {
088:                Object res = null;
089:                ServiceProxyArgs args = context.getArgs();
090:
091:                boolean client = (side == XRouteManager.CLIENT_SIDE);
092:                if (client) {
093:                    if (BuildProperties.IS_EVAL)
094:                        LicenceCheck.checkLicence();
095:
096:                    /**
097:                     * Pass the current session key to the server, call the next proxy. If 
098:                     * there was an error on the server show the error message otherwise store
099:                     * the session key for future calls.
100:                     */
101:                    String modelSessid = (String) args
102:                            .getPassParam(ARG_NAME_MODELSESSID);
103:                    if ((modelSessid != null) && (modelSessid.length() > 0))
104:                        sessIdMdl = (XModel) XProjectManager.getModel().get(
105:                                modelSessid);
106:
107:                    if (sessIdMdl != null)
108:                        sessionKey = (String) sessIdMdl.get();
109:
110:                    if (selfManaged)
111:                        args.setPassParam(ARG_NAME_PASS_SESSION, sessionKey);
112:
113:                    res = nextProxy.call(method, context);
114:                    String error = getSessionError(context);
115:                    if (error != null) {
116:                        showErrorMessage();
117:                        setSessionModelValue(args, null);
118:                    } else if ((selfManaged) && !context.hasErrors())
119:                        setSessionModelValue(args, (String) args
120:                                .getReturnParam(ARG_NAME_RETURN_SESSION));
121:                }
122:                return res;
123:            }
124:
125:            /**
126:             * @param args
127:             * @param value
128:             */
129:            protected void setSessionModelValue(ServiceProxyArgs args,
130:                    String value) {
131:                if (sessIdMdl != null)
132:                    sessIdMdl.set(value);
133:            }
134:
135:            /**
136:             * @param context
137:             */
138:            protected String getSessionError(ServiceContext context) {
139:                Vector errors = context.getErrors();
140:                for (int i = 0; i < errors.size(); i++) {
141:                    String err = (String) errors.get(i);
142:                    if (err.compareTo(ERR_SESSION_EXPIRED) == 0)
143:                        return ERR_SESSION_EXPIRED;
144:                }
145:                return null;
146:            }
147:
148:            /**
149:             * If there is a problem with the session show a message on the client.
150:             */
151:            private void showErrorMessage() {
152:                Frame fra = currentProject.getAppFrame();
153:                JOptionPane dlg = new JOptionPane();
154:                dlg.showMessageDialog(fra,
155:                        "You session has expired... Please log on again!");
156:            }
157:
158:            /**
159:             * Check the self managed attribute of the ServiceProxy so we can store state
160:             * or pass it back through the return arguments
161:             * @param attribs Hashtable of attributes from the XML declaration
162:             */
163:            public void setAttributes(Hashtable attribs) {
164:                String temp = (String) attribs.get("selfmanaged");
165:                if (temp != null) {
166:                    selfManaged = temp.compareTo("true") == 0;
167:                    if (side == XRouteManager.CLIENT_SIDE) {
168:                        String modelSessid = (String) attribs.get("modelid");
169:                        if (modelSessid != null)
170:                            sessIdMdl = (XModel) XProjectManager.getModel()
171:                                    .get(modelSessid);
172:                    }
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.