use of org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method register.
@SuppressWarnings("unchecked")
private <S extends ConsumerEndpointSpec<S, ? extends MessageHandler>> B register(S endpointSpec, Consumer<S> endpointConfigurer) {
if (endpointConfigurer != null) {
endpointConfigurer.accept(endpointSpec);
}
MessageChannel inputChannel = this.currentMessageChannel;
this.currentMessageChannel = null;
if (inputChannel == null) {
inputChannel = new DirectChannel();
this.registerOutputChannelIfCan(inputChannel);
}
Tuple2<ConsumerEndpointFactoryBean, ? extends MessageHandler> factoryBeanTuple2 = endpointSpec.get();
addComponents(endpointSpec.getComponentsToRegister());
if (inputChannel instanceof MessageChannelReference) {
factoryBeanTuple2.getT1().setInputChannelName(((MessageChannelReference) inputChannel).getName());
} else {
if (inputChannel instanceof FixedSubscriberChannelPrototype) {
String beanName = ((FixedSubscriberChannelPrototype) inputChannel).getName();
inputChannel = new FixedSubscriberChannel(factoryBeanTuple2.getT2());
if (beanName != null) {
((FixedSubscriberChannel) inputChannel).setBeanName(beanName);
}
registerOutputChannelIfCan(inputChannel);
}
factoryBeanTuple2.getT1().setInputChannel(inputChannel);
}
return addComponent(endpointSpec).currentComponent(factoryBeanTuple2.getT2());
}
use of org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method registerOutputChannelIfCan.
private B registerOutputChannelIfCan(MessageChannel outputChannel) {
if (!(outputChannel instanceof FixedSubscriberChannelPrototype)) {
this.integrationComponents.put(outputChannel, null);
if (this.currentComponent != null) {
String channelName = null;
if (outputChannel instanceof MessageChannelReference) {
channelName = ((MessageChannelReference) outputChannel).getName();
}
Object currentComponent = this.currentComponent;
if (AopUtils.isAopProxy(currentComponent)) {
currentComponent = extractProxyTarget(currentComponent);
}
if (currentComponent instanceof MessageProducer) {
MessageProducer messageProducer = (MessageProducer) currentComponent;
checkReuse(messageProducer);
if (channelName != null) {
if (messageProducer instanceof AbstractMessageProducingHandler) {
((AbstractMessageProducingHandler) messageProducer).setOutputChannelName(channelName);
} else {
throw new BeanCreationException("The 'currentComponent' (" + currentComponent + ") must extend 'AbstractMessageProducingHandler' " + "for message channel resolution by name.\n" + "Your handler should extend 'AbstractMessageProducingHandler', " + "its subclass 'AbstractReplyProducingMessageHandler', or you should " + "reference a 'MessageChannel' bean instead of its name.");
}
} else {
messageProducer.setOutputChannel(outputChannel);
}
} else if (currentComponent instanceof SourcePollingChannelAdapterSpec) {
SourcePollingChannelAdapterFactoryBean pollingChannelAdapterFactoryBean = ((SourcePollingChannelAdapterSpec) currentComponent).get().getT1();
if (channelName != null) {
pollingChannelAdapterFactoryBean.setOutputChannelName(channelName);
} else {
pollingChannelAdapterFactoryBean.setOutputChannel(outputChannel);
}
} else {
throw new BeanCreationException("The 'currentComponent' (" + currentComponent + ") is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. " + "This is the end of the integration flow.");
}
this.currentComponent = null;
}
}
return _this();
}
Aggregations