use of io.joynr.provider.Promise in project joynr by bmwcarit.
the class DummyCapabilitiesDirectory method lookup.
@Override
public Promise<Lookup1Deferred> lookup(String[] domains, String interfaceName, joynr.types.DiscoveryQos discoveryQos) {
final Lookup1Deferred deferred = new Lookup1Deferred();
CapabilitiesCallback callback = new CapabilitiesCallback() {
@Override
public void processCapabilitiesReceived(@CheckForNull Collection<DiscoveryEntryWithMetaInfo> capabilities) {
if (capabilities != null) {
deferred.resolve(capabilities.toArray(new DiscoveryEntryWithMetaInfo[0]));
} else {
deferred.reject(new ProviderRuntimeException("Received capabilities list was null"));
}
}
@Override
public void onError(Throwable e) {
deferred.reject(new ProviderRuntimeException(e.toString()));
}
};
DiscoveryScope discoveryScope = DiscoveryScope.valueOf(discoveryQos.getDiscoveryScope().name());
lookup(domains, interfaceName, new DiscoveryQos(30000, ArbitrationStrategy.NotSet, discoveryQos.getCacheMaxAge(), discoveryScope), callback);
return new Promise<Lookup1Deferred>(deferred);
}
use of io.joynr.provider.Promise in project joynr by bmwcarit.
the class GlobalDomainRoleControllerProviderImpl method removeDomainRole.
@Override
public Promise<RemoveDomainRoleDeferred> removeDomainRole(String uid, Role role) {
RemoveDomainRoleDeferred deferred = new RemoveDomainRoleDeferred();
boolean removeSuccess = domainAccessStore.removeDomainRole(uid, role);
if (removeSuccess) {
// To notify DRE removal only primary keys (user ID and role) must
// be set. All other fields are undefined.
DomainRoleEntry removedEntry = new DomainRoleEntry(uid, null, role);
fireDomainRoleEntryChanged(ChangeType.REMOVE, removedEntry);
}
deferred.resolve(removeSuccess);
return new Promise<RemoveDomainRoleDeferred>(deferred);
}
use of io.joynr.provider.Promise in project joynr by bmwcarit.
the class MyRadioProvider method shuffleStations.
@Override
public Promise<DeferredVoid> shuffleStations() {
final DeferredVoid deferred = new DeferredVoid();
// actions that take longer must be run in an appliction thread.
// DO NOT block joynr threads
executorService.schedule(new Runnable() {
@Override
public void run() {
RadioStation oldStation = currentStation;
currentStationIndex++;
currentStationIndex = currentStationIndex % stationsList.size();
currentStation = stationsList.get(currentStationIndex);
currentStationChanged(currentStation);
LOG.info(PRINT_BORDER + "shuffleStations: " + oldStation + " -> " + currentStation + PRINT_BORDER);
deferred.resolve();
}
}, DELAY_MS, TimeUnit.MILLISECONDS);
// Promise is returned immediately. Deferred is resolved later
return new Promise<DeferredVoid>(deferred);
}
use of io.joynr.provider.Promise in project joynr by bmwcarit.
the class MyRadioProvider method getLocationOfCurrentStation.
@Override
public Promise<GetLocationOfCurrentStationDeferred> getLocationOfCurrentStation() {
Country country = currentStation.getCountry();
GeoPosition location = countryGeoPositionMap.get(country);
LOG.info(PRINT_BORDER + "getLocationOfCurrentStation: country: " + country.name() + ", location: " + location + PRINT_BORDER);
RadioProvider.GetLocationOfCurrentStationDeferred deferred = new GetLocationOfCurrentStationDeferred();
// actions that take no time can be returned immediately by resolving the deferred.
deferred.resolve(country, location);
return new Promise<RadioProvider.GetLocationOfCurrentStationDeferred>(deferred);
}
use of io.joynr.provider.Promise in project joynr by bmwcarit.
the class CapabilitiesDirectoryImpl method touch.
@Override
public Promise<DeferredVoid> touch(String clusterControllerId) {
DeferredVoid deferred = new DeferredVoid();
discoveryEntryStore.touch(clusterControllerId);
deferred.resolve();
return new Promise<DeferredVoid>(deferred);
}
Aggregations