Search in sources :

Example 16 with CCInProcessRuntimeModule

use of io.joynr.runtime.CCInProcessRuntimeModule 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 17 with CCInProcessRuntimeModule

use of io.joynr.runtime.CCInProcessRuntimeModule 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 18 with CCInProcessRuntimeModule

use of io.joynr.runtime.CCInProcessRuntimeModule in project joynr by bmwcarit.

the class HelloWorldJava method main.

public static final void main(String... args) throws InterruptedException {
    JoynrInjectorFactory joynrInjectorFactory = new JoynrInjectorFactory(new CCInProcessRuntimeModule());
    JoynrApplication helloWorldApplication = joynrInjectorFactory.createApplication(HelloWorldApplication.class);
    helloWorldApplication.run();
    // Wait for the application to finish, shutdown and exit
    executionSemaphore.acquire();
    helloWorldApplication.shutdown();
    logger.info("Done.");
}
Also used : CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory) JoynrApplication(io.joynr.runtime.JoynrApplication) AbstractJoynrApplication(io.joynr.runtime.AbstractJoynrApplication)

Example 19 with CCInProcessRuntimeModule

use of io.joynr.runtime.CCInProcessRuntimeModule 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)

Example 20 with CCInProcessRuntimeModule

use of io.joynr.runtime.CCInProcessRuntimeModule 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

CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)20 Module (com.google.inject.Module)17 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)15 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)10 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)8 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)8 Properties (java.util.Properties)8 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)7 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)6 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)6 AbstractModule (com.google.inject.AbstractModule)5 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)5 TestGlobalAddressModule (io.joynr.messaging.routing.TestGlobalAddressModule)5 MqttModule (io.joynr.messaging.mqtt.MqttModule)3 AbstractJoynrApplication (io.joynr.runtime.AbstractJoynrApplication)3 JoynrApplication (io.joynr.runtime.JoynrApplication)3 Before (org.junit.Before)3 CCWebSocketRuntimeModule (io.joynr.runtime.CCWebSocketRuntimeModule)2 ProviderQos (joynr.types.ProviderQos)2 Injector (com.google.inject.Injector)1