use of org.springframework.integration.endpoint.IntegrationConsumer in project spring-integration by spring-projects.
the class IntegrationGraphServer method consumers.
private void consumers(Collection<IntegrationNode> nodes, Collection<LinkNode> links, Map<String, MessageChannelNode> channelNodes) {
Map<String, IntegrationConsumer> consumers = this.applicationContext.getBeansOfType(IntegrationConsumer.class);
for (Entry<String, IntegrationConsumer> entry : consumers.entrySet()) {
IntegrationConsumer consumer = entry.getValue();
MessageHandlerNode handlerNode = consumer instanceof PollingConsumer ? this.nodeFactory.polledHandlerNode(entry.getKey(), (PollingConsumer) consumer) : this.nodeFactory.handlerNode(entry.getKey(), consumer);
nodes.add(handlerNode);
MessageChannelNode channelNode = channelNodes.get(handlerNode.getInput());
if (channelNode != null) {
links.add(new LinkNode(channelNode.getNodeId(), handlerNode.getNodeId(), LinkNode.Type.input));
}
producerLink(links, channelNodes, handlerNode);
}
}
use of org.springframework.integration.endpoint.IntegrationConsumer in project spring-integration by spring-projects.
the class MockIntegrationContext method resetBeans.
/**
* Reinstate the mocked beans after execution test to their real state.
* Typically is used from the {@link org.junit.After} method.
* @param beanNames the bean names to reset.
* If {@code null}, all the mocked beans are reset
*/
public void resetBeans(String... beanNames) {
final Collection<String> names;
if (!ObjectUtils.isEmpty(beanNames)) {
names = Arrays.asList(beanNames);
} else {
names = null;
}
this.beans.entrySet().stream().filter(e -> names == null || names.contains(e.getKey())).forEach(e -> {
Object endpoint = this.beanFactory.getBean(e.getKey());
DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(endpoint);
if (endpoint instanceof SourcePollingChannelAdapter) {
directFieldAccessor.setPropertyValue("source", e.getValue());
} else if (endpoint instanceof IntegrationConsumer) {
directFieldAccessor.setPropertyValue("handler", e.getValue());
}
});
}
Aggregations