1 64 package com.jcorporate.expresso.kernel; 65 66 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap; 67 import com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig; 68 import com.jcorporate.expresso.kernel.exception.ConfigurationException; 69 import com.jcorporate.expresso.kernel.management.ExpressoRuntimeMap; 70 71 import java.lang.ref.WeakReference ; 72 import java.util.Collections ; 73 import java.util.HashMap ; 74 import java.util.Map ; 75 76 77 83 public class RootContainer extends ContainerComponentBase 84 implements RootContainerInterface { 85 private Boolean showStackTrace; 86 private LogManager logManager = null; 87 private Map setupValues = new HashMap(); 88 private String httpPort; 89 private String servletAPI; 90 private String sslPort; 91 92 96 private java.net.URL servicesFile; 97 98 103 private WeakReference systemConfiguration = null; 104 105 108 public RootContainer() { 109 } 110 111 117 public synchronized void setExpressoServicesConfig(ExpressoServicesConfig theConfig) { 118 this.systemConfiguration = new WeakReference (theConfig); 119 } 120 121 136 public synchronized ExpressoServicesConfig getExpressoServicesConfig() { 137 ExpressoServicesConfig sc; 138 139 if (systemConfiguration.get() == null) { 140 sc = new ExpressoServicesConfig(); 141 sc.setExpressoServicesFile(servicesFile); 142 sc.loadExpressoServices(); 143 systemConfiguration = new WeakReference (sc); 144 } 145 146 return (ExpressoServicesConfig) systemConfiguration.get(); 147 } 148 149 154 public synchronized void setHttpPort(String httpPort) { 155 this.httpPort = httpPort; 156 } 157 158 163 public synchronized String getHttpPort() { 164 return httpPort; 165 } 166 167 172 public synchronized void setLogManager(LogManager newManager) { 173 logManager = newManager; 174 } 175 176 181 public synchronized LogManager getLogManager() { 182 return this.logManager; 183 } 184 185 191 public synchronized void setServicesFileLocation(java.net.URL url) { 192 servicesFile = url; 193 } 194 195 201 public synchronized java.net.URL getServicesFileLocation() { 202 return servicesFile; 203 } 204 205 210 public synchronized void setServletAPI(String servletAPI) { 211 this.servletAPI = servletAPI; 212 } 213 214 219 public synchronized String getServletAPI() { 220 return servletAPI; 221 } 222 223 229 public synchronized String getSetupValue(String key) { 230 return (String ) setupValues.get(key); 231 } 232 233 238 public synchronized Map getSetupValues() { 239 return Collections.synchronizedMap(setupValues); 240 } 241 242 248 public synchronized void setShowStackTrace(Boolean showStackTrace) { 249 if (showStackTrace == null) { 250 this.showStackTrace = Boolean.FALSE; 251 } 252 253 this.showStackTrace = showStackTrace; 254 } 255 256 262 public synchronized Boolean getShowStackTrace() { 263 return showStackTrace; 264 } 265 266 271 public synchronized boolean isShowStackTrace() { 272 return showStackTrace.booleanValue(); 273 } 274 275 280 public synchronized void setSslPort(String sslPort) { 281 this.sslPort = sslPort; 282 } 283 284 290 public synchronized String getSslPort() { 291 return sslPort; 292 } 293 294 301 public synchronized void configure(Configuration newConfig) 302 throws ConfigurationException { 303 Map setupMap = newConfig.getMappedProperties("SetupValue"); 304 305 if (setupMap != null) { 306 setupValues = new ConcurrentReaderHashMap(setupMap); 307 } 308 309 setShowStackTrace((Boolean ) newConfig.get("ShowStackTrace")); 310 311 setHttpPort((String ) newConfig.get("HttpPort")); 312 setServletAPI((String ) newConfig.get("ServletAPI")); 313 setSslPort((String ) newConfig.get("SslPort")); 314 } 315 316 320 public synchronized void destroy() { 321 ExpressoRuntimeMap.unregisterRuntime(this.getExpressoServicesConfig() 322 .getName()); 323 this.getContainerImplementation().destroyContainer(); 324 } 325 326 329 public synchronized void initialize() { 330 return; 331 } 332 333 339 public synchronized void reconfigure(Configuration newConfig) 340 throws ConfigurationException { 341 setShowStackTrace(null); 342 setHttpPort(null); 343 setServletAPI(null); 344 setSslPort(null); 345 setupValues = new HashMap(); 346 configure(newConfig); 347 } 348 } 349 | Popular Tags |