Search in sources :

Example 41 with DeferredVoid

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);
    }
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryException(io.joynr.exceptions.DiscoveryException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

DeferredVoid (io.joynr.provider.DeferredVoid)41 Promise (io.joynr.provider.Promise)36 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)7 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)5 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)4 JoynrException (io.joynr.exceptions.JoynrException)3 Deferred (io.joynr.provider.Deferred)2 PromiseListener (io.joynr.provider.PromiseListener)2 ApplicationException (joynr.exceptions.ApplicationException)2 StructWithStringArray (joynr.interlanguagetest.namedTypeCollection1.StructWithStringArray)2 DiscoveryEntry (joynr.types.DiscoveryEntry)2 AbstractModule (com.google.inject.AbstractModule)1 TypeLiteral (com.google.inject.TypeLiteral)1 GlobalDiscoveryEntryPersisted (io.joynr.capabilities.GlobalDiscoveryEntryPersisted)1 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)1 JoynrMessageScopeModule (io.joynr.context.JoynrMessageScopeModule)1 MultiReturnValuesContainer (io.joynr.dispatcher.rpc.MultiReturnValuesContainer)1 RequestCaller (io.joynr.dispatching.RequestCaller)1 RequestCallerFactory (io.joynr.dispatching.RequestCallerFactory)1 RequestInterpreter (io.joynr.dispatching.rpc.RequestInterpreter)1