1 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 64 public class RuntimeConfig 65 { 66 private static final String 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 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 102 public ManagedBean getManagedBean(String name) 103 { 104 return (ManagedBean)_managedBeans.get(name); 105 } 106 107 public void addManagedBean(String name, ManagedBean managedBean) 108 { 109 _managedBeans.put(name, managedBean); 110 } 111 } 112 | Popular Tags |