1 23 24 37 package com.sun.enterprise.server; 38 39 import java.util.Collection ; 40 import java.util.Iterator ; 41 42 import com.sun.ejb.Container; 43 import com.sun.ejb.ContainerFactory; 44 import com.sun.enterprise.Switch; 45 import com.sun.enterprise.log.Log; 46 47 import com.sun.enterprise.config.serverbeans.Applications; 48 import com.sun.enterprise.config.serverbeans.DasConfig; 49 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 50 import com.sun.enterprise.config.serverbeans.ServerXPathHelper; 51 import com.sun.enterprise.config.ConfigBeansFactory; 52 import com.sun.enterprise.config.ConfigContext; 53 import com.sun.enterprise.config.ConfigException; 54 55 import com.sun.enterprise.instance.InstanceFactory; 56 import com.sun.enterprise.instance.InstanceEnvironment; 57 import com.sun.enterprise.instance.AppsManager; 58 import com.sun.enterprise.instance.EjbModulesManager; 59 import com.sun.enterprise.instance.ConnectorModulesManager; 60 61 import java.util.logging.Level ; 62 import java.util.logging.Logger ; 63 import com.sun.logging.LogDomains; 64 65 import com.sun.enterprise.server.ServerContext; 66 import com.sun.appserv.server.ServerLifecycle; 67 import com.sun.appserv.server.ServerLifecycleException; 68 import com.sun.appserv.server.util.PreprocessorUtil; 69 70 import com.sun.enterprise.resource.ResourceInstaller; 71 78 public class ApplicationLifecycle implements ServerLifecycle { 79 80 93 public void onInitialization(ServerContext sc) 94 throws ServerLifecycleException { 95 96 98 this._context = sc; 99 100 try { 101 103 113 this._applicationMgr = ManagerFactory.getApplicationManager(); 116 117 127 this._ejbMgr = ManagerFactory.getSAEJBModulesManager(); 128 130 this._webMgr = ManagerFactory.getSAWebModulesManager(); 131 132 142 this._connMgr = ManagerFactory.getSAConnectorModulesManager(); 143 144 this._connectorResLoader = new ConnectorResourcesLoader(sc); 145 146 149 this._acMgr = ManagerFactory.getSAACModulesManager(); 150 151 } catch (ConfigException confEx) { 152 _logger.log(Level.SEVERE, 153 "core.config_exception_while_app_loading", confEx); 154 } catch (Throwable th) { 155 _logger.log(Level.SEVERE, 156 "core.unexpected_error_occured_while_app_loading", th); 157 } 158 } 159 160 168 public void onStartup(ServerContext sc) throws ServerLifecycleException { 169 170 try { 171 172 174 this._connectorResLoader.loadRAConfigs(); 175 176 this._connMgr.load(); 182 183 boolean standAloneRarsResources=true; 184 185 this._connectorResLoader.load(standAloneRarsResources); 188 189 ResourceInstaller installer = 191 Switch.getSwitch().getResourceInstaller(); 192 installer.recoverXAResources(); 193 194 this._acMgr.load(); 196 197 this._ejbMgr.load(); 199 200 this._webMgr.load(); 202 203 this._applicationMgr.load(); 205 206 210 211 } catch (Throwable th) { 212 _logger.log(Level.SEVERE, 213 "core.unexpected_error_occured_while_app_loading", th); 214 } 215 } 216 217 226 public void onReady(ServerContext sc) throws ServerLifecycleException { 227 try { 228 ApplicationRegistry registry = ApplicationRegistry.getInstance(); 229 Collection containers = null; 230 231 if (registry != null) { 232 containers = registry.getAllEjbContainers(); 233 } 234 235 if (containers != null) { 238 Iterator iter = containers.iterator(); 239 240 while (iter.hasNext()) { 241 Container container = (Container) iter.next(); 242 243 if (container != null) { 244 container.onReady(); 245 } 246 } 247 } 248 249 _logger.log(Level.FINE, "core.application_onReady_complete"); 250 251 } catch (Throwable th) { 252 _logger.log(Level.SEVERE, 253 "core.unexpected_error_occured_while_app_onready", th); 254 } 255 256 264 ConfigContext configCtx = sc.getConfigContext(); 266 267 Applications applicationsBean = null; 269 270 DasConfig dasConfig = null; 271 272 boolean monitor = false; 274 275 try { 276 281 dasConfig = ServerBeansFactory.getDasConfigBean(configCtx); 282 283 monitor = dasConfig.isDynamicReloadEnabled(); 285 286 } catch (ConfigException ce) { 287 _logger.log(Level.SEVERE, 288 "core.config_exception_while_dynamic_reloading", ce); 289 monitor = false; 290 } 291 292 if (monitor) { 294 ReloadMonitor reloadMonitor = ReloadMonitor.getInstance(2000l); 296 reloadMonitor.start(); 297 } 298 299 332 333 ContainerFactory cf = Switch.getSwitch().getContainerFactory(); 334 try { 335 cf.restoreEJBTimers(); 336 } catch (Exception ex) { 337 _logger.log(Level.SEVERE, 338 "ApplicationLifeCycle.onReady():: exception when calling " + 339 "restoreEJBTimers()", ex); 340 } 341 } 342 343 349 public void onShutdown() throws ServerLifecycleException { 350 351 if (this._applicationMgr == null) { 352 return; 354 } 355 try { 356 _logger.log(Level.INFO, "core.shutting_down_applications"); 357 358 this._applicationMgr.shutdown(); 360 361 ApplicationRegistry registry = ApplicationRegistry.getInstance(); 363 Collection containers = null; 364 365 if (registry != null) { 366 containers = registry.getAllEjbContainers(); 367 } 368 369 if (containers != null) { 372 Iterator iter = containers.iterator(); 373 374 while (iter.hasNext()) { 375 Container container = (Container) iter.next(); 376 377 if (container != null) { 378 container.onShutdown(); 379 } 380 } 381 } 382 383 _logger.log(Level.INFO, "core.shutting_down_resource_adapters"); 390 this._connectorResLoader.stopActiveResourceAdapters(); 391 _logger.log(Level.INFO, "core.ra_shutdown_complete"); 392 393 _logger.log(Level.INFO, "core.application_shutdown_complete"); 394 395 } catch (Throwable th) { 396 _logger.log(Level.SEVERE, 397 "core.unexpected_error_occured_while_app_shutdown", th); 398 } 399 } 400 401 410 public void onTermination() throws ServerLifecycleException { 411 412 try { 413 ApplicationRegistry registry = ApplicationRegistry.getInstance(); 415 Collection containers = null; 416 417 if (registry != null) { 418 containers = registry.getAllEjbContainers(); 419 } 420 421 if (containers != null) { 423 Iterator iter = containers.iterator(); 424 425 while (iter.hasNext()) { 426 Container container = (Container) iter.next(); 427 428 if (container != null) { 429 container.onTermination(); 430 } 431 } 432 } 433 } catch (Throwable th) { 434 _logger.log(Level.SEVERE, 435 "core.unexpected_error_occured_while_app_terminate", th); 436 } 437 } 438 439 protected ServerContext _context = null; 441 protected ApplicationManager _applicationMgr = null; 442 protected StandAloneEJBModulesManager _ejbMgr = null; 443 protected StandAloneConnectorModulesManager _connMgr = null; 444 protected ConnectorResourcesLoader _connectorResLoader= null; 445 protected StandAloneAppClientModulesManager _acMgr = null; 446 protected DummyWebModuleManager _webMgr = null; 447 448 protected static Logger _logger=LogDomains.getLogger(LogDomains.CORE_LOGGER); 449 } 450 | Popular Tags |