use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class MessagingGatewayTests method validateErrorChannelWithSuccessfulReply.
// should not fail but it does now
@Test
public void validateErrorChannelWithSuccessfulReply() {
TestUtils.TestApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
testApplicationContext.refresh();
DirectChannel reqChannel = new DirectChannel();
reqChannel.subscribe(message -> {
throw new RuntimeException("ooops");
});
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyOneWayErrorService());
handler.setBeanFactory(testApplicationContext);
handler.afterPropertiesSet();
errorChannel.subscribe(handler);
this.messagingGateway = new MessagingGatewaySupport() {
};
this.messagingGateway.setRequestChannel(reqChannel);
this.messagingGateway.setErrorChannel(errorChannel);
this.messagingGateway.setReplyChannel(null);
this.messagingGateway.setBeanFactory(mock(BeanFactory.class));
this.messagingGateway.afterPropertiesSet();
this.messagingGateway.start();
this.messagingGateway.send("hello");
testApplicationContext.close();
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class PayloadAndHeaderMappingTests method getHandler.
private ServiceActivatingHandler getHandler(String methodName, Class<?>... types) throws Exception {
ServiceActivatingHandler serviceActivatingHandler = new ServiceActivatingHandler(bean, TestBean.class.getMethod(methodName, types));
serviceActivatingHandler.setBeanFactory(applicationContext);
serviceActivatingHandler.afterPropertiesSet();
return serviceActivatingHandler;
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorFactoryBean method createExpressionEvaluatingHandler.
@Override
protected MessageHandler createExpressionEvaluatingHandler(Expression expression) {
ExpressionEvaluatingMessageProcessor<Object> processor = new ExpressionEvaluatingMessageProcessor<Object>(expression);
processor.setBeanFactory(this.getBeanFactory());
ServiceActivatingHandler handler = new ServiceActivatingHandler(processor);
handler.setPrimaryExpression(expression);
return this.configureHandler(handler);
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorFactoryBean method createMethodInvokingHandler.
@Override
protected MessageHandler createMethodInvokingHandler(Object targetObject, String targetMethodName) {
MessageHandler handler = null;
handler = createDirectHandlerIfPossible(targetObject, targetMethodName);
if (handler == null) {
handler = configureHandler(StringUtils.hasText(targetMethodName) ? new ServiceActivatingHandler(targetObject, targetMethodName) : new ServiceActivatingHandler(targetObject));
}
return handler;
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorAnnotationPostProcessor method createHandler.
@Override
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) {
AbstractReplyProducingMessageHandler serviceActivator;
if (AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
final Object target = this.resolveTargetBeanFromMethodWithBeanAnnotation(method);
serviceActivator = this.extractTypeIfPossible(target, AbstractReplyProducingMessageHandler.class);
if (serviceActivator == null) {
if (target instanceof MessageHandler) {
/*
* Return a reply-producing message handler so that we still get 'produced no reply' messages
* and the super class will inject the advice chain to advise the handler method if needed.
*/
return new ReplyProducingMessageHandlerWrapper((MessageHandler) target);
} else {
serviceActivator = new ServiceActivatingHandler(target);
}
} else {
checkMessageHandlerAttributes(resolveTargetBeanName(method), annotations);
return (MessageHandler) target;
}
} else {
serviceActivator = new ServiceActivatingHandler(bean, method);
}
String requiresReply = MessagingAnnotationUtils.resolveAttribute(annotations, "requiresReply", String.class);
if (StringUtils.hasText(requiresReply)) {
serviceActivator.setRequiresReply(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(requiresReply)));
}
String isAsync = MessagingAnnotationUtils.resolveAttribute(annotations, "async", String.class);
if (StringUtils.hasText(isAsync)) {
serviceActivator.setAsync(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(isAsync)));
}
this.setOutputChannelIfPresent(annotations, serviceActivator);
return serviceActivator;
}
Aggregations