/** * Notifies any interested listeners that all ServletContextListeners * of the web module represented by the given WebBundleDescriptor * have been invoked at their contextInitialized method */ void afterServletContextInitializedEvent(WebBundleDescriptor wbd) { events.send(new Event<WebBundleDescriptor>( WebBundleDescriptor.AFTER_SERVLET_CONTEXT_INITIALIZED_EVENT, wbd), false); }
public void stop() { try { env.setStatus(ServerEnvironment.Status.stopped); events.send(new EventListener.Event(EventTypes.SERVER_SHUTDOWN), false); } catch (Exception ex) { Logger.getAnonymousLogger().warning(ex.getMessage()); } } }
public void clean(ExtendedDeploymentContext context) throws Exception { for (EngineRef ref : reversedEngines) { ref.clean(context); } if (events!=null) { events.send(new Event<DeploymentContext>(Deployment.MODULE_CLEANED,context), false); } }
public void stop(ExtendedDeploymentContext context, Logger logger) { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(appClassLoader); context.setClassLoader(appClassLoader); super.stop(context, logger); for (ModuleInfo module : getModuleInfos()) { module.stop(getSubContext(module, context), logger); } if (events!=null) { events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_STOPPED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
public void stop(ExtendedDeploymentContext context, Logger logger) { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(appClassLoader); context.setClassLoader(appClassLoader); super.stop(context, logger); for (ModuleInfo module : reversedModules) { module.stop(getSubContext(module, context), logger); } if (events!=null) { events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_STOPPED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
public void clean(ExtendedDeploymentContext context) throws Exception { for (EngineRef ref : _getEngineRefs()) { ref.clean(context); } if (events!=null) { events.send(new Event<DeploymentContext>(Deployment.MODULE_CLEANED,context), false); } }
public synchronized void stop(ExtendedDeploymentContext context, Logger logger) { if (!started) return; ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(moduleClassLoader); for (EngineRef module : reversedEngines) { try { context.setClassLoader(moduleClassLoader); module.stop(context); } catch(Exception e) { logger.log(Level.SEVERE, "Cannot stop module " + module.getContainerInfo().getSniffer().getModuleType(),e ); } } started=false; if (events!=null) { events.send(new Event<ModuleInfo>(Deployment.MODULE_STOPPED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
@Override public void onError(RunLevelFuture future, ErrorInformation info) { if (future.isDown()) { // TODO: Need a log message logger.log(Level.WARNING, "An error occured when the system was coming down", info.getError()); return; } logger.log(Level.INFO, KernelLoggerInfo.shutdownRequested, info.getError()); if (controller.getCurrentRunLevel() >= InitRunLevel.VAL) { logger.log(Level.SEVERE, KernelLoggerInfo.startupFailure, info.getError()); events.send(new Event(EventTypes.SERVER_SHUTDOWN), false); } forcedShutdown = true; shutdown(); }
public void unload(ExtendedDeploymentContext context) { Logger logger = context.getLogger(); if (!isLoaded) { logger.fine("Application is already unloaded."); return; } ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(appClassLoader); context.setClassLoader(appClassLoader); super.unload(context); for (ModuleInfo module : reversedModules) { module.unload(getSubContext(module, context)); } isLoaded = false; if (events!=null) { events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_UNLOADED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); context.setClassLoader(null); } }
public synchronized void stop(ExtendedDeploymentContext context, Logger logger) { if (!started) return; ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(moduleClassLoader); for (EngineRef module : _getEngineRefs()) { try { context.setClassLoader(moduleClassLoader); module.stop(context); } catch(Exception e) { logger.log(Level.SEVERE, "Cannot stop module " + module.getContainerInfo().getSniffer().getModuleType(),e ); } } started=false; if (events!=null) { events.send(new Event<ModuleInfo>(Deployment.MODULE_STOPPED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
public void unload(ExtendedDeploymentContext context) { Logger logger = context.getLogger(); ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(moduleClassLoader); for (EngineRef engine : reversedEngines) { if (engine.getApplicationContainer()!=null && engine.getApplicationContainer().getClassLoader()!=null) { classLoaders.add(engine.getApplicationContainer().getClassLoader()); try { context.setClassLoader(moduleClassLoader); engine.unload(context); } catch(Throwable e) { logger.log(Level.SEVERE, "Failed to unload from container type : " + engine.getContainerInfo().getSniffer().getModuleType(), e); } } } // add the module classloader to the predestroy list if it's not // already there if (classLoaders != null && moduleClassLoader != null) { classLoaders.add(moduleClassLoader); } if (events!=null) { events.send(new Event<ModuleInfo>(Deployment.MODULE_UNLOADED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); context.setClassLoader(null); } }
public void unload(ExtendedDeploymentContext context) { Logger logger = context.getLogger(); ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(moduleClassLoader); for (EngineRef engine : _getEngineRefs()) { if (engine.getApplicationContainer()!=null && engine.getApplicationContainer().getClassLoader()!=null) { classLoaders.add(engine.getApplicationContainer().getClassLoader()); try { context.setClassLoader(moduleClassLoader); engine.unload(context); } catch(Throwable e) { logger.log(Level.SEVERE, "Failed to unload from container type : " + engine.getContainerInfo().getSniffer().getModuleType(), e); } } } // add the module classloader to the predestroy list if it's not // already there if (classLoaders != null && moduleClassLoader != null) { classLoaders.add(moduleClassLoader); } if (events!=null) { events.send(new Event<ModuleInfo>(Deployment.MODULE_UNLOADED, this), false); } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); context.setClassLoader(null); } }
public void clean(ExtendedDeploymentContext context) throws Exception { // clean the app level classloader if it's not already // cleaned if (appClassLoader != null) { try { PreDestroy.class.cast(appClassLoader).preDestroy(); } catch (Exception e) { // ignore, the class loader does not need to be // explicitely stopped or already stopped } appClassLoader = null; } super.clean(context); for (ModuleInfo info : modules) { info.clean(getSubContext(info,context)); info = null; } if (events!=null) { events.send(new EventListener.Event<DeploymentContext>(Deployment.APPLICATION_CLEANED, context), false); } }
public void undeploy(String appName, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); UndeployCommandParameters params = context.getCommandParameters(UndeployCommandParameters.class); ApplicationInfo info = appRegistry.get(appName); if (info==null) { report.failure(context.getLogger(), "Application " + appName + " not registered", null); events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); return; } events.send(new Event(Deployment.UNDEPLOYMENT_START, info)); // for DAS target, the undeploy should unload the application // as well if (DeploymentUtils.isDASTarget(params.target)) { unload(info, context); } if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) { events.send(new Event(Deployment.UNDEPLOYMENT_SUCCESS, context)); deploymentLifecycleProbeProvider.applicationUndeployedEvent(appName, getApplicationType(info)); } else { events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); } appRegistry.remove(appName); }
public void undeploy(String appName, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); UndeployCommandParameters params = context.getCommandParameters(UndeployCommandParameters.class); ApplicationInfo info = appRegistry.get(appName); if (info==null) { report.failure(context.getLogger(), "Application " + appName + " not registered", null); events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); return; } events.send(new Event(Deployment.UNDEPLOYMENT_START, info)); // for DAS target, the undeploy should unload the application // as well if (DeploymentUtils.isDASTarget(params.target)) { unload(info, context); } if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) { events.send(new Event(Deployment.UNDEPLOYMENT_SUCCESS, context)); deploymentLifecycleProbeProvider.applicationUndeployedEvent(appName, getApplicationType(info)); } else { events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); } appRegistry.remove(appName); }
events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_LOADED, this), false);
public void start( ExtendedDeploymentContext context, ProgressTracker tracker) throws Exception { DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class); if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.START); } super.start(context, tracker); // registers all deployed items. for (ModuleInfo module : getModuleInfos()) { if (tracing!=null) { tracing.addModuleMark(DeploymentTracing.ModuleMark.START, module.getName()); } module.start(getSubContext(module, context), tracker); if (tracing!=null) { tracing.addModuleMark( DeploymentTracing.ModuleMark.STARTED, module.getName()); } } if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.START_EVENTS); } if (events!=null) { events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_STARTED, this), false); } if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.STARTED); } }
public void start( ExtendedDeploymentContext context, ProgressTracker tracker) throws Exception { DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class); if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.START); } super.start(context, tracker); // registers all deployed items. for (ModuleInfo module : getModuleInfos()) { if (tracing!=null) { tracing.addModuleMark(DeploymentTracing.ModuleMark.START, module.getName()); } module.start(getSubContext(module, context), tracker); if (tracing!=null) { tracing.addModuleMark( DeploymentTracing.ModuleMark.STARTED, module.getName()); } } if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.START_EVENTS); } if (events!=null) { events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_STARTED, this), false); } if (tracing!=null) { tracing.addMark(DeploymentTracing.Mark.STARTED); } }
public ApplicationInfo unload(ApplicationInfo info, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); if (info==null) { report.failure(context.getLogger(), "Application not registered", null); return null; } notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.STOP, context); if (info.isLoaded()) { info.stop(context, context.getLogger()); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.STOP, context); notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.UNLOAD, context); info.unload(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.UNLOAD, context); } events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED, info), false); try { notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.CLEAN, context); info.clean(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.CLEAN, context); } catch(Exception e) { report.failure(context.getLogger(), "Exception while cleaning", e); return info; } return info; }
public ApplicationInfo unload(ApplicationInfo info, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); if (info==null) { report.failure(context.getLogger(), "Application not registered", null); return null; } notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.STOP, context); if (info.isLoaded()) { info.stop(context, context.getLogger()); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.STOP, context); notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.UNLOAD, context); info.unload(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.UNLOAD, context); } events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED, info), false); try { notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.CLEAN, context); info.clean(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.CLEAN, context); } catch(Exception e) { report.failure(context.getLogger(), "Exception while cleaning", e); return info; } return info; }