Search in sources :

Example 1 with ProviderContainer

use of io.joynr.provider.ProviderContainer in project joynr by bmwcarit.

the class PublicationManagerImpl method entryRemoved.

@Override
public void entryRemoved(String providerParticipantId) {
    stopPublicationByProviderId(providerParticipantId);
    ProviderContainer providerContainer = providerDirectory.get(providerParticipantId);
    if (providerContainer != null) {
        providerContainer.getSubscriptionPublisher().unregisterMulticastListener(multicastListeners.remove(providerParticipantId));
    }
}
Also used : ProviderContainer(io.joynr.provider.ProviderContainer)

Example 2 with ProviderContainer

use of io.joynr.provider.ProviderContainer in project joynr by bmwcarit.

the class DispatcherImplTest method addRequestCallerDoesNotBlock.

@Test
public void addRequestCallerDoesNotBlock() throws InterruptedException, ExecutionException, TimeoutException {
    final Callable<Boolean> stuffToDo = new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            try {
                String requestReplyId = UUID.randomUUID().toString();
                RequestCaller requestCaller = mock(RequestCaller.class);
                AbstractSubscriptionPublisher subscriptionPublisher = mock(AbstractSubscriptionPublisher.class);
                /* setBlockInitialisation to true causes the messageReceiver to block
                     * during startup
                     * The MessageReceiver is invoked by the dispatcher once a request caller
                     * is registered
                     *
                     */
                messageReceiverMock.setBlockOnInitialisation(true);
                requestCallerDirectory.add(requestReplyId, new ProviderContainer("interfaceName", DispatcherImplTest.class, requestCaller, subscriptionPublisher));
            } finally {
                messageReceiverMock.setBlockOnInitialisation(false);
            }
            return true;
        }
    };
    final ExecutorService executor = Executors.newSingleThreadExecutor();
    final Future<Boolean> future = executor.submit(stuffToDo);
    // should not throw a timeout exception
    future.get(1000, TimeUnit.MILLISECONDS);
    verify(messageReceiverMock).start(eq(fixture), any(ReceiverStatusListener.class));
}
Also used : AbstractSubscriptionPublisher(io.joynr.provider.AbstractSubscriptionPublisher) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) Matchers.anyString(org.mockito.Matchers.anyString) ReceiverStatusListener(io.joynr.messaging.ReceiverStatusListener) ProviderContainer(io.joynr.provider.ProviderContainer) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 3 with ProviderContainer

use of io.joynr.provider.ProviderContainer in project joynr by bmwcarit.

the class CapabilitiesRegistrarImpl method registerProvider.

/*
     * (non-Javadoc)
     *
     * @see io.joynr.capabilities.CapabilitiesRegistrar# registerProvider(java.lang.String,
     * io.joynr.provider.JoynrProvider, java.lang.Class)
     */
@Override
public Future<Void> registerProvider(final String domain, Object provider, ProviderQos providerQos) {
    if (providerQos == null) {
        throw new JoynrRuntimeException("providerQos == null. It must not be null");
    }
    ProviderContainer providerContainer = providerContainerFactory.create(provider);
    String participantId = participantIdStorage.getProviderParticipantId(domain, providerContainer.getInterfaceName());
    String defaultPublicKeyId = "";
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(getVersionFromAnnotation(provider.getClass()), domain, providerContainer.getInterfaceName(), participantId, providerQos, System.currentTimeMillis(), System.currentTimeMillis() + defaultExpiryTimeMs, defaultPublicKeyId);
    final boolean isGloballyVisible = (discoveryEntry.getQos().getScope() == ProviderScope.GLOBAL);
    messageRouter.addNextHop(participantId, libjoynrMessagingAddress, isGloballyVisible);
    providerDirectory.add(participantId, providerContainer);
    Callback<Void> callback = new Callback<Void>() {

        @Override
        public void onSuccess(@CheckForNull Void result) {
        }

        @Override
        public void onFailure(JoynrRuntimeException runtimeException) {
            logger.error("Unexpected Error while registering Provider:", runtimeException);
        }
    };
    return localDiscoveryAggregator.add(callback, discoveryEntry);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) Callback(io.joynr.proxy.Callback) CheckForNull(javax.annotation.CheckForNull) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) ProviderContainer(io.joynr.provider.ProviderContainer)

Aggregations

ProviderContainer (io.joynr.provider.ProviderContainer)3 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 ReceiverStatusListener (io.joynr.messaging.ReceiverStatusListener)1 AbstractSubscriptionPublisher (io.joynr.provider.AbstractSubscriptionPublisher)1 Callback (io.joynr.proxy.Callback)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 CheckForNull (javax.annotation.CheckForNull)1 DiscoveryEntry (joynr.types.DiscoveryEntry)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1