本文整理汇总了Java中com.google.common.util.concurrent.ServiceManager.startAsync方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceManager.startAsync方法的具体用法?Java ServiceManager.startAsync怎么用?Java ServiceManager.startAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.util.concurrent.ServiceManager
的用法示例。
在下文中一共展示了ServiceManager.startAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.google.common.util.concurrent.ServiceManager; //导入方法依赖的package包/类
public static void main(String[] args) {
LOGGER.info("{} {} starting", NAME, VERSION);
Configuration configuration = new Configuration();
try {
configuration = DataBindingUtils.readConfiguration(new File("config.yml"));
} catch (IOException e) {
LOGGER.error("Unable to read configuration, exiting.");
LOGGER.error(e.getMessage());
System.exit(1);
}
final ServiceFactory configurationAwareServiceFactory = new ServiceFactory(configuration);
configurationAwareServiceFactory.initializePlugins();
final ServiceManager serviceManager = new ServiceManager(configurationAwareServiceFactory.getServices());
LOGGER.info("Starting services");
serviceManager.startAsync();
}
示例2: serviceManager
import com.google.common.util.concurrent.ServiceManager; //导入方法依赖的package包/类
/**
* Create a new {@link ServiceManagerIface} that wraps a {@link ServiceManager}.
*
* @param delegate Service manager to delegate to.
* @return A wrapper.
*/
public static ServiceManagerIface serviceManager(final ServiceManager delegate) {
return new ServiceManagerIface() {
@Override
public ServiceManagerIface startAsync() {
delegate.startAsync();
return this;
}
@Override
public void awaitHealthy() {
delegate.awaitHealthy();
}
@Override
public ServiceManagerIface stopAsync() {
delegate.stopAsync();
return this;
}
@Override
public void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
delegate.awaitStopped(timeout, unit);
}
@Override
public ImmutableMultimap<State, Service> servicesByState() {
return delegate.servicesByState();
}
};
}
示例3: getSlayer
import com.google.common.util.concurrent.ServiceManager; //导入方法依赖的package包/类
public static DaemonSlayer getSlayer(NGContext context) {
if (daemonSlayerInstance == null) {
synchronized (DaemonSlayer.class) {
if (daemonSlayerInstance == null) {
DaemonSlayer slayer = new DaemonSlayer(context);
ServiceManager manager = new ServiceManager(ImmutableList.of(slayer));
manager.startAsync();
daemonSlayerInstance = new DaemonSlayerInstance(slayer);
}
}
}
return daemonSlayerInstance.daemonSlayer;
}
示例4: AutoStartInstance
import com.google.common.util.concurrent.ServiceManager; //导入方法依赖的package包/类
public AutoStartInstance(Consumer<String> hangReportConsumer, Duration hangCheckTimeout) {
LOG.info("HangMonitorAutoStart");
hangMonitor = new HangMonitor(hangReportConsumer, hangCheckTimeout);
serviceManager = new ServiceManager(ImmutableList.of(hangMonitor));
serviceManager.startAsync();
}