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();
}
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());
}
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;
}
Aggregations