use of org.jboss.as.controller.UninterruptibleCountDownLatch in project wildfly by wildfly.
the class RaOperationUtil method restartIfPresent.
public static ServiceName restartIfPresent(OperationContext context, final String raName, final String id) throws OperationFailedException {
final ServiceName raDeploymentServiceName = ConnectorServices.getDeploymentServiceName(raName, id);
final ServiceRegistry registry = context.getServiceRegistry(true);
ServiceController raServiceController = registry.getService(raDeploymentServiceName);
if (raServiceController != null) {
final org.jboss.msc.service.ServiceController.Mode originalMode = raServiceController.getMode();
final UninterruptibleCountDownLatch latch = new UninterruptibleCountDownLatch(1);
raServiceController.addListener(new LifecycleListener() {
@Override
public void handleEvent(ServiceController controller, LifecycleEvent event) {
latch.awaitUninterruptibly();
if (event == LifecycleEvent.DOWN) {
try {
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, id));
Activation raxml = (Activation) RaxmlController.getValue();
((ResourceAdapterXmlDeploymentService) controller.getService()).setRaxml(raxml);
controller.compareAndSetMode(ServiceController.Mode.NEVER, originalMode);
} finally {
controller.removeListener(this);
}
}
}
});
try {
raServiceController.setMode(ServiceController.Mode.NEVER);
} finally {
latch.countDown();
}
return raDeploymentServiceName;
} else {
return null;
}
}
Aggregations