Example usage for com.google.common.util.concurrent AbstractIdleService stopAsync

List of usage examples for com.google.common.util.concurrent AbstractIdleService stopAsync

Introduction

In this page you can find the example usage for com.google.common.util.concurrent AbstractIdleService stopAsync.

Prototype

@Override
public final Service stopAsync() 

Source Link

Usage

From source file:org.grycap.gpf4med.manager.ShutdownHook.java

/**
 * Creates an instance of this class and registers it with the JVM.
 *///from  w  w w  .j  av a2s.c  o m
public ShutdownHook() {
    hook = new Thread() {
        @Override
        public void run() {
            for (final Map.Entry<String, AbstractIdleService> entry : services.entrySet()) {
                final AbstractIdleService service = entry.getValue();
                if (service != null && service.isRunning()) {
                    service.stopAsync().awaitTerminated();
                }
            }
        }
    };
    Runtime.getRuntime().addShutdownHook(hook);
}

From source file:eu.eubrazilcc.lvl.core.ShutdownHook.java

/**
 * Creates an instance of this class and registers it with the JVM.
 */// w  ww .j  av a2s .  c  om
public ShutdownHook() {
    hook = new Thread() {
        @Override
        public void run() {
            for (final Map.Entry<String, AbstractIdleService> entry : services.entrySet()) {
                final AbstractIdleService service = entry.getValue();
                if (service != null && service.isRunning()) {
                    service.stopAsync().awaitTerminated();
                }
            }
        }
    };
    getRuntime().addShutdownHook(hook);
}