1 52 53 package com.go.teaservlet; 54 55 import java.util.*; 56 import javax.servlet.*; 57 import com.go.trove.log.Log; 58 import com.go.trove.util.PropertyMap; 59 import com.go.trove.util.plugin.Plugin; 60 61 69 class InternalApplicationConfig implements ApplicationConfig { 70 private ApplicationConfig mBaseConfig; 71 private PropertyMap mProperties; 72 private Log mLog; 73 private Map mPluginMap; 74 75 87 public InternalApplicationConfig(ApplicationConfig config, 88 PropertyMap properties, 89 Map plugins, 90 String name) { 91 mBaseConfig = config; 92 mLog = new Log(name, config.getLog()); 93 mLog.applyProperties(properties.subMap("log")); 94 mProperties = new PropertyMap(properties.subMap("init")); 95 96 PropertyMap baseProps = config.getProperties(); 97 String filtered = "applications" + baseProps.getSeparator(); 98 Iterator it = baseProps.keySet().iterator(); 99 while (it.hasNext()) { 100 String key = (String )it.next(); 101 if (!key.startsWith(filtered) && !mProperties.containsKey(key)) { 102 mProperties.put(key, baseProps.get(key)); 103 } 104 } 105 106 mPluginMap = plugins; 107 } 108 109 112 public PropertyMap getProperties() { 113 return mProperties; 114 } 115 116 120 public String getName() { 121 return mLog.getName(); 122 } 123 124 128 public Log getLog() { 129 return mLog; 130 } 131 132 public Plugin getPlugin(String name) { 133 return (Plugin)mPluginMap.get(name); 134 } 135 136 public Map getPlugins() { 137 return mPluginMap; 138 } 139 140 public ServletContext getServletContext() { 141 return mBaseConfig.getServletContext(); 142 } 143 144 public String getInitParameter(String name) { 145 return mProperties.getString(name); 146 } 147 148 public Enumeration getInitParameterNames() { 149 return Collections.enumeration(mProperties.keySet()); 150 } 151 152 public String getServletName() { 153 return mBaseConfig.getServletName(); 154 } 155 } 156
| Popular Tags
|