Search in sources :

Example 11 with MqttPahoModule

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

the class AccessControllerEnd2EndTest method createRuntime.

private JoynrRuntime createRuntime() {
    Properties properties = new Properties();
    properties.put(MqttModule.PROPERTY_KEY_MQTT_BROKER_URI, "tcp://localhost:1883");
    properties.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
    Module module = Modules.override(new CCInProcessRuntimeModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bindConstant().annotatedWith(Names.named(ClusterControllerRuntimeModule.PROPERTY_ACCESSCONTROL_ENABLE)).to(true);
        }
    }, new MqttPahoModule());
    DummyJoynrApplication app = (DummyJoynrApplication) new JoynrInjectorFactory(properties, module).createApplication(DummyJoynrApplication.class);
    return app.getRuntime();
}
Also used : DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Properties(java.util.Properties) Module(com.google.inject.Module) MqttModule(io.joynr.messaging.mqtt.MqttModule) ClusterControllerRuntimeModule(io.joynr.runtime.ClusterControllerRuntimeModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 12 with MqttPahoModule

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

the class MyRadioConsumerApplication method getRuntimeModule.

private static Module getRuntimeModule(String transport, String host, int port, Properties joynrConfig) {
    Module runtimeModule;
    if (transport != null) {
        if (transport.contains("websocket")) {
            joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_HOST, host);
            joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PORT, "" + port);
            joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PROTOCOL, "ws");
            joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PATH, "");
            runtimeModule = new LibjoynrWebSocketRuntimeModule();
        } else {
            runtimeModule = new CCInProcessRuntimeModule();
        }
        Module backendTransportModules = Modules.EMPTY_MODULE;
        if (transport.contains("http")) {
            backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
        }
        if (transport.contains("mqtt")) {
            joynrConfig.put("joynr.messaging.mqtt.brokerUri", "tcp://localhost:1883");
            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 MqttPahoModule());
}
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) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule)

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