KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > config > RuntimeConfig


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.config;
17
18 import org.apache.myfaces.config.element.ManagedBean;
19 import org.apache.myfaces.config.element.NavigationRule;
20
21 import javax.faces.context.ExternalContext;
22 import java.util.*;
23
24 /**
25  * Holds all configuration information (from the faces-config xml files) that
26  * is needed later during runtime.
27  * The config information in this class is only available to the MyFaces core
28  * implementation classes (i.e. the myfaces source tree). See MyfacesConfig
29  * for config parameters that can be used for shared or component classes.
30  *
31  * @author Manfred Geiler (latest modification by $Author: matze $)
32  * @version $Revision: 1.4 $ $Date: 2004/10/13 11:50:59 $
33  * $Log: RuntimeConfig.java,v $
34  * Revision 1.4 2004/10/13 11:50:59 matze
35  * renamed packages to org.apache
36  *
37  * Revision 1.3 2004/09/08 09:28:56 manolito
38  * moved MyfacesConfig to package config
39  *
40  * Revision 1.2 2004/07/07 08:34:58 mwessendorf
41  * removed unused import-statements
42  *
43  * Revision 1.1 2004/07/07 00:25:05 o_rossmueller
44  * tidy up config/confignew package (moved confignew classes to package config)
45  *
46  * Revision 1.4 2004/07/01 22:05:09 mwessendorf
47  * ASF switch
48  *
49  * Revision 1.3 2004/06/16 23:02:24 o_rossmueller
50  * merged confignew_branch
51  *
52  * Revision 1.2.2.1 2004/06/16 01:25:52 o_rossmueller
53  * refactorings: FactoryFinder, decorator creation, dispenser (removed reverse order)
54  * bug fixes
55  * additional tests
56  *
57  * Revision 1.2 2004/06/08 20:50:09 o_rossmueller
58  * completed configurator
59  *
60  * Revision 1.1 2004/05/17 14:28:28 manolito
61  * new configuration concept
62  *
63  */

64 public class RuntimeConfig
65 {
66     private static final String JavaDoc APPLICATION_MAP_PARAM_NAME = RuntimeConfig.class.getName();
67
68     private Collection _navigationRules = new ArrayList();
69     private Map _managedBeans = new HashMap();
70
71
72     public static RuntimeConfig getCurrentInstance(ExternalContext externalContext)
73     {
74         RuntimeConfig runtimeConfig
75                 = (RuntimeConfig)externalContext.getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
76         if (runtimeConfig == null)
77         {
78             runtimeConfig = new RuntimeConfig();
79             externalContext.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, runtimeConfig);
80         }
81         return runtimeConfig;
82     }
83
84     /**
85      * Return the navigation rules that can be used by the NavigationHandler implementation.
86      * @return a Collection of {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
87      */

88     public Collection getNavigationRules()
89     {
90         return Collections.unmodifiableCollection(_navigationRules);
91     }
92
93     public void addNavigationRule(NavigationRule navigationRule)
94     {
95         _navigationRules.add(navigationRule);
96     }
97
98     /**
99      * Return the managed bean info that can be used by the VariableResolver implementation.
100      * @return a {@link org.apache.myfaces.config.element.ManagedBean ManagedBean}
101      */

102     public ManagedBean getManagedBean(String JavaDoc name)
103     {
104         return (ManagedBean)_managedBeans.get(name);
105     }
106
107     public void addManagedBean(String JavaDoc name, ManagedBean managedBean)
108     {
109         _managedBeans.put(name, managedBean);
110     }
111 }
112
Popular Tags