Şu satırı dahil ederiz
import com.google.common.util.concurrent.ServiceManager;
startAsync metodu
Örnek
Şöyle yaparız
public class ManagedGuavaServices implements Managed {
@Inject
private ServiceManager serviceManager;
@Inject
public ManagedGuavaServices(ServiceManager serviceManager) {
this.serviceManager = serviceManager;
}
@Override
public void start() throws Exception {
serviceManager.startAsync();
serviceManager.awaitHealthy(2, TimeUnit.SECONDS);
}
@Override
public void stop() throws Exception {
serviceManager.stopAsync();
serviceManager.awaitStopped(2, TimeUnit.SECONDS);
}
}
Hiç yorum yok:
Yorum Gönder