use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class LocalCapabilitiesDirectoryImpl method registerGlobal.
private void registerGlobal(final DiscoveryEntry discoveryEntry, final DeferredVoid deferred) {
synchronized (globalAddressLock) {
try {
globalAddress = globalAddressProvider.get();
} catch (Exception e) {
logger.debug("error getting global address", e);
globalAddress = null;
}
if (globalAddress == null) {
queuedDiscoveryEntries.add(new QueuedDiscoveryEntry(discoveryEntry, deferred));
globalAddressProvider.registerGlobalAddressesReadyListener(this);
return;
}
}
final GlobalDiscoveryEntry globalDiscoveryEntry = CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, globalAddress);
if (globalDiscoveryEntry != null) {
logger.info("starting global registration for " + globalDiscoveryEntry.getDomain() + " : " + globalDiscoveryEntry.getInterfaceName());
globalCapabilitiesDirectoryClient.add(new Callback<Void>() {
@Override
public void onSuccess(Void nothing) {
logger.info("global registration for " + globalDiscoveryEntry.getDomain() + " : " + globalDiscoveryEntry.getInterfaceName() + " completed");
deferred.resolve();
globalDiscoveryEntryCache.add(CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, globalAddress));
}
@Override
public void onFailure(JoynrRuntimeException exception) {
deferred.reject(new ProviderRuntimeException(exception.toString()));
}
}, globalDiscoveryEntry);
}
}
Aggregations