for (String sourceName : sources) {
ComponentConfiguration comp = compMap.get(sourceName);
if(comp != null) {
SourceConfiguration config = (SourceConfiguration) comp;
Source source = getSourceFactory().create(comp.getComponentName(),
comp.getType());
Configurables.configure(source, config);
Set<String> channelNames = config.getChannels();
List<Channel> channels = new ArrayList<Channel>();
for (String chName : channelNames) {
channels.add(conf.getChannels().get(chName));
}
ChannelSelectorConfiguration selectorConfig =
config.getSelectorConfiguration();
ChannelSelector selector = ChannelSelectorFactory.create(
channels, selectorConfig);
ChannelProcessor channelProcessor = new ChannelProcessor(selector);
Configurables.configure(channelProcessor, config);
source.setChannelProcessor(channelProcessor);
conf.getSourceRunners().put(comp.getComponentName(),
SourceRunner.forSource(source));
}
}
Map<String, Context> sourceContexts = agentConf.getSourceContext();
for (String src : sources) {
Context context = sourceContexts.get(src);
if(context != null){
Source source =
getSourceFactory().create(src,
context.getString(BasicConfigurationConstants.CONFIG_TYPE));
List<Channel> channels = new ArrayList<Channel>();
Configurables.configure(source, context);
String[] channelNames = context.getString(
BasicConfigurationConstants.CONFIG_CHANNELS).split("\\s+");
for (String chName : channelNames) {
channels.add(conf.getChannels().get(chName));
}
Map<String, String> selectorConfig = context.getSubProperties(
BasicConfigurationConstants.CONFIG_SOURCE_CHANNELSELECTOR_PREFIX);
ChannelSelector selector = ChannelSelectorFactory.create(
channels, selectorConfig);
ChannelProcessor channelProcessor = new ChannelProcessor(selector);
Configurables.configure(channelProcessor, context);
source.setChannelProcessor(channelProcessor);
conf.getSourceRunners().put(src,
SourceRunner.forSource(source));
}
}