Search in sources :

Example 16 with JoynrInjectorFactory

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

the class IltConsumerTest method getRuntime.

protected static JoynrRuntime getRuntime(Properties joynrConfig, Module... modules) {
    LOG.info("getRuntime: Entering");
    providerDomain = joynrConfig.getProperty("provider.domain");
    LOG.info("getRuntime: providerDomain = " + providerDomain);
    Properties appConfig = new Properties();
    appConfig.setProperty(INTER_LANGUAGE_PROVIDER_DOMAIN, providerDomain);
    Module modulesWithRuntime = getRuntimeModule(joynrConfig);
    IltDummyApplication application = (IltDummyApplication) new JoynrInjectorFactory(joynrConfig, modulesWithRuntime).createApplication(IltDummyApplication.class, appConfig);
    objectMapper = application.getObjectMapper();
    LOG.info("getRuntime: Leaving");
    return application.getRuntime();
}
Also used : Properties(java.util.Properties) 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) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 17 with JoynrInjectorFactory

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

the class EchoProviderApplication method createJoynrApplication.

private static JoynrApplication createJoynrApplication() throws Exception {
    Module runtimeModule = Modules.override(getRuntimeModule()).with(getBackendModule());
    Properties joynrConfig = createJoynrConfig();
    Properties appConfig = createAppConfig();
    JoynrInjectorFactory injectorFactory = new JoynrInjectorFactory(joynrConfig, runtimeModule, new StaticDomainAccessControlProvisioningModule());
    JoynrApplication joynrApplication = injectorFactory.createApplication(new JoynrApplicationModule(EchoProviderApplication.class, appConfig));
    return joynrApplication;
}
Also used : Module(com.google.inject.Module) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) Properties(java.util.Properties) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory) JoynrApplication(io.joynr.runtime.JoynrApplication) AbstractJoynrApplication(io.joynr.runtime.AbstractJoynrApplication)

Example 18 with JoynrInjectorFactory

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

the class ShortCircuitTest method setup.

@Before
public void setup() throws Exception {
    Module runtimeModule = Modules.override(new CCInProcessRuntimeModule()).with(new TestGlobalAddressModule());
    Properties joynrConfig = new Properties();
    DummyJoynrApplication application = (DummyJoynrApplication) new JoynrInjectorFactory(joynrConfig, runtimeModule).createApplication(DummyJoynrApplication.class);
    runtime = application.getRuntime();
    DiscoveryQos discoveryQos = new DiscoveryQos(CONST_DEFAULT_TEST_TIMEOUT, ArbitrationStrategy.HighestPriority, DiscoveryQos.NO_MAX_AGE, DiscoveryScope.LOCAL_ONLY);
    ProxyBuilder<EchoProxy> proxyBuilder = runtime.getProxyBuilder(DOMAIN, EchoProxy.class).setDiscoveryQos(discoveryQos);
    echoProxy = proxyBuilder.build();
    EchoProvider echoProvider = new EchoProviderImpl();
    ProviderQos providerQos = new ProviderQos();
    providerQos.setPriority(System.currentTimeMillis());
    providerQos.setScope(ProviderScope.LOCAL);
    runtime.registerProvider(DOMAIN, echoProvider, providerQos);
    // warmup
    for (int i = 0; i < 100; i++) {
        echoProxy.echoString("warmup");
        echoProxy.echoByteArray(new Byte[1]);
    }
}
Also used : TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) EchoProvider(joynr.tests.performance.EchoProvider) Properties(java.util.Properties) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AbstractModule(com.google.inject.AbstractModule) EchoProxy(joynr.tests.performance.EchoProxy) ProviderQos(joynr.types.ProviderQos) Before(org.junit.Before)

Example 19 with JoynrInjectorFactory

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

the class ConsumerApplication method main.

/**
 * Main method.
 *
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    if (args.length != 1 && args.length != 2) {
        LOG.error("USAGE: java {} <provider-domain> [websocket]", ConsumerApplication.class.getName());
        return;
    }
    String providerDomain = args[0];
    LOG.debug("Searching for providers on domain \"{}\"", providerDomain);
    Properties joynrConfig = new Properties();
    Module runtimeModule = getRuntimeModule(args, joynrConfig);
    LOG.debug("Using the following runtime module: " + runtimeModule.getClass().getSimpleName());
    LOG.debug("Searching for providers on domain \"{}\"", providerDomain);
    joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
    joynrConfig.setProperty(PROPERTY_JOYNR_DOMAIN_LOCAL, providerDomain);
    Properties appConfig = new Properties();
    appConfig.setProperty(SYSTEMINTEGRATIONTEST_PROVIDER_DOMAIN, providerDomain);
    JoynrApplication myConsumerApp = new JoynrInjectorFactory(joynrConfig, runtimeModule).createApplication(new JoynrApplicationModule(ConsumerApplication.class, appConfig));
    myConsumerApp.run();
    myConsumerApp.shutdown();
}
Also used : Properties(java.util.Properties) Module(com.google.inject.Module) LibjoynrWebSocketRuntimeModule(io.joynr.runtime.LibjoynrWebSocketRuntimeModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) WebsocketModule(io.joynr.messaging.websocket.WebsocketModule) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) JoynrApplication(io.joynr.runtime.JoynrApplication) AbstractJoynrApplication(io.joynr.runtime.AbstractJoynrApplication) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 20 with JoynrInjectorFactory

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

the class DefaultJoynrRuntimeFactory method getInjector.

@Override
public Injector getInjector() {
    if (fInjector == null) {
        Module jeeModule = override(new CCInProcessRuntimeModule()).with(new JeeJoynrIntegrationModule(scheduledExecutorService));
        Module finalModule = override(jeeModule).with(new AbstractModule() {

            @Override
            protected void configure() {
                bind(RawMessagingPreprocessor.class).toInstance(rawMessagePreprocessor);
                if (mqttClientIdProvider != null) {
                    bind(MqttClientIdProvider.class).toInstance(mqttClientIdProvider);
                }
                bind(MqttStatusReceiver.class).toInstance(mqttStatusReceiver);
                bind(StatusReceiver.class).toInstance(statusReceiver);
            }
        });
        fInjector = new JoynrInjectorFactory(joynrProperties, new StaticDomainAccessControlProvisioningModule(), getMessageProcessorsModule(), finalModule).getInjector();
    }
    return fInjector;
}
Also used : CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AbstractModule(com.google.inject.AbstractModule) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) AbstractModule(com.google.inject.AbstractModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Aggregations

JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)31 Module (com.google.inject.Module)22 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)21 Properties (java.util.Properties)20 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)11 AbstractJoynrApplication (io.joynr.runtime.AbstractJoynrApplication)11 JoynrApplication (io.joynr.runtime.JoynrApplication)11 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)11 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)10 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)10 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)10 WebsocketModule (io.joynr.messaging.websocket.WebsocketModule)9 AbstractModule (com.google.inject.AbstractModule)7 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)7 CCWebSocketRuntimeModule (io.joynr.runtime.CCWebSocketRuntimeModule)7 Injector (com.google.inject.Injector)5 TestGlobalAddressModule (io.joynr.messaging.routing.TestGlobalAddressModule)5 JoynrRuntime (io.joynr.runtime.JoynrRuntime)5 MqttModule (io.joynr.messaging.mqtt.MqttModule)3 ClusterControllerRuntime (io.joynr.runtime.ClusterControllerRuntime)3