Source Code Cross Referenced for HttpPortletSession.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » portal » generic » 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 » EJB Server resin 3.1.5 » resin » com.caucho.portal.generic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         * Copyright (c) 2001-2004 Caucho Technology, Inc.  All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * 1. Redistributions of source code must retain the above copyright
011:         *    notice, this list of conditions and the following disclaimer.
012:         *
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in
015:         *    the documentation and/or other materials provided with the
016:         *    distribution.
017:         *
018:         * 3. The end-user documentation included with the redistribution, if
019:         *    any, must include the following acknowlegement:
020:         *       "This product includes software developed by the
021:         *        Caucho Technology (http://www.caucho.com/)."
022:         *    Alternately, this acknowlegement may appear in the software itself,
023:         *    if and wherever such third-party acknowlegements normally appear.
024:         *
025:         * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
026:         *    endorse or promote products derived from this software without prior
027:         *    written permission. For written permission, please contact
028:         *    info@caucho.com.
029:         *
030:         * 5. Products derived from this software may not be called "Resin"
031:         *    nor may "Resin" appear in their names without prior written
032:         *    permission of Caucho Technology.
033:         *
034:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037:         * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
038:         * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
039:         * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
040:         * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
041:         * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
042:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
043:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
044:         * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
045:         *
046:         * @author Sam
047:         */
048:
049:        package com.caucho.portal.generic;
050:
051:        import javax.portlet.PortletContext;
052:        import javax.portlet.PortletSession;
053:        import javax.servlet.http.HttpSession;
054:        import java.util.Enumeration;
055:        import java.util.NoSuchElementException;
056:        import java.util.logging.Logger;
057:
058:        /**
059:         * An adapter to a {@link javax.servlet.HttpSession}.
060:         */
061:        public class HttpPortletSession implements  PortletSession {
062:            static protected final Logger log = Logger
063:                    .getLogger(HttpPortletSession.class.getName());
064:
065:            public final String PORTLET_SCOPE_PREFIX = "javax.portlet.p.";
066:            public final String PORTLET_SCOPE_RESERVED_PREFIX = "javax.portlet.p.javax.portlet.";
067:
068:            private PortletContext _portletContext;
069:            private HttpSession _httpSession;
070:
071:            public HttpPortletSession() {
072:            }
073:
074:            public void start(PortletContext portletContext,
075:                    HttpSession httpSession) {
076:                _portletContext = portletContext;
077:                _httpSession = httpSession;
078:
079:                if (_httpSession != null) {
080:                    for (Enumeration en = _httpSession.getAttributeNames(); en
081:                            .hasMoreElements();) {
082:                        String name = (String) en.nextElement();
083:                        Object value = _httpSession.getAttribute(name);
084:                    }
085:                }
086:
087:            }
088:
089:            /**
090:             * Finish with the HttpSession object.  After calling this method, 
091:             * this object can be placed into a pool and reused for subsequent requests.
092:             */
093:            public void finish() {
094:                _httpSession = null;
095:                _portletContext = null;
096:            }
097:
098:            public PortletContext getPortletContext() {
099:                return _portletContext;
100:            }
101:
102:            public HttpSession getHttpSession() {
103:                return _httpSession;
104:            }
105:
106:            private String scopedName(String name, int scope) {
107:                if (name == null)
108:                    throw new IllegalArgumentException("name is null");
109:
110:                if (false) // XXX: isInvalid() might be handled by HttpSession
111:                    throw new IllegalStateException("session is invalid");
112:
113:                if (scope == APPLICATION_SCOPE) {
114:                } else if (scope == PORTLET_SCOPE) {
115:                    StringBuffer sb = new StringBuffer(PORTLET_SCOPE_PREFIX);
116:                    sb.append(name);
117:                    name = sb.toString();
118:                } else {
119:                    throw new IllegalArgumentException("invalid scope `"
120:                            + scope + "'");
121:                }
122:
123:                return name;
124:            }
125:
126:            public Object getAttribute(String name) {
127:                return getAttribute(name, PORTLET_SCOPE);
128:            }
129:
130:            public Object getAttribute(String name, int scope) {
131:                return _httpSession.getAttribute(scopedName(name, scope));
132:            }
133:
134:            public Enumeration getAttributeNames() {
135:                return getAttributeNames(PORTLET_SCOPE);
136:            }
137:
138:            public Enumeration getAttributeNames(int scope) {
139:                if (scope == APPLICATION_SCOPE) {
140:                    return _httpSession.getAttributeNames();
141:                } else if (scope == PORTLET_SCOPE) {
142:                    return new Enumeration() {
143:                        private Enumeration _e = _httpSession
144:                                .getAttributeNames();
145:                        private Object _next;
146:
147:                        public boolean hasMoreElements() {
148:                            nextIfNeeded();
149:                            return _next != null ? true : false;
150:                        }
151:
152:                        public Object nextElement() {
153:                            nextIfNeeded();
154:                            if (_next == null)
155:                                throw new NoSuchElementException();
156:                            String result = (String) _next;
157:                            result = result.substring(PORTLET_SCOPE_PREFIX
158:                                    .length());
159:                            _next = null;
160:                            return result;
161:                        }
162:
163:                        private void nextIfNeeded() {
164:                            if (_next == null) {
165:                                while (_e.hasMoreElements()) {
166:                                    String e = (String) _e.nextElement();
167:                                    if (e.startsWith(PORTLET_SCOPE_PREFIX)) {
168:                                        if (!e
169:                                                .startsWith(PORTLET_SCOPE_RESERVED_PREFIX)) {
170:                                            _next = e;
171:                                            break;
172:                                        }
173:                                    }
174:                                }
175:                            }
176:                        }
177:                    };
178:                } else {
179:                    throw new IllegalArgumentException("invalid scope `"
180:                            + scope + "'");
181:                }
182:            }
183:
184:            public long getCreationTime() {
185:                return _httpSession.getCreationTime();
186:            }
187:
188:            public String getId() {
189:                return _httpSession.getId();
190:            }
191:
192:            public long getLastAccessedTime() {
193:                return _httpSession.getLastAccessedTime();
194:            }
195:
196:            public int getMaxInactiveInterval() {
197:                return _httpSession.getMaxInactiveInterval();
198:            }
199:
200:            public void invalidate() {
201:                _httpSession.invalidate();
202:            }
203:
204:            public boolean isNew() {
205:                return _httpSession.isNew();
206:            }
207:
208:            public void removeAttribute(String name) {
209:                removeAttribute(name, PORTLET_SCOPE);
210:            }
211:
212:            public void removeAttribute(String name, int scope) {
213:                _httpSession.removeAttribute(scopedName(name, scope));
214:            }
215:
216:            public void setAttribute(String name, Object value) {
217:                setAttribute(name, value, PORTLET_SCOPE);
218:            }
219:
220:            public void setAttribute(String name, Object value, int scope) {
221:                _httpSession.setAttribute(scopedName(name, scope), value);
222:            }
223:
224:            public void setMaxInactiveInterval(int interval) {
225:                _httpSession.setMaxInactiveInterval(interval);
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.