package io.joynr.messaging;

import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.name.Names;

/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2013 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import io.joynr.dispatcher.ServletMessageReceiver;
import io.joynr.dispatcher.ServletMessageReceiverImpl;
import io.joynr.messaging.channel.ChannelMessagingSkeleton;
import joynr.system.RoutingTypes.Address;
import joynr.system.RoutingTypes.ChannelAddress;

/**
 * Used in conjunction with DefaultDispatcherModule to inject the application side
 *
 */
public class ServletMessagingModule extends AbstractModule {

    @Override
    protected void configure() {
        install(new HttpMessagingModule());
        bind(MessageListeners.class).to(MessageListenersImpl.class).asEagerSingleton();
        bind(ServletMessageReceiver.class).to(ServletMessageReceiverImpl.class);
        bind(MessageReceiver.class).to(ServletMessageReceiverImpl.class);
        MapBinder<Class<? extends Address>, IMessagingSkeleton> messagingSkeletonFactory;
        messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
        }, new TypeLiteral<IMessagingSkeleton>() {
        }, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
        messagingSkeletonFactory.addBinding(ChannelAddress.class).to(ChannelMessagingSkeleton.class);
    }
}

@@ -147,24 +147,76 @@
 .MapBinder;%0A
+import com.google.inject.multibindings.Multibinder;%0A
 import com.g
@@ -240,16 +240,16 @@
 .Names;%0A
-
 %0A/*%0A * #
@@ -1044,16 +1044,129 @@
 eleton;%0A
+import io.joynr.messaging.http.HttpGlobalAddressFactory;%0Aimport io.joynr.messaging.routing.GlobalAddressFactory;%0A
 import j
@@ -2072,24 +2072,24 @@
 KELETONS));%0A
-
         mess
@@ -2173,21 +2173,244 @@
 eton.class);
+%0A%0A        Multibinder%3CGlobalAddressFactory%3E globalAddresses;%0A        globalAddresses = Multibinder.newSetBinder(binder(), GlobalAddressFactory.class);%0A        globalAddresses.addBinding().to(HttpGlobalAddressFactory.class);
 %0A    %7D%0A%7D%0A

Fix missing global address in ServletModule