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));
}
}
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));
}
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);
}
Aggregations