List of usage examples for com.google.common.base Service stop
Future<State> stop();
From source file:com.talvish.tales.services.ServiceHost.java
/** * The standard Java main entry point, which in this case will * instantiate and run the service and then wait for it to be * shutdown.//from ww w .jav a 2s. c om * @param theArgs the arguments containing the start-up or override parameters * @throws Exception any potential uncaught exception */ public static void main(String[] theArgs) throws Exception { logger.info("Service host is initializing."); ConfigurationManager configurationManager = instantiateConfiguration(theArgs); Class<? extends Service> serviceClass = loadServiceClass(configurationManager); Service serviceInstance = instantiateService(serviceClass); // now we have the service create // so let's get it running and wait // for it to finish serviceInstance.start(configurationManager); serviceInstance.run(); serviceInstance.stop(); }
From source file:fathom.Services.java
public synchronized void stop() { // stop the services in the reverse order Collections.reverse(instances); for (Service service : instances) { if (service.isRunning()) { log.info("Stopping service '{}'", service.getClass().getName()); try { service.stop(); } catch (Exception e) { log.error("Failed to stop '{}'", service.getClass().getName(), e); }// w w w. j av a 2 s . co m } } }
From source file:io.datakernel.service.ServiceGraphModule.java
private Service getWorkersServiceOrNull(final Key<?> key, final List<?> instances) { final List<Service> services = new ArrayList<>(); boolean found = false; for (Object instance : instances) { Service service = getServiceOrNull(key, instance); services.add(service);/* ww w. j av a2 s.c o m*/ if (service != null) { found = true; } } if (!found) return null; return new Service() { @Override public ListenableFuture<?> start() { List<ListenableFuture<?>> futures = new ArrayList<>(); for (Service service : services) { futures.add(service != null ? service.start() : null); } return combineFutures(futures, directExecutor()); } @Override public ListenableFuture<?> stop() { List<ListenableFuture<?>> futures = new ArrayList<>(); for (Service service : services) { futures.add(service != null ? service.stop() : null); } return combineFutures(futures, directExecutor()); } }; }