Search in sources :

Example 6 with MqttPahoModule

use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.

the class IltConsumerTest method getRuntimeModule.

private static Module getRuntimeModule(Properties joynrConfig) {
    LOG.info("getRuntimeModule: Entering");
    Module runtimeModule;
    String transport = System.getProperty("transport");
    if (transport == null) {
        throw new IllegalArgumentException("property \"transport\" not set");
    }
    LOG.info("getRuntimeModule: transport = " + transport);
    if (transport.contains("websocket")) {
        LOG.info("getRuntimeModule: websocket host = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_HOST));
        LOG.info("getRuntimeModule: websocket port = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PORT));
        LOG.info("getRuntimeModule: websocket protocol = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PROTOCOL));
        LOG.info("getRuntimeModule: websocket path = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PATH));
        LOG.info("getRuntimeModule: selecting LibjoynrWebSocketRuntimeModule");
        runtimeModule = new LibjoynrWebSocketRuntimeModule();
    } else {
        LOG.info("getRuntimeModule: selecting CCInProcessRuntimeModule");
        runtimeModule = new CCInProcessRuntimeModule();
    }
    Module backendTransportModules = Modules.EMPTY_MODULE;
    if (transport.contains("http")) {
        LOG.info("getRuntimeModule: using AtmosphereMessagingModule");
        backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
    }
    if (transport.contains("mqtt")) {
        LOG.info("getRuntimeModule: using MqttPahoModule");
        joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
        backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
    }
    LOG.info("getRuntimeModule: Leaving");
    return Modules.override(runtimeModule).with(backendTransportModules);
}
Also used : LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule)

Example 7 with MqttPahoModule

use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.

the class ConsumerApplication method getRuntimeModule.

private static Module getRuntimeModule(Properties joynrConfig) {
    Module runtimeModule;
    Module backendTransportModules = Modules.EMPTY_MODULE;
    if (invocationParameters.getRuntimeMode() == RuntimeConfig.WEBSOCKET) {
        joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_HOST, invocationParameters.getCcHost());
        joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PORT, invocationParameters.getCcPort());
        joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PROTOCOL, "ws");
        joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PATH, "");
        joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
        runtimeModule = new LibjoynrWebSocketRuntimeModule();
    } else {
        runtimeModule = new CCInProcessRuntimeModule();
        if (invocationParameters.getBackendTransportMode() == BackendConfig.MQTT) {
            joynrConfig.put("joynr.messaging.mqtt.brokerUri", invocationParameters.getMqttBrokerUri());
            joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
            backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
        } else {
            // HTTP
            backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
        }
    }
    return Modules.override(runtimeModule).with(backendTransportModules);
}
Also used : LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule)

Example 8 with MqttPahoModule

use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.

the class IltProviderApplication method getRuntimeModule.

private static Module getRuntimeModule(String[] args, Properties joynrConfig) {
    Module runtimeModule;
    if (args.length > 1) {
        String transport = args[1].toLowerCase();
        if (transport.contains("websocketcc")) {
            configureWebSocket(joynrConfig);
            runtimeModule = new CCWebSocketRuntimeModule();
        } else if (transport.contains("websocket")) {
            configureWebSocket(joynrConfig);
            runtimeModule = new LibjoynrWebSocketRuntimeModule();
        } else {
            runtimeModule = new CCInProcessRuntimeModule();
        }
        Module backendTransportModules = Modules.EMPTY_MODULE;
        if (transport.contains("http")) {
            LOG.info("Configuring HTTP...");
            backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
        }
        if (transport.contains("mqtt")) {
            LOG.info("Configuring MQTT...");
            joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
            backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
        }
        return Modules.override(runtimeModule).with(backendTransportModules);
    }
    return Modules.override(new CCInProcessRuntimeModule()).with(new AtmosphereMessagingModule());
}
Also used : LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) CCWebSocketRuntimeModule(io.joynr.runtime.CCWebSocketRuntimeModule) Module(com.google.inject.Module) CCWebSocketRuntimeModule(io.joynr.runtime.CCWebSocketRuntimeModule) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule)

Example 9 with MqttPahoModule

use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.

the class DefaultMqttClientIdProviderTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Properties properties = PropertyLoader.loadProperties(MessagingPropertyKeys.DEFAULT_MESSAGING_PROPERTIES_FILE);
    Module testModule = Modules.override(new MqttPahoModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
            bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
            bind(MessageRouter.class).toInstance(mockMessageRouter);
            bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
        }
    });
    properties.put(MessagingPropertyKeys.RECEIVERID, shortReceiverId);
    Injector injectorWithShortReceiverId = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
    clientIdProviderWithShortReceiverId = injectorWithShortReceiverId.getInstance(MqttClientIdProvider.class);
    properties.put(MessagingPropertyKeys.RECEIVERID, longReceiverId);
    Injector injectorWithLongReceiverId = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
    clientIdProviderWithLongReceiverId = injectorWithLongReceiverId.getInstance(MqttClientIdProvider.class);
    properties.put(MessagingPropertyKeys.RECEIVERID, standardReceiverId);
    Injector injectorWithoutClientIdPrefix = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
    clientIdProviderWithoutClientIdPrefix = injectorWithoutClientIdPrefix.getInstance(MqttClientIdProvider.class);
    properties.put(MqttModule.PROPERTY_KEY_MQTT_CLIENT_ID_PREFIX, clientIdPrefix);
    Injector injectorWithClientIdPrefix = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
    clientIdProviderWithClientIdPrefix = injectorWithClientIdPrefix.getInstance(MqttClientIdProvider.class);
}
Also used : NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) Injector(com.google.inject.Injector) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) Properties(java.util.Properties) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) Module(com.google.inject.Module) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 10 with MqttPahoModule

use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.

the class DefaultMqttTopicPrefixProviderTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Properties properties = PropertyLoader.loadProperties(MessagingPropertyKeys.DEFAULT_MESSAGING_PROPERTIES_FILE);
    properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_MULTICAST, expectedMulticastPrefix);
    properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_REPLYTO, expectedReplyToPrefix);
    properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_UNICAST, expectedUnicastPrefix);
    Module testModule = Modules.override(new MqttPahoModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
            bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
            bind(MessageRouter.class).toInstance(mockMessageRouter);
            bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
        }
    });
    Injector injector = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
    mqttTopicProviderInstance = injector.getInstance(MqttTopicPrefixProvider.class);
}
Also used : NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) Injector(com.google.inject.Injector) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) Properties(java.util.Properties) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) Module(com.google.inject.Module) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Aggregations

MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)12 Module (com.google.inject.Module)11 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)8 Properties (java.util.Properties)7 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)6 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)6 AbstractModule (com.google.inject.AbstractModule)5 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)5 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)4 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)4 Injector (com.google.inject.Injector)3 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)3 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)3 MqttModule (io.joynr.messaging.mqtt.MqttModule)3 CCWebSocketRuntimeModule (io.joynr.runtime.CCWebSocketRuntimeModule)3 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)2 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)2 NoOpRawMessagingPreprocessor (io.joynr.messaging.NoOpRawMessagingPreprocessor)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Before (org.junit.Before)2