Search in sources :

Example 6 with DiscoveryScope

use of io.joynr.arbitration.DiscoveryScope in project joynr by bmwcarit.

the class LocalCapabilitiesDirectoryImpl method lookup.

@Override
@CheckForNull
public void lookup(final String participantId, final DiscoveryQos discoveryQos, final CapabilityCallback capabilityCallback) {
    final DiscoveryEntry localDiscoveryEntry = localDiscoveryEntryStore.lookup(participantId, discoveryQos.getCacheMaxAgeMs());
    DiscoveryScope discoveryScope = discoveryQos.getDiscoveryScope();
    switch(discoveryScope) {
        case LOCAL_ONLY:
            if (localDiscoveryEntry != null) {
                capabilityCallback.processCapabilityReceived(CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(true, localDiscoveryEntry));
            } else {
                capabilityCallback.processCapabilityReceived(null);
            }
            break;
        case LOCAL_THEN_GLOBAL:
        case LOCAL_AND_GLOBAL:
            if (localDiscoveryEntry != null) {
                capabilityCallback.processCapabilityReceived(CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(true, localDiscoveryEntry));
            } else {
                asyncGetGlobalCapabilitity(participantId, discoveryQos, capabilityCallback);
            }
            break;
        case GLOBAL_ONLY:
            asyncGetGlobalCapabilitity(participantId, discoveryQos, capabilityCallback);
            break;
        default:
            break;
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DiscoveryScope(io.joynr.arbitration.DiscoveryScope) CheckForNull(javax.annotation.CheckForNull)

Aggregations

DiscoveryScope (io.joynr.arbitration.DiscoveryScope)6 CheckForNull (javax.annotation.CheckForNull)3 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 Promise (io.joynr.provider.Promise)2 Collection (java.util.Collection)2 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)2 DiscoveryEntry (joynr.types.DiscoveryEntry)2 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)2 CommandLineParser (org.apache.commons.cli.CommandLineParser)2 DefaultParser (org.apache.commons.cli.DefaultParser)2 HelpFormatter (org.apache.commons.cli.HelpFormatter)2 Options (org.apache.commons.cli.Options)2 ParseException (org.apache.commons.cli.ParseException)2 Module (com.google.inject.Module)1 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)1 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)1 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)1 AbstractJoynrApplication (io.joynr.runtime.AbstractJoynrApplication)1 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)1