Search in sources :

Example 6 with JsonMessageSerializerModule

use of io.joynr.messaging.JsonMessageSerializerModule in project joynr by bmwcarit.

the class AbstractRuntimeModule method configure.

@Override
protected void configure() {
    requestStaticInjection(CapabilityUtils.class, RpcUtils.class, ArbitratorFactory.class, JoynrDelayMessageException.class, JoynrAppenderManagerFactory.class);
    install(new JsonMessageSerializerModule());
    install(new FactoryModuleBuilder().implement(ProxyInvocationHandler.class, ProxyInvocationHandlerImpl.class).build(ProxyInvocationHandlerFactory.class));
    install(new JoynrMessageScopeModule());
    messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
    }, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
    messagingStubFactory.addBinding(InProcessAddress.class).to(InProcessMessagingStubFactory.class);
    messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<IMessagingSkeleton>() {
    }, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
    messagingSkeletonFactory.addBinding(InProcessAddress.class).to(InProcessLibjoynrMessagingSkeleton.class);
    // other address types must be added to the Multibinder to support global addressing. Created here to make
    // sure the Set exists, even if empty.
    Multibinder.newSetBinder(binder(), new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
    }, Names.named(GlobalAddressProvider.GLOBAL_ADDRESS_PROVIDER));
    Multibinder.newSetBinder(binder(), new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
    }, Names.named(ReplyToAddressProvider.REPLY_TO_ADDRESS_PROVIDER));
    multicastAddressCalculators = Multibinder.newSetBinder(binder(), new TypeLiteral<MulticastAddressCalculator>() {
    });
    bind(ProxyBuilderFactory.class).to(ProxyBuilderFactoryImpl.class);
    bind(RequestReplyManager.class).to(RequestReplyManagerImpl.class);
    bind(SubscriptionManager.class).to(SubscriptionManagerImpl.class);
    bind(PublicationManager.class).to(PublicationManagerImpl.class);
    bind(Dispatcher.class).to(DispatcherImpl.class);
    bind(LocalDiscoveryAggregator.class).in(Singleton.class);
    bind(DiscoveryAsync.class).to(LocalDiscoveryAggregator.class);
    bind(CapabilitiesRegistrar.class).to(CapabilitiesRegistrarImpl.class);
    bind(ParticipantIdStorage.class).to(PropertiesFileParticipantIdStorage.class);
    bind(SubscriptionRequestStorage.class).to(FileSubscriptionRequestStorage.class);
    bind(MessagingSettings.class).to(ConfigurableMessagingSettings.class);
    bind(RoutingTable.class).to(RoutingTableImpl.class).asEagerSingleton();
    bind(MulticastReceiverRegistry.class).to(InMemoryMulticastReceiverRegistry.class).asEagerSingleton();
    bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toProvider(DefaultScheduledExecutorServiceProvider.class);
    bind(StatusReceiver.class).to(DefaultStatusReceiver.class);
    install(new StaticCapabilitiesProvisioningModule());
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(JOYNR_SCHEDULER_CLEANUP)).toProvider(DefaultScheduledExecutorServiceProvider.class);
    Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
    });
}
Also used : PublicationManager(io.joynr.dispatching.subscription.PublicationManager) FileSubscriptionRequestStorage(io.joynr.dispatching.subscription.FileSubscriptionRequestStorage) SubscriptionRequestStorage(io.joynr.dispatching.subscription.SubscriptionRequestStorage) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) Address(joynr.system.RoutingTypes.Address) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) GlobalAddressFactory(io.joynr.messaging.routing.GlobalAddressFactory) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) PropertiesFileParticipantIdStorage(io.joynr.capabilities.PropertiesFileParticipantIdStorage) ParticipantIdStorage(io.joynr.capabilities.ParticipantIdStorage) SubscriptionManager(io.joynr.dispatching.subscription.SubscriptionManager) Dispatcher(io.joynr.dispatching.Dispatcher) NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) RawMessagingPreprocessor(io.joynr.messaging.RawMessagingPreprocessor) StatusReceiver(io.joynr.statusmetrics.StatusReceiver) DefaultStatusReceiver(io.joynr.statusmetrics.DefaultStatusReceiver) MessagingSettings(io.joynr.messaging.MessagingSettings) ConfigurableMessagingSettings(io.joynr.messaging.ConfigurableMessagingSettings) TypeLiteral(com.google.inject.TypeLiteral) RequestReplyManager(io.joynr.dispatching.RequestReplyManager) ProxyInvocationHandlerFactory(io.joynr.proxy.ProxyInvocationHandlerFactory) RoutingTableImpl(io.joynr.messaging.routing.RoutingTableImpl) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) DiscoveryAsync(joynr.system.DiscoveryAsync) CapabilitiesRegistrar(io.joynr.capabilities.CapabilitiesRegistrar) StaticCapabilitiesProvisioningModule(io.joynr.capabilities.StaticCapabilitiesProvisioningModule) InMemoryMulticastReceiverRegistry(io.joynr.messaging.routing.InMemoryMulticastReceiverRegistry) ProxyBuilderFactory(io.joynr.proxy.ProxyBuilderFactory) JoynrMessageScopeModule(io.joynr.context.JoynrMessageScopeModule) LocalDiscoveryAggregator(io.joynr.discovery.LocalDiscoveryAggregator)

Example 7 with JsonMessageSerializerModule

use of io.joynr.messaging.JsonMessageSerializerModule in project joynr by bmwcarit.

the class LongPollingChannelLifecycleTest method setUp.

@Before
public void setUp() throws Exception {
    server = new LocalTestServer(null, null);
    server.register(CHANNELPATH, new HttpRequestHandler() {

        @Override
        public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
            response.setStatusCode(createChannelResponseCode);
            response.setHeader("Location", bounceProxyUrl + "channels/" + channelId);
        }
    });
    server.start();
    serviceAddress = "http://" + server.getServiceAddress().getHostName() + ":" + server.getServiceAddress().getPort();
    bounceProxyUrl = serviceAddress + BOUNCEPROXYPATH;
    Properties properties = new Properties();
    properties.put(MessagingPropertyKeys.CHANNELID, channelId);
    properties.put(MessagingPropertyKeys.BOUNCE_PROXY_URL, bounceProxyUrl);
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        public void configure() {
            bind(HttpRequestFactory.class).to(ApacheHttpRequestFactory.class);
            bind(CloseableHttpClient.class).toProvider(HttpClientProvider.class).in(Singleton.class);
            bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
            bind(MessagingSettings.class).to(ConfigurableMessagingSettings.class);
        }
    }, new JoynrPropertiesModule(properties), new JsonMessageSerializerModule(), new DummyDiscoveryModule());
    longpollingChannelLifecycle = injector.getInstance(LongPollingChannelLifecycle.class);
}
Also used : HttpRequest(org.apache.http.HttpRequest) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) RequestConfig(org.apache.http.client.config.RequestConfig) ConfigurableMessagingSettings(io.joynr.messaging.ConfigurableMessagingSettings) HttpRequestHandler(org.apache.http.protocol.HttpRequestHandler) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) HttpContext(org.apache.http.protocol.HttpContext) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException) Properties(java.util.Properties) DummyDiscoveryModule(io.joynr.capabilities.DummyDiscoveryModule) AbstractModule(com.google.inject.AbstractModule) Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) HttpException(org.apache.http.HttpException) LocalTestServer(org.apache.http.localserver.LocalTestServer) Before(org.junit.Before)

Aggregations

JsonMessageSerializerModule (io.joynr.messaging.JsonMessageSerializerModule)7 AbstractModule (com.google.inject.AbstractModule)6 Before (org.junit.Before)6 TypeLiteral (com.google.inject.TypeLiteral)5 Injector (com.google.inject.Injector)4 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)4 Properties (java.util.Properties)4 Request (joynr.Request)4 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Multibinder (com.google.inject.multibindings.Multibinder)2 JoynrMessageScopeModule (io.joynr.context.JoynrMessageScopeModule)2 ConfigurableMessagingSettings (io.joynr.messaging.ConfigurableMessagingSettings)2 MessagingQos (io.joynr.messaging.MessagingQos)2 InProcessAddress (io.joynr.messaging.inprocess.InProcessAddress)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Reply (joynr.Reply)2 SubscriptionRequest (joynr.SubscriptionRequest)2 Address (joynr.system.RoutingTypes.Address)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1