LibJoynrDbusRuntime::LibJoynrDbusRuntime(QSettings* settings) : LibJoynrRuntime(settings), dbusMessageRouterAdapter(Q_NULLPTR), dbusSettings(new DbusSettings(*settings)), libjoynrMessagingServiceUrl() { dbusSettings->printSettings(); QString messagingUuid = Util::createUuid().replace("-", ""); QString libjoynrMessagingDomain("local"); QString libjoynrMessagingServiceName("io.joynr.libjoynr.Messaging"); QString libjoynrMessagingId("libjoynr.messaging.participantid_" + messagingUuid); libjoynrMessagingServiceUrl = QString( QString("%0:%1:%2").arg(libjoynrMessagingDomain).arg(libjoynrMessagingServiceName).arg( libjoynrMessagingId)); QSharedPointer<joynr::system::QtAddress> libjoynrMessagingAddress( new system::QtCommonApiDbusAddress( libjoynrMessagingDomain, libjoynrMessagingServiceName, libjoynrMessagingId)); // create connection to parent routing service QSharedPointer<joynr::system::QtAddress> ccMessagingAddress(new system::QtCommonApiDbusAddress( dbusSettings->getClusterControllerMessagingDomain(), dbusSettings->getClusterControllerMessagingServiceName(), dbusSettings->getClusterControllerMessagingParticipantId())); LibJoynrRuntime::init( new DbusMessagingStubFactory(), libjoynrMessagingAddress, ccMessagingAddress); }
void JoynrClusterControllerRuntime::initializeAllDependencies() { /** * libjoynr side skeleton & dispatcher * This needs some preparation of libjoynr and clustercontroller parts. */ messagingSettings = new MessagingSettings(*settings); messagingSettings->printSettings(); libjoynrSettings = new LibjoynrSettings(*settings); libjoynrSettings->printSettings(); wsSettings.printSettings(); // Initialise security manager securityManager = new DummyPlatformSecurityManager(); // CAREFUL: the factory creates an old style dispatcher, not the new one! inProcessDispatcher = new InProcessDispatcher(); /* CC */ // create the messaging stub factory MessagingStubFactory* messagingStubFactory = new MessagingStubFactory(); #ifdef USE_DBUS_COMMONAPI_COMMUNICATION messagingStubFactory->registerStubFactory(new DbusMessagingStubFactory()); #endif // USE_DBUS_COMMONAPI_COMMUNICATION messagingStubFactory->registerStubFactory(new InProcessMessagingStubFactory()); // init message router messageRouter = std::shared_ptr<MessageRouter>( new MessageRouter(messagingStubFactory, securityManager)); // provision global capabilities directory std::shared_ptr<joynr::system::RoutingTypes::Address> globalCapabilitiesDirectoryAddress( new system::RoutingTypes::ChannelAddress( messagingSettings->getCapabilitiesDirectoryChannelId())); messageRouter->addProvisionedNextHop(messagingSettings->getCapabilitiesDirectoryParticipantId(), globalCapabilitiesDirectoryAddress); // provision channel url directory std::shared_ptr<joynr::system::RoutingTypes::Address> globalChannelUrlDirectoryAddress( new system::RoutingTypes::ChannelAddress( messagingSettings->getChannelUrlDirectoryChannelId())); messageRouter->addProvisionedNextHop(messagingSettings->getChannelUrlDirectoryParticipantId(), globalChannelUrlDirectoryAddress); // setup CC WebSocket interface WebSocketMessagingStubFactory* wsMessagingStubFactory = new WebSocketMessagingStubFactory(); messagingStubFactory->registerStubFactory(wsMessagingStubFactory); system::RoutingTypes::WebSocketAddress wsAddress = wsSettings.createClusterControllerMessagingAddress(); wsCcMessagingSkeleton = new WebSocketCcMessagingSkeleton(*messageRouter, *wsMessagingStubFactory, wsAddress); /* LibJoynr */ assert(messageRouter); joynrMessageSender = new JoynrMessageSender(messageRouter); joynrDispatcher = new Dispatcher(joynrMessageSender); joynrMessageSender->registerDispatcher(joynrDispatcher); /* CC */ // TODO: libjoynrmessagingskeleton now uses the Dispatcher, should it use the // InprocessDispatcher? libJoynrMessagingSkeleton = std::shared_ptr<InProcessMessagingSkeleton>( new InProcessLibJoynrMessagingSkeleton(joynrDispatcher)); // EndpointAddress to messagingStub is transmitted when a provider is registered // messagingStubFactory->registerInProcessMessagingSkeleton(libJoynrMessagingSkeleton); /** * ClusterController side * */ if (!messageReceiver) { JOYNR_LOG_INFO( logger, "The message receiver supplied is NULL, creating the default MessageReceiver"); messageReceiver = std::shared_ptr<IMessageReceiver>( new HttpReceiver(*messagingSettings, messageRouter)); } std::string channelId = messageReceiver->getReceiveChannelId(); // create message sender if (!messageSender) { JOYNR_LOG_INFO( logger, "The message sender supplied is NULL, creating the default MessageSender"); messageSender = std::shared_ptr<IMessageSender>(new HttpSender( messagingSettings->getBounceProxyUrl(), std::chrono::milliseconds(messagingSettings->getSendMsgMaxTtl()), std::chrono::milliseconds(messagingSettings->getSendMsgRetryInterval()))); } messagingStubFactory->registerStubFactory( new JoynrMessagingStubFactory(messageSender, messageReceiver->getReceiveChannelId())); // joynrMessagingSendSkeleton = new DummyClusterControllerMessagingSkeleton(messageRouter); // ccDispatcher = DispatcherFactory::createDispatcherInSameThread(messagingSettings); // we currently have to use the fake client, because JAVA side is not yet working for // CapabilitiesServer. bool usingRealCapabilitiesClient = /*when switching this to true, turn on the UUID in systemintegrationtests again*/ true; capabilitiesClient = new CapabilitiesClient(channelId); // ownership of this is not transferred // try using the real capabilitiesClient again: // capabilitiesClient = new CapabilitiesClient(channelId);// ownership of this is not // transferred localCapabilitiesDirectory = std::make_shared<LocalCapabilitiesDirectory>( *messagingSettings, capabilitiesClient, *messageRouter); #ifdef USE_DBUS_COMMONAPI_COMMUNICATION dbusSettings = new DbusSettings(*settings); dbusSettings->printSettings(); // register dbus skeletons for capabilities and messaging interfaces std::string ccMessagingAddress(dbusSettings->createClusterControllerMessagingAddressString()); ccDbusMessageRouterAdapter = new DBusMessageRouterAdapter(*messageRouter, ccMessagingAddress); #endif // USE_DBUS_COMMONAPI_COMMUNICATION /** * libJoynr side * */ publicationManager = new PublicationManager(); subscriptionManager = new SubscriptionManager(); inProcessPublicationSender = new InProcessPublicationSender(subscriptionManager); std::shared_ptr<joynr::system::RoutingTypes::Address> libjoynrMessagingAddress( new InProcessMessagingAddress(libJoynrMessagingSkeleton)); // subscriptionManager = new SubscriptionManager(...) inProcessConnectorFactory = new InProcessConnectorFactory( subscriptionManager, publicationManager, inProcessPublicationSender, dynamic_cast<IRequestCallerDirectory*>(inProcessDispatcher)); joynrMessagingConnectorFactory = new JoynrMessagingConnectorFactory(joynrMessageSender, subscriptionManager); connectorFactory = createConnectorFactory(inProcessConnectorFactory, joynrMessagingConnectorFactory); proxyFactory = new ProxyFactory(libjoynrMessagingAddress, connectorFactory, &cache); dispatcherList.push_back(joynrDispatcher); dispatcherList.push_back(inProcessDispatcher); // Set up the persistence file for storing provider participant ids std::string persistenceFilename = libjoynrSettings->getParticipantIdsPersistenceFilename(); participantIdStorage = std::shared_ptr<ParticipantIdStorage>(new ParticipantIdStorage(persistenceFilename)); dispatcherAddress = libjoynrMessagingAddress; discoveryProxy = new LocalDiscoveryAggregator( *dynamic_cast<IRequestCallerDirectory*>(inProcessDispatcher), systemServicesSettings); std::string discoveryProviderParticipantId( systemServicesSettings.getCcDiscoveryProviderParticipantId()); std::shared_ptr<RequestCaller> discoveryRequestCaller( new joynr::system::DiscoveryRequestCaller(localCapabilitiesDirectory)); std::shared_ptr<InProcessAddress> discoveryProviderAddress( new InProcessAddress(discoveryRequestCaller)); joynr::system::DiscoveryInProcessConnector* discoveryInProcessConnector = InProcessConnectorFactoryHelper<joynr::system::IDiscoveryConnector>().create( subscriptionManager, publicationManager, inProcessPublicationSender, std::string(), // can be ignored discoveryProviderParticipantId, discoveryProviderAddress); discoveryProxy->setDiscoveryProxy(discoveryInProcessConnector); capabilitiesRegistrar = new CapabilitiesRegistrar(dispatcherList, *discoveryProxy, libjoynrMessagingAddress, participantIdStorage, dispatcherAddress, messageRouter); joynrDispatcher->registerPublicationManager(publicationManager); joynrDispatcher->registerSubscriptionManager(subscriptionManager); /** * Finish initialising Capabilitiesclient by building a Proxy and passing it */ std::int64_t discoveryMessagesTtl = messagingSettings->getDiscoveryMessagesTtl(); if (usingRealCapabilitiesClient) { ProxyBuilder<infrastructure::GlobalCapabilitiesDirectoryProxy>* capabilitiesProxyBuilder = createProxyBuilder<infrastructure::GlobalCapabilitiesDirectoryProxy>( messagingSettings->getDiscoveryDirectoriesDomain()); DiscoveryQos discoveryQos(10000); discoveryQos.setArbitrationStrategy( DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY); // actually only one provider // should be available std::shared_ptr<infrastructure::GlobalCapabilitiesDirectoryProxy> capabilitiesProxy( capabilitiesProxyBuilder->setMessagingQos(MessagingQos(discoveryMessagesTtl)) ->setCached(true) ->setDiscoveryQos(discoveryQos) ->build()); ((CapabilitiesClient*)capabilitiesClient)->init(capabilitiesProxy); } ProxyBuilder<infrastructure::ChannelUrlDirectoryProxy>* channelUrlDirectoryProxyBuilder = createProxyBuilder<infrastructure::ChannelUrlDirectoryProxy>( messagingSettings->getDiscoveryDirectoriesDomain()); DiscoveryQos discoveryQos(10000); discoveryQos.setArbitrationStrategy( DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY); // actually only one provider // should be available channelUrlDirectoryProxy = std::shared_ptr<infrastructure::ChannelUrlDirectoryProxy>( channelUrlDirectoryProxyBuilder->setMessagingQos(MessagingQos(discoveryMessagesTtl)) ->setCached(true) ->setDiscoveryQos(discoveryQos) ->build()); channelUrlDirectory = std::shared_ptr<ILocalChannelUrlDirectory>( new LocalChannelUrlDirectory(*messagingSettings, channelUrlDirectoryProxy)); messageReceiver->init(channelUrlDirectory); messageSender->init(channelUrlDirectory, *messagingSettings); }