Source Code Cross Referenced for PortletConfig.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » cheftool » 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 » ERP CRM Financial » sakai » org.sakaiproject.cheftool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/velocity/tags/sakai_2-4-1/tool/src/java/org/sakaiproject/cheftool/PortletConfig.java $
003:         * $Id: PortletConfig.java 7519 2006-04-09 13:02:00Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.cheftool;
021:
022:        import java.util.Collection;
023:        import java.util.Collections;
024:        import java.util.Enumeration;
025:        import java.util.HashMap;
026:        import java.util.Map;
027:        import java.util.Properties;
028:        import java.util.Set;
029:
030:        import javax.servlet.ServletConfig;
031:
032:        import org.sakaiproject.tool.api.Placement;
033:
034:        /** Provides read access to tool parameters, which are (name, value) pairs.  
035:         * Write access is not allowed.  This provides
036:         * an unmodifiable Map that looks first in the tool configuration, then in 
037:         * the tool registration, then in the servlet configuration.  The values 
038:         * in the tool configuration may have been configured by the end-user,
039:         * the values in the tool registration are defaulted in the tool registration
040:         * file, and the values in the servlet configuration come from web.xml and
041:         * cannot be modified by the user.
042:         */
043:        public class PortletConfig implements  Map {
044:            private ServletConfig m_servletCofig;
045:            private Properties m_toolConfig;
046:            private Properties m_toolReg;
047:            private Placement m_placement;
048:
049:            /** Lazily instantiated map populated from the servlet config, the tool configuration,
050:             * and the tool registration - not modifiable after creation.
051:             */
052:            private Map m_map = null;
053:
054:            PortletConfig(ServletConfig config, Properties toolConfig,
055:                    Properties reg, Placement p) {
056:                m_servletCofig = config;
057:                m_toolConfig = toolConfig;
058:                m_toolReg = reg;
059:                m_placement = p;
060:            }
061:
062:            public String getInitParameter(String name, String dflt) {
063:                String value = getInitParameter(name);
064:
065:                if (value == null) {
066:                    value = dflt;
067:                }
068:
069:                return value;
070:            }
071:
072:            public String getInitParameter(String name) {
073:                String value = null;
074:
075:                // check the tool config if present
076:                if (m_toolConfig != null) {
077:                    value = m_toolConfig.getProperty(name);
078:                }
079:
080:                // check the registration if present and no value so far
081:                if (value == null) {
082:                    if (m_toolReg != null) {
083:                        value = m_toolReg.getProperty(name);
084:                    }
085:                }
086:
087:                // check the servlet config if no value so far
088:                if (value == null) {
089:                    value = m_servletCofig.getInitParameter(name);
090:                }
091:
092:                return value;
093:            }
094:
095:            public Map getInitParameters() {
096:                return getMap();
097:            }
098:
099:            /** Populate the Map, such that (name, value) pairs will be found in this order:
100:             * <ol>
101:             * <li>ToolConfiguration</li>
102:             * <li>ToolRegistration</li>
103:             * <li>ServletConfig</li>
104:             * </ul>
105:             */
106:            private synchronized Map getMap() {
107:                if (m_map != null)
108:                    return m_map;
109:
110:                Map map = new HashMap();
111:
112:                // load up with ServletConfig parameters
113:                Enumeration e = m_servletCofig.getInitParameterNames();
114:                while (e.hasMoreElements()) {
115:                    String name = (String) e.nextElement();
116:                    map.put(name, m_servletCofig.getInitParameter(name));
117:                }
118:
119:                // add ToolRegistration
120:                if (m_toolReg != null) {
121:                    for (e = m_toolReg.propertyNames(); e.hasMoreElements();) {
122:                        String name = (String) e.nextElement();
123:                        map.put(name, m_toolReg.getProperty(name));
124:                    }
125:                }
126:
127:                // add ToolConfiguration
128:                if (m_toolConfig != null) {
129:                    for (Enumeration i = m_toolConfig.propertyNames(); i
130:                            .hasMoreElements();) {
131:                        String name = (String) i.nextElement();
132:                        map.put(name, m_toolConfig.getProperty(name));
133:                    }
134:                }
135:
136:                // ensure that this Map won't get modified past this point
137:                m_map = Collections.unmodifiableMap(map);
138:                return m_map;
139:            }
140:
141:            public String getTitle() {
142:                if (m_placement != null) {
143:                    return m_placement.getTitle();
144:                }
145:
146:                return "";
147:            }
148:
149:            /**
150:             * Special non-jetspeed imitation: get three possible init parameter values:
151:             * [0] from servlet config
152:             * [1] from tool registration
153:             * [2] from tool config
154:             * nulls if not present
155:             */
156:            public String[] get3InitParameter(String name) {
157:                String[] value = new String[3];
158:
159:                // check the tool config if present
160:                if (m_toolConfig != null) {
161:                    value[2] = m_toolConfig.getProperty(name);
162:                }
163:
164:                // check the registration if present
165:                if (m_toolReg != null) {
166:                    value[1] = m_toolReg.getProperty(name);
167:                }
168:
169:                // check the servlet config
170:                value[0] = m_servletCofig.getInitParameter(name);
171:
172:                return value;
173:            }
174:
175:            /** <b>Unsupported operation</b> */
176:            public void clear() {
177:                throw new UnsupportedOperationException();
178:            }
179:
180:            public boolean containsKey(Object key) {
181:                return getMap().containsKey(key);
182:            }
183:
184:            public boolean containsValue(Object value) {
185:                return getMap().containsValue(value);
186:            }
187:
188:            public Set entrySet() {
189:                return getMap().entrySet();
190:            }
191:
192:            public Object get(Object key) {
193:                return getMap().get(key);
194:            }
195:
196:            public boolean isEmpty() {
197:                return getMap().isEmpty();
198:            }
199:
200:            public Set keySet() {
201:                return getMap().keySet();
202:            }
203:
204:            /** <b>Unsupported operation</b> */
205:            public Object put(Object key, Object value) {
206:                throw new UnsupportedOperationException();
207:            }
208:
209:            /** <b>Unsupported operation</b> */
210:            public void putAll(Map t) {
211:                throw new UnsupportedOperationException();
212:            }
213:
214:            /** <b>Unsupported operation</b> */
215:            public Object remove(Object key) {
216:                throw new UnsupportedOperationException();
217:            }
218:
219:            public int size() {
220:                return getMap().size();
221:            }
222:
223:            public Collection values() {
224:                return getMap().values();
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.