コード例 #1
0
ファイル: JobsPlugin.java プロジェクト: hopcroft/databus
  @Override
  public void onApplicationStop() {

    List<Class> jobs = Play.classloader.getAssignableClasses(Job.class);

    for (final Class clazz : jobs) {
      // @OnApplicationStop
      if (clazz.isAnnotationPresent(OnApplicationStop.class)) {
        try {
          Job<?> job = ((Job<?>) clazz.newInstance());
          scheduledJobs.add(job);
          job.run();
          if (job.wasError) {
            if (job.lastException != null) {
              throw job.lastException;
            }
            throw new RuntimeException("@OnApplicationStop Job has failed");
          }
        } catch (InstantiationException e) {
          throw new UnexpectedException("Job could not be instantiated", e);
        } catch (IllegalAccessException e) {
          throw new UnexpectedException("Job could not be instantiated", e);
        } catch (Throwable ex) {
          if (ex instanceof PlayException) {
            throw (PlayException) ex;
          }
          throw new UnexpectedException(ex);
        }
      }
    }

    executor.shutdownNow();
    executor.getQueue().clear();
  }
コード例 #2
0
  public void contextDestroyed(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    InitFacesContext initContext = null;
    try {
      initContext = new InitFacesContext(context);

      if (webAppListener != null) {
        webAppListener.contextDestroyed(sce);
        webAppListener = null;
      }
      if (webResourcePool != null) {
        webResourcePool.shutdownNow();
      }
      if (!ConfigManager.getInstance().hasBeenInitialized(context)) {
        return;
      }
      GroovyHelper helper = GroovyHelper.getCurrentInstance(context);
      if (helper != null) {
        helper.setClassLoader();
      }
      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(
            Level.FINE, "ConfigureListener.contextDestroyed({0})", context.getServletContextName());
      }

      ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver());
      elctx.putContext(FacesContext.class, initContext);
      initContext.setELContext(elctx);
      Application app = initContext.getApplication();
      app.publishEvent(initContext, PreDestroyApplicationEvent.class, Application.class, app);

      Util.setNonFacesContextApplicationMap(null);

    } catch (Exception e) {
      if (LOGGER.isLoggable(Level.SEVERE)) {
        LOGGER.log(
            Level.SEVERE,
            "Unexpected exception when attempting to tear down the Mojarra runtime",
            e);
      }
    } finally {
      ApplicationAssociate.clearInstance(initContext.getExternalContext());
      ApplicationAssociate.setCurrentInstance(null);
      com.sun.faces.application.ApplicationImpl.clearInstance(initContext.getExternalContext());
      com.sun.faces.application.InjectionApplicationFactory.clearInstance(
          initContext.getExternalContext());
      // Release the initialization mark on this web application
      ConfigManager.getInstance().destory(context);
      if (initContext != null) {
        initContext.release();
      }
      ReflectionUtils.clearCache(Thread.currentThread().getContextClassLoader());
      WebConfiguration.clear(context);
    }
  }
コード例 #3
0
  @AfterClass
  public static void finalization() {

    for (int i = 0; i < serverNumbers; i++) {
      logger.info("Stopping SMPP server " + i + " ...");
      serverArray[i].destroy();
      logger.info("SMPP server " + i + "stopped");
    }
    executor.shutdownNow();
    monitorExecutor.shutdownNow();
    balancer.stop();
    logger.info("Done. Exiting");
  }
コード例 #4
0
ファイル: ThreadPool.java プロジェクト: mehiel/elasticsearch
 public void shutdownNow() {
   estimatedTimeThread.running = false;
   estimatedTimeThread.interrupt();
   scheduler.shutdownNow();
   for (ExecutorHolder executor : executors.values()) {
     if (executor.executor instanceof ThreadPoolExecutor) {
       ((ThreadPoolExecutor) executor.executor).shutdownNow();
     }
   }
   while (!retiredExecutors.isEmpty()) {
     ((ThreadPoolExecutor) retiredExecutors.remove().executor).shutdownNow();
   }
 }
コード例 #5
0
 @Override
 protected void serviceStop() throws Exception {
   if (sched != null) {
     sched.shutdown();
     boolean terminated = false;
     try {
       terminated = sched.awaitTermination(10, SECONDS);
     } catch (InterruptedException e) {
     }
     if (terminated != true) {
       sched.shutdownNow();
     }
   }
   super.serviceStop();
 }
コード例 #6
0
ファイル: SimpleTimer2.java プロジェクト: alexwykoff/i2p
 /** Stops the SimpleTimer. Subsequent executions should not throw a RejectedExecutionException. */
 public void stop() {
   _executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
   _executor.shutdownNow();
 }
コード例 #7
0
 public void shutdown() {
   scheduledThreadPoolExecutor.shutdownNow();
 }
コード例 #8
0
 @Override
 public void onApplicationStop() {
   executor.shutdownNow();
   executor.getQueue().clear();
 }
コード例 #9
0
ファイル: ExecutorService.java プロジェクト: ecmnet/MAVComm
 public static void shutdown() {
   schedThPoolExec.shutdownNow();
 }
コード例 #10
0
ファイル: DefaultScheduler.java プロジェクト: fnegre/exiftool
 // Implement finalizer.
 // This is just a small security to stop scheduled task if
 // instance is garbage collected.
 @Override
 protected void finalize() throws Throwable {
   super.finalize();
   stop();
   executor.shutdownNow();
 }