Search in sources :

Example 6 with LibjoynrWebSocketRuntimeModule

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

the class WebSocketProviderProxyEnd2EndTest method getRuntime.

@Override
protected JoynrRuntime getRuntime(final Properties joynrConfig, final Module... modules) {
    if (ccJoynrRuntime == null) {
        ccJoynrRuntime = createClusterController(webSocketConfig);
        createdRuntimes.add(ccJoynrRuntime);
    }
    joynrConfig.putAll(webSocketConfig);
    joynrConfig.putAll(baseTestConfig);
    joynrConfig.setProperty(ConfigurableMessagingSettings.PROPERTY_CC_CONNECTION_TYPE, "WEBSOCKET");
    Module modulesWithRuntime = Modules.override(modules).with(Modules.override(new LibjoynrWebSocketRuntimeModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            // shorten reconnect delay to speed up tests
            bind(long.class).annotatedWith(Names.named(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_RECONNECT_DELAY)).toInstance(100L);
        }
    }));
    DummyJoynrApplication application = (DummyJoynrApplication) new JoynrInjectorFactory(joynrConfig, modulesWithRuntime).createApplication(DummyJoynrApplication.class);
    return application.getRuntime();
}
Also used : LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) Module(com.google.inject.Module) CCWebSocketRuntimeModule(io.joynr.runtime.CCWebSocketRuntimeModule) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 7 with LibjoynrWebSocketRuntimeModule

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

Example 8 with LibjoynrWebSocketRuntimeModule

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

the class InitRuntimeTask method doInBackground.

@Override
protected JoynrRuntime doInBackground(Object... params) {
    try {
        Log.d("JAS", "starting joynr runtime");
        publishProgress("Starting joynr runtime...\n");
        // create/make persistence file absolute
        File appWorkingDir = applicationContext.getFilesDir();
        String persistenceFileName = appWorkingDir.getPath() + File.separator + joynrConfig.getProperty(MessagingPropertyKeys.PERSISTENCE_FILE, MessagingPropertyKeys.DEFAULT_PERSISTENCE_FILE);
        joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, persistenceFileName);
        // create/make participant ID persistence file absolute
        String participantIdPersistenceFileName = appWorkingDir.getPath() + File.separator + joynrConfig.getProperty(ConfigurableMessagingSettings.PROPERTY_PARTICIPANTIDS_PERSISISTENCE_FILE, ConfigurableMessagingSettings.DEFAULT_PARTICIPANTIDS_PERSISTENCE_FILE);
        joynrConfig.setProperty(ConfigurableMessagingSettings.PROPERTY_PARTICIPANTIDS_PERSISISTENCE_FILE, participantIdPersistenceFileName);
        publishProgress("Properties loaded\n");
        // Create an injector with all the required custom modules.
        // CCInProcessRuntimeModule is used by default but can be overwritten by custom modules
        Module combinedModules = Modules.override(new LibjoynrWebSocketRuntimeModule()).with(modules);
        Injector injectorA = new JoynrInjectorFactory(joynrConfig, combinedModules).createChildInjector();
        JoynrRuntime runtime = injectorA.getInstance(JoynrRuntime.class);
        if (runtime != null) {
            Log.d("JAS", "joynr runtime started");
        } else {
            Log.e("JAS", "joynr runtime not started");
        }
        publishProgress("joynr runtime started.\n");
        return runtime;
    } catch (Exception e) {
        Log.e("JAS", "joynr runtime not started", e);
        publishProgress(e.getMessage());
    }
    return null;
}
Also used : LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) JoynrRuntime(io.joynr.runtime.JoynrRuntime) Injector(com.google.inject.Injector) Module(com.google.inject.Module) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) File(java.io.File) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Aggregations

Module (com.google.inject.Module)8 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)8 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)7 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)6 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)6 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)6 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)5 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)4 CCWebSocketRuntimeModule (io.joynr.runtime.CCWebSocketRuntimeModule)3 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)3 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)1 AbstractJoynrApplication (io.joynr.runtime.AbstractJoynrApplication)1 JoynrApplication (io.joynr.runtime.JoynrApplication)1 JoynrRuntime (io.joynr.runtime.JoynrRuntime)1 File (java.io.File)1 Properties (java.util.Properties)1