/**
 * Copyright (C) 2012 Ness Computing, Inc.
 *
 * 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.
 */
package com.nesscomputing.event;

import static com.nesscomputing.event.NessEventModule.EVENT_NAME;

import com.nesscomputing.logging.Log;

import java.util.Map;
import java.util.Set;

import javax.annotation.Nonnull;

import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;

@Singleton
public class NessEventSender
{
    private static final Log LOG = Log.findLog();

    private final NessEventConfig eventConfig;

    private final Set<NessEventTransmitter> eventTransmitters = Sets.newHashSet();

    @Inject
    NessEventSender(final NessEventConfig eventConfig)
    {
        this.eventConfig = eventConfig;
    }

    @Inject(optional=true)
    void injectTransmitters(@Named(EVENT_NAME) final Map<String, NessEventTransmitter> eventTransmitters)
    {
        final String [] transports = eventConfig.getTransports();

        for (int i = 0; i < transports.length; i++) {
            if (eventTransmitters.containsKey(transports[i])) {
                this.eventTransmitters.add(eventTransmitters.get(transports[i]));
                LOG.trace("Added %s as an event transport.", transports[i]);
            }
            else {
                LOG.warn("Event transport %s configured but not available.", transports[i]);
            }
        }
    }

    /**
     * Enqueue an event into the messaging system.
     */
    public void enqueue(@Nonnull NessEvent event)
    {
        for (NessEventTransmitter transport : eventTransmitters) {
            transport.transmit(event);
        }
    }
}

@@ -703,47 +703,8 @@
 E;%0A%0A
-import com.nesscomputing.logging.Log;%0A%0A
 impo
@@ -776,16 +776,50 @@
 Nonnull;
+%0Aimport javax.annotation.Nullable;
 %0A%0Aimport
@@ -958,16 +958,55 @@
 Named;%0A%0A
+import com.nesscomputing.logging.Log;%0A%0A
 @Singlet
@@ -1238,16 +1238,23 @@
 ect%0A    
+public 
 NessEven
@@ -1261,16 +1261,26 @@
 tSender(
+@Nullable 
 final Ne
@@ -1465,37 +1465,41 @@
 entTransmitter%3E 
-event
+available
 Transmitters)%0A  
@@ -1494,32 +1494,71 @@
 smitters)%0A    %7B%0A
+        if (eventConfig != null) %7B%0A    
         final St
@@ -1612,24 +1612,28 @@
 );%0A%0A        
+    
 for (int i =
@@ -1678,25 +1678,33 @@
         
+  
+  
 if (
-event
+available
 Transmit
@@ -1750,30 +1750,32 @@
             
-this.e
+    addE
 ventTransmit
@@ -1781,19 +1781,18 @@
 tter
-s.add(event
+(available
 Tran
@@ -1821,16 +1821,20 @@
 s%5Bi%5D));%0A
+    
         
@@ -1906,34 +1906,42 @@
 %5D);%0A            
-%7D%0A
+    %7D%0A    
             else
@@ -1955,24 +1955,28 @@
             
+  
+  
 LOG.warn(%22Ev
@@ -2056,19 +2056,347 @@
     
-%7D%0A        %7D
+    %7D%0A            %7D%0A        %7D%0A        else %7B%0A            LOG.warn(%22Event config is null but transports were injected!%22);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Add a new transmitter to this sender.%0A     */%0A    public void addEventTransmitter(final NessEventTransmitter eventTransmitter)%0A    %7B%0A        this.eventTransmitters.add(eventTransmitter);
 %0A   

Make NessEventSender c'tor public. Allow explicit addition of transmitters.