Source Code Cross Referenced for AttributeAccessor.java in  » Web-Framework » calyxo » de » odysseus » calyxo » base » access » 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 » Web Framework » calyxo » de.odysseus.calyxo.base.access 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004, 2005, 2006 Odysseus Software GmbH
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package de.odysseus.calyxo.base.access;
017:
018:        import javax.servlet.http.HttpServletRequest;
019:        import javax.servlet.http.HttpSession;
020:
021:        import de.odysseus.calyxo.base.ModuleContext;
022:
023:        /**
024:         * This accessor serves an attribute value.
025:         * 
026:         * @author Christoph Beck
027:         */
028:        public class AttributeAccessor implements  Accessor {
029:
030:            /**
031:             * Request attribute scope
032:             */
033:            public static final int REQUEST_SCOPE = 1;
034:
035:            /**
036:             * Session attribute scope
037:             */
038:            public static final int SESSION_SCOPE = 2;
039:
040:            /**
041:             * Module attribute scope
042:             */
043:            public static final int MODULE_SCOPE = 4;
044:
045:            /**
046:             * Application attribute scope
047:             */
048:            public static final int APPLICATION_SCOPE = 8;
049:
050:            /**
051:             * Search all scopes
052:             */
053:            public static final int ALL_SCOPES = 15;
054:
055:            private int scope;
056:            private String name;
057:            private boolean cachable;
058:            private ModuleContext context;
059:
060:            /**
061:             * Constructor.
062:             * @param context The module context we're in
063:             * @param name attribute name
064:             * @param scope attribute scope
065:             * @param cachable true iff attribute value cannot change within request
066:             */
067:            public AttributeAccessor(ModuleContext context, String name,
068:                    int scope, boolean cachable) {
069:                this .context = context;
070:                this .scope = scope;
071:                this .name = name;
072:                this .cachable = cachable;
073:            }
074:
075:            /**
076:             * Constructor (not cachable).
077:             * @param context The module context we're in
078:             * @param name attribute name
079:             * @param scope attribute scope
080:             */
081:            public AttributeAccessor(ModuleContext context, String name,
082:                    int scope) {
083:                this (context, name, scope, false);
084:            }
085:
086:            /**
087:             * Constructor (search all scopes).
088:             * @param context The module context we're in
089:             * @param name attribute name
090:             * @param cachable true iff attribute value cannot change within request
091:             */
092:            public AttributeAccessor(ModuleContext context, String name,
093:                    boolean cachable) {
094:                this (context, name, ALL_SCOPES, cachable);
095:            }
096:
097:            /**
098:             * Constructor (not cachable, search all scopes).
099:             * @param context The module context we're in
100:             * @param name attribute name
101:             */
102:            public AttributeAccessor(ModuleContext context, String name) {
103:                this (context, name, false);
104:            }
105:
106:            /**
107:             * Get attribute value according to name and scope settings;
108:             */
109:            public Object get(HttpServletRequest request) {
110:                HttpSession session = null;
111:                switch (scope) {
112:                case REQUEST_SCOPE:
113:                    return request.getAttribute(name);
114:
115:                case SESSION_SCOPE:
116:                    session = request.getSession(false);
117:                    if (session == null) {
118:                        return null;
119:                    }
120:                    return session.getAttribute(name);
121:
122:                case MODULE_SCOPE:
123:                    return context.getAttribute(name);
124:
125:                case APPLICATION_SCOPE:
126:                    return context.getServletContext().getAttribute(name);
127:
128:                case ALL_SCOPES:
129:                    Object result = request.getAttribute(name);
130:                    if (result != null) {
131:                        return result;
132:                    }
133:                    session = request.getSession(false);
134:                    result = session.getAttribute(name);
135:                    if (result != null) {
136:                        return result;
137:                    }
138:                    result = context.getAttribute(name);
139:                    if (result != null) {
140:                        return result;
141:                    }
142:                    return context.getServletContext().getAttribute(name);
143:                }
144:                return null;
145:            }
146:
147:            /**
148:             * Get cachable
149:             */
150:            public boolean isCacheable() {
151:                return cachable;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.