{
channel_list = new ArrayList<Channel>();
channel_list_map.put(channel_name, channel_list);
}
String channel_class_name = send_to_cfg.getAttribute("channel-class", ServiceChannel.class.getName());
Channel channel;
try
{
Class<Channel> channel_class = (Class<Channel>)ClassUtil.forName(channel_class_name, RuleServiceCallHelper.class);
channel = channel_class.newInstance();
if (channel instanceof Configurable)
{
((Configurable)channel).setConfiguration(send_to_cfg);
}
channel_list.add(channel);
}
catch (ClassNotFoundException cnfe)
{
throw new ConfigurationException("could not find channel-class: " + channel_class_name, cnfe);
}
catch (Exception nsme)
{
throw new ConfigurationException("problem instantiating channel-class: " + channel_class_name, nsme);
}
}
Map<String,Channel> channel_map = new HashMap<String,Channel>();
for (Entry<String,List<Channel>> entry : channel_list_map.entrySet())
{
String channel_name = entry.getKey();
final List<Channel> channel_list = entry.getValue();
int channel_list_size = channel_list.size();
if (channel_list_size == 1)
{
channel_map.put(channel_name, channel_list.get(0));
}
else if (channel_list_size > 1)
{
channel_map.put(channel_name, new Channel() {
public void send(Object object) {
for (Channel channel : channel_list) {
channel.send(object);
}
}
});
}
}