Search in sources :

Example 6 with AtmosphereMessagingModule

use of io.joynr.messaging.AtmosphereMessagingModule 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 AtmosphereMessagingModule

use of io.joynr.messaging.AtmosphereMessagingModule 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 AtmosphereMessagingModule

use of io.joynr.messaging.AtmosphereMessagingModule 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 AtmosphereMessagingModule

use of io.joynr.messaging.AtmosphereMessagingModule in project joynr by bmwcarit.

the class HTTPProviderProxyEnd2EndTest method getRuntime.

@Override
protected JoynrRuntime getRuntime(Properties joynrConfig, Module... modules) {
    Module runtimeModule = Modules.override(new CCInProcessRuntimeModule()).with(new AtmosphereMessagingModule());
    Module modulesWithRuntime = Modules.override(modules).with(runtimeModule);
    DummyJoynrApplication application = (DummyJoynrApplication) new JoynrInjectorFactory(joynrConfig, modulesWithRuntime).createApplication(DummyJoynrApplication.class);
    return application.getRuntime();
}
Also used : DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 10 with AtmosphereMessagingModule

use of io.joynr.messaging.AtmosphereMessagingModule in project joynr by bmwcarit.

the class GpsConsumerApplication method main.

/**
 * Main method. This method is responsible for: 1. Instantiating the consumer application. 2. Injecting the instance
 * with Guice bindings 3. Starting the application. 4. Ending the application so that the necessary clean up calls
 * are made.
 *
 * @param args arguments give when calling the main method
 */
public static void main(String[] args) {
    // mvn exec:java -Dexec.classpathScope="test" -Dexec.mainClass="io.joynr.public_examples.android_location_provider.GpsConsumerApplication" -Dexec.args="<provider-domain>"
    if (args.length != 1) {
        LOG.error("USAGE: java {} <provider-domain>", GpsConsumerApplication.class.getName());
        return;
    }
    String providerDomain = args[0];
    LOG.debug("Searching for providers on domain \"{}\"", providerDomain);
    // joynr config properties are used to set joynr configuration at compile time. They are set on the
    // JoynInjectorFactory.
    Properties joynrConfig = new Properties();
    // Set a custom static persistence file (default is joynr.properties in the working dir) to store
    // joynr configuration. It allows for changing the joynr configuration at runtime. Custom persistence
    // files support running the consumer and provider applications from within the same directory.
    joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
    // How to use custom infrastructure elements:
    // 1) Set them programmatically at compile time using the joynr configuration properties at the
    // JoynInjectorFactory. E.g. uncomment the following lines to set a certain joynr server
    // instance.
    // joynrConfig.setProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL, "http://localhost:8080/bounceproxy/");
    // joynrConfig.setProperty(MessagingPropertyKeys.DISCOVERYDIRECTORYURL, "http://localhost:8080/discovery/channels/discoverydirectory_channelid/");
    joynrConfig.setProperty(PROPERTY_JOYNR_DOMAIN_LOCAL, "test_consumer_local_domain");
    // NOTE: When running this application to test the android-location-provider, you must use
    // the concrete hostname (and _not_ localhost) in the bounceproxy URL, since this URL
    // is registered in the global discovery directory and must be resolvable by the Android
    // device.
    // joynrConfig.setProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL, "http://<concrete host>:8080/bounceproxy/");
    // 2) Or set them in the static persistence file (default: joynr.properties in working dir) at
    // runtime. If not available in the working dir, it will be created during the first launch
    // of the application. Copy the following lines to the custom persistence file to set a
    // certain joynr server instance.
    // NOTE: This application uses a custom static persistence file consumer-joynr.properties.
    // Copy the following lines to the custom persistence file to set a certain joynr server
    // instance.
    // joynr.messaging.bounceproxyurl=http://localhost:8080/bounceproxy/
    // joynr.messaging.discoverydirectoryurl=http://localhost:8080/discovery/channels/discoverydirectory_channelid/
    // 3) Or set them in Java System properties.
    // -Djoynr.messaging.bounceProxyUrl=http://localhost:8080/bounceproxy/
    // -Djoynr.messaging.capabilitiesDirectoryUrl=http://localhost:8080/discovery/channels/discoverydirectory_channelid/
    // NOTE:
    // Programmatically set configuration properties override properties set in the static persistence file.
    // Java system properties override both
    // Application-specific configuration properties are injected to the application by setting
    // them on the JoynApplicationModule.
    Properties appConfig = new Properties();
    appConfig.setProperty(APP_CONFIG_PROVIDER_DOMAIN, providerDomain);
    JoynrApplication gpsConsumerApp = new JoynrInjectorFactory(joynrConfig, Modules.override(new CCInProcessRuntimeModule()).with(new AtmosphereMessagingModule())).createApplication(new JoynrApplicationModule(GpsConsumerApplication.class, appConfig));
    gpsConsumerApp.run();
    pressQEnterToContinue();
    gpsConsumerApp.shutdown();
}
Also used : CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Properties(java.util.Properties) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) JoynrApplication(io.joynr.runtime.JoynrApplication) AbstractJoynrApplication(io.joynr.runtime.AbstractJoynrApplication) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Aggregations

AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)13 Module (com.google.inject.Module)10 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)10 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)7 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)6 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)6 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)6 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)5 Properties (java.util.Properties)5 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)4 Injector (com.google.inject.Injector)3 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)3 AbstractModule (com.google.inject.AbstractModule)2 Singleton (com.google.inject.Singleton)2 TypeLiteral (com.google.inject.TypeLiteral)2 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)2 MessagingTestModule (io.joynr.messaging.MessagingTestModule)2 AbstractJoynrApplication (io.joynr.runtime.AbstractJoynrApplication)2 CCWebSocketRuntimeModule (io.joynr.runtime.CCWebSocketRuntimeModule)2 JoynrApplication (io.joynr.runtime.JoynrApplication)2