Source Code Cross Referenced for RuntimeConfig.java in  » J2EE » myfaces-core-1.2.0 » org » apache » myfaces » config » 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 » myfaces core 1.2.0 » org.apache.myfaces.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 The Apache Software Foundation.
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 org.apache.myfaces.config;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.Collections;
021:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import javax.el.CompositeELResolver;
025:        import javax.el.ELResolver;
026:        import javax.el.ExpressionFactory;
027:        import javax.faces.context.ExternalContext;
028:        import javax.faces.el.PropertyResolver;
029:        import javax.faces.el.VariableResolver;
030:
031:        import org.apache.commons.logging.Log;
032:        import org.apache.commons.logging.LogFactory;
033:        import org.apache.myfaces.config.element.ManagedBean;
034:        import org.apache.myfaces.config.element.NavigationRule;
035:        import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
036:
037:        /**
038:         * Holds all configuration information (from the faces-config xml files) that is needed later during runtime. The config
039:         * information in this class is only available to the MyFaces core implementation classes (i.e. the myfaces source
040:         * tree). See MyfacesConfig for config parameters that can be used for shared or component classes.
041:         * 
042:         * @author Manfred Geiler (latest modification by $Author: mbr $)
043:         * @version $Revision: 527076 $ $Date: 2007-04-10 12:01:32 +0200 (Di, 10 Apr 2007) $
044:         */
045:        @SuppressWarnings("deprecation")
046:        public class RuntimeConfig {
047:            private static final Log log = LogFactory
048:                    .getLog(RuntimeConfig.class);
049:
050:            private static final String APPLICATION_MAP_PARAM_NAME = RuntimeConfig.class
051:                    .getName();
052:
053:            private final Collection<NavigationRule> _navigationRules = new ArrayList<NavigationRule>();
054:            private final Map<String, ManagedBean> _managedBeans = new HashMap<String, ManagedBean>();
055:            private boolean _navigationRulesChanged = false;
056:            private final Map<String, ResourceBundle> _resourceBundles = new HashMap<String, ResourceBundle>();
057:
058:            private CompositeELResolver facesConfigElResolvers;
059:            private CompositeELResolver applicationElResolvers;
060:
061:            private VariableResolver _variableResolver;
062:            private PropertyResolver _propertyResolver;
063:
064:            private ExpressionFactory _expressionFactory;
065:
066:            private PropertyResolver _propertyResolverChainHead;
067:
068:            private VariableResolver _variableResolverChainHead;
069:
070:            public static RuntimeConfig getCurrentInstance(
071:                    ExternalContext externalContext) {
072:                RuntimeConfig runtimeConfig = (RuntimeConfig) externalContext
073:                        .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
074:                if (runtimeConfig == null) {
075:                    runtimeConfig = new RuntimeConfig();
076:                    externalContext.getApplicationMap().put(
077:                            APPLICATION_MAP_PARAM_NAME, runtimeConfig);
078:                }
079:                return runtimeConfig;
080:            }
081:
082:            /**
083:             * Return the navigation rules that can be used by the NavigationHandler implementation.
084:             * 
085:             * @return a Collection of {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
086:             */
087:            public Collection<NavigationRule> getNavigationRules() {
088:                return Collections.unmodifiableCollection(_navigationRules);
089:            }
090:
091:            public void addNavigationRule(NavigationRule navigationRule) {
092:                _navigationRules.add(navigationRule);
093:
094:                _navigationRulesChanged = true;
095:            }
096:
097:            public boolean isNavigationRulesChanged() {
098:                return _navigationRulesChanged;
099:            }
100:
101:            public void setNavigationRulesChanged(boolean navigationRulesChanged) {
102:                _navigationRulesChanged = navigationRulesChanged;
103:            }
104:
105:            /**
106:             * Return the managed bean info that can be used by the VariableResolver implementation.
107:             * 
108:             * @return a {@link org.apache.myfaces.config.element.ManagedBean ManagedBean}
109:             */
110:            public ManagedBean getManagedBean(String name) {
111:                return _managedBeans.get(name);
112:            }
113:
114:            public Map<String, ManagedBean> getManagedBeans() {
115:                return Collections.unmodifiableMap(_managedBeans);
116:            }
117:
118:            public void addManagedBean(String name, ManagedBean managedBean) {
119:                _managedBeans.put(name, managedBean);
120:            }
121:
122:            /**
123:             * Return the resourcebundle which was configured in faces config by var name
124:             * 
125:             * @param name
126:             *            the name of the resource bundle (content of var)
127:             * @return the resource bundle or null if not found
128:             */
129:            public ResourceBundle getResourceBundle(String name) {
130:                return _resourceBundles.get(name);
131:            }
132:
133:            /**
134:             * @return the resourceBundles
135:             */
136:            public Map<String, ResourceBundle> getResourceBundles() {
137:                return _resourceBundles;
138:            }
139:
140:            public void addResourceBundle(ResourceBundle bundle) {
141:                if (bundle == null) {
142:                    throw new IllegalArgumentException(
143:                            "bundle must not be null");
144:                }
145:                String var = bundle.getVar();
146:                if (_resourceBundles.containsKey(var) && log.isWarnEnabled()) {
147:                    log.warn("Another resource bundle for var '" + var
148:                            + "' with base name '"
149:                            + _resourceBundles.get(var).getBaseName()
150:                            + "' is already registered. '"
151:                            + _resourceBundles.get(var).getBaseName()
152:                            + "' will be replaced with '"
153:                            + bundle.getBaseName() + "'.");
154:                }
155:                _resourceBundles.put(var, bundle);
156:            }
157:
158:            public void addFacesConfigElResolver(ELResolver resolver) {
159:                if (facesConfigElResolvers == null) {
160:                    facesConfigElResolvers = new org.apache.myfaces.el.CompositeELResolver();
161:                }
162:                facesConfigElResolvers.add(resolver);
163:            }
164:
165:            public ELResolver getFacesConfigElResolvers() {
166:                return facesConfigElResolvers;
167:            }
168:
169:            public void addApplicationElResolver(ELResolver resolver) {
170:                if (applicationElResolvers == null) {
171:                    applicationElResolvers = new org.apache.myfaces.el.CompositeELResolver();
172:                }
173:                applicationElResolvers.add(resolver);
174:            }
175:
176:            public ELResolver getApplicationElResolvers() {
177:                return applicationElResolvers;
178:            }
179:
180:            public void setVariableResolver(VariableResolver variableResolver) {
181:                _variableResolver = variableResolver;
182:            }
183:
184:            public VariableResolver getVariableResolver() {
185:                return _variableResolver;
186:            }
187:
188:            public void setPropertyResolver(PropertyResolver propertyResolver) {
189:                _propertyResolver = propertyResolver;
190:            }
191:
192:            public PropertyResolver getPropertyResolver() {
193:                return _propertyResolver;
194:            }
195:
196:            public ExpressionFactory getExpressionFactory() {
197:                return _expressionFactory;
198:            }
199:
200:            public void setExpressionFactory(ExpressionFactory expressionFactory) {
201:                _expressionFactory = expressionFactory;
202:            }
203:
204:            public void setPropertyResolverChainHead(PropertyResolver resolver) {
205:                _propertyResolverChainHead = resolver;
206:            }
207:
208:            public PropertyResolver getPropertyResolverChainHead() {
209:                return _propertyResolverChainHead;
210:            }
211:
212:            public void setVariableResolverChainHead(VariableResolver resolver) {
213:                _variableResolverChainHead = resolver;
214:            }
215:
216:            public VariableResolver getVariableResolverChainHead() {
217:                return _variableResolverChainHead;
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.