use of org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider in project controller by opendaylight.
the class ClusterSingletonServiceProviderModule method createInstance.
@Override
public AutoCloseable createInstance() {
final WaitingServiceTracker<ClusterSingletonServiceProvider> tracker = WaitingServiceTracker.create(ClusterSingletonServiceProvider.class, bundleContext);
final ClusterSingletonServiceProvider service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
// instance will be closed via blueprint.
return Reflection.newProxy(AutoCloseableDOMClusterSingletonServiceProvider.class, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (method.getName().equals("close")) {
tracker.close();
return null;
} else {
return method.invoke(service, args);
}
}
});
}
Aggregations