Java Code Examples for com.google.inject.util.Modules#EMPTY_MODULE

The following examples show how to use com.google.inject.util.Modules#EMPTY_MODULE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyRadioProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static Module getRuntimeModule(String transport, String host, int port, Properties joynrConfig) {
    Module runtimeModule;
    if (transport != null) {
        if (transport.contains("websocketcc")) {
            configureWebSocket(host, port, joynrConfig);
            runtimeModule = new CCWebSocketRuntimeModule();
        } else if (transport.contains("websocket")) {
            configureWebSocket(host, port, joynrConfig);
            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")) {
            configureMqtt(joynrConfig);
            backendTransportModules = Modules.combine(backendTransportModules, new HivemqMqttClientModule());
        }
        return Modules.override(runtimeModule).with(backendTransportModules);
    }
    return Modules.override(new CCInProcessRuntimeModule()).with(new HivemqMqttClientModule());
}
 
Example 2
Source File: MyRadioConsumerApplication.java    From joynr with Apache License 2.0 5 votes vote down vote up
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 HivemqMqttClientModule());
        }

        return Modules.override(runtimeModule).with(backendTransportModules);
    }

    return Modules.override(new CCInProcessRuntimeModule()).with(new HivemqMqttClientModule());
}
 
Example 3
Source File: EchoProviderApplication.java    From joynr with Apache License 2.0 5 votes vote down vote up
private static Module getBackendModule() throws Exception {
    Module backendTransportModules = Modules.EMPTY_MODULE;
    switch (invocationParams.getBackendTransportMode()) {
    case MQTT:
        return Modules.combine(backendTransportModules, new HivemqMqttClientModule());
    default:
        throw new Exception("Unknown backend requested");
    }
}
 
Example 4
Source File: ConsumerApplication.java    From joynr with Apache License 2.0 5 votes vote down vote up
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 HivemqMqttClientModule());
            } else {
                // HTTP
                backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
            }
        }

        return Modules.override(runtimeModule).with(backendTransportModules);
    }
 
Example 5
Source File: EmbeddedTitusGateway.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private Module newJettyModule() {
    if (!enableREST) {
        return Modules.EMPTY_MODULE;
    }
    return new EmbeddedJettyModule(httpPort);
}
 
Example 6
Source File: EmbeddedTitusMaster.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private Module newJettyModule() {
    if (!enableREST) {
        return Modules.EMPTY_MODULE;
    }
    return new EmbeddedJettyModule(apiPort);
}
 
Example 7
Source File: ServerProviderConformanceTestTest.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public Module newConfigModule() {
    return Modules.EMPTY_MODULE;
}
 
Example 8
Source File: AbstractJettyTest.java    From attic-aurora with Apache License 2.0 2 votes vote down vote up
/**
 * Subclasses should override with a module that configures the servlets they are testing.
 *
 * @return A module used in the creation of the servlet container's child injector.
 */
protected Function<ServletContext, Module> getChildServletModule() {
  return (servletContext) -> Modules.EMPTY_MODULE;
}