org.glassfish.api.event.Events.send()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.glassfish.api.event.Events.send()方法的一些代码示例,展示了Events.send()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Events.send()方法的具体详情如下:
包路径:org.glassfish.api.event.Events
类名称:Events
方法名:send

Events.send介绍

[英]Sends a event asynchronously
[中]异步发送事件

代码示例

代码示例来源:origin: org.glassfish.web/web-glue

/**
 * 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);
}

代码示例来源:origin: org.glassfish.main.core/kernel

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());
    }
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }        
  
}

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }
}

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }        
  
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }
}

代码示例来源:origin: org.glassfish.main.core/kernel

@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();
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }
}

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }
}

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }
}

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }
}

代码示例来源:origin: fujitsu/launcher

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);
}

代码示例来源:origin: org.glassfish.main.core/kernel

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);
}

代码示例来源:origin: eclipse-ee4j/glassfish

events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_LOADED, this), false);

代码示例来源:origin: org.glassfish.common/internal-api

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);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

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);
  }
}

代码示例来源:origin: fujitsu/launcher

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;
}

代码示例来源:origin: org.glassfish.main.core/kernel

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;
}

相关文章