private boolean routerAttributesProvided(List<Annotation> annotations) { String defaultOutputChannel = MessagingAnnotationUtils.resolveAttribute(annotations, "defaultOutputChannel", String.class); String[] channelMappings = MessagingAnnotationUtils.resolveAttribute(annotations, "channelMappings", String[].class); String prefix = MessagingAnnotationUtils.resolveAttribute(annotations, "prefix", String.class); String suffix = MessagingAnnotationUtils.resolveAttribute(annotations, "suffix", String.class); String resolutionRequired = MessagingAnnotationUtils.resolveAttribute(annotations, "resolutionRequired", String.class); String applySequence = MessagingAnnotationUtils.resolveAttribute(annotations, "applySequence", String.class); String ignoreSendFailures = MessagingAnnotationUtils.resolveAttribute(annotations, "ignoreSendFailures", String.class); return StringUtils.hasText(defaultOutputChannel) || !ObjectUtils.isEmpty(channelMappings) || StringUtils.hasText(prefix) || StringUtils.hasText(suffix) || StringUtils.hasText(resolutionRequired) || StringUtils.hasText(applySequence) || StringUtils.hasText(ignoreSendFailures); }
protected void setOutputChannelIfPresent(List<Annotation> annotations, AbstractReplyProducingMessageHandler handler) { String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "outputChannel", String.class); if (StringUtils.hasText(outputChannelName)) { handler.setOutputChannelName(outputChannelName); } }
@Override public boolean shouldCreateEndpoint(Method method, List<Annotation> annotations) { boolean isBean = AnnotatedElementUtils.isAnnotated(method, Bean.class.getName()); Assert.isTrue(isBean, "'@BridgeFrom' is eligible only for '@Bean' methods"); boolean isMessageChannelBean = MessageChannel.class.isAssignableFrom(method.getReturnType()); Assert.isTrue(isMessageChannelBean, "'@BridgeFrom' is eligible only for 'MessageChannel' '@Bean' methods"); String channel = MessagingAnnotationUtils.resolveAttribute(annotations, "value", String.class); Assert.isTrue(StringUtils.hasText(channel), "'@BridgeFrom.value()' (inputChannelName) must not be empty"); boolean hasBridgeTo = AnnotatedElementUtils.isAnnotated(method, BridgeTo.class.getName()); Assert.isTrue(!hasBridgeTo, "'@BridgeFrom' and '@BridgeTo' are mutually exclusive 'MessageChannel' " + "'@Bean' method annotations"); return true; }
@Override protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { BridgeHandler handler = new BridgeHandler(); String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "value", String.class); if (StringUtils.hasText(outputChannelName)) { handler.setOutputChannelName(outputChannelName); } return handler; }
protected List<Advice> extractAdviceChain(String beanName, List<Annotation> annotations) { List<Advice> adviceChain = null; String[] adviceChainNames = MessagingAnnotationUtils.resolveAttribute(annotations, ADVICE_CHAIN_ATTRIBUTE, String[].class);
@Override public boolean shouldCreateEndpoint(Method method, List<Annotation> annotations) { String inputChannel = MessagingAnnotationUtils.resolveAttribute(annotations, getInputChannelAttribute(), String.class); boolean createEndpoint = StringUtils.hasText(inputChannel); if (!createEndpoint && beanAnnotationAware()) { boolean isBean = AnnotatedElementUtils.isAnnotated(method, Bean.class.getName()); Assert.isTrue(!isBean, "A channel name in '" + getInputChannelAttribute() + "' is required when " + this.annotationType + " is used on '@Bean' methods."); } return createEndpoint; }
protected AbstractEndpoint doCreateEndpoint(MessageHandler handler, MessageChannel inputChannel, List<Annotation> annotations) { AbstractEndpoint endpoint; if (inputChannel instanceof PollableChannel) { PollingConsumer pollingConsumer = new PollingConsumer((PollableChannel) inputChannel, handler); configurePollingEndpoint(pollingConsumer, annotations); endpoint = pollingConsumer; } else { Poller[] pollers = MessagingAnnotationUtils.resolveAttribute(annotations, "poller", Poller[].class); Assert.state(ObjectUtils.isEmpty(pollers), "A '@Poller' should not be specified for Annotation-based " + "endpoint, since '" + inputChannel + "' is a SubscribableChannel (not pollable)."); if (inputChannel instanceof Publisher) { endpoint = new ReactiveStreamsConsumer(inputChannel, handler); } else { endpoint = new EventDrivenConsumer((SubscribableChannel) inputChannel, handler); } } return endpoint; }
@Override public Object postProcess(Object bean, String beanName, Method method, List<Annotation> annotations) { String channelName = MessagingAnnotationUtils .resolveAttribute(annotations, AnnotationUtils.VALUE, String.class); Assert.hasText(channelName, "The channel ('value' attribute of @InboundChannelAdapter) can't be empty."); MessageSource<?> messageSource = null; try { messageSource = createMessageSource(bean, beanName, method); } catch (NoSuchBeanDefinitionException e) { if (this.logger.isDebugEnabled()) { this.logger.debug("Skipping endpoint creation; " + e.getMessage() + "; perhaps due to some '@Conditional' annotation."); } return null; } SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter(); adapter.setOutputChannelName(channelName); adapter.setSource(messageSource); configurePollingEndpoint(adapter, annotations); return adapter; }
String defaultOutputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "defaultOutputChannel", String.class); if (StringUtils.hasText(defaultOutputChannelName)) { String applySequence = MessagingAnnotationUtils.resolveAttribute(annotations, "applySequence", String.class); if (StringUtils.hasText(applySequence)) { router.setApplySequence(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(applySequence))); String ignoreSendFailures = MessagingAnnotationUtils.resolveAttribute(annotations, "ignoreSendFailures", String.class); if (StringUtils.hasText(ignoreSendFailures)) { String resolutionRequired = MessagingAnnotationUtils.resolveAttribute(annotations, "resolutionRequired", String.class); if (StringUtils.hasText(resolutionRequired)) { String prefix = MessagingAnnotationUtils.resolveAttribute(annotations, "prefix", String.class); if (StringUtils.hasText(prefix)) { methodInvokingRouter.setPrefix(this.beanFactory.resolveEmbeddedValue(prefix)); String suffix = MessagingAnnotationUtils.resolveAttribute(annotations, "suffix", String.class); if (StringUtils.hasText(suffix)) { methodInvokingRouter.setSuffix(this.beanFactory.resolveEmbeddedValue(suffix)); String[] channelMappings = MessagingAnnotationUtils.resolveAttribute(annotations, "channelMappings", String[].class); if (!ObjectUtils.isEmpty(channelMappings)) {
String discardWithinAdvice = MessagingAnnotationUtils.resolveAttribute(annotations, "discardWithinAdvice", String.class); if (StringUtils.hasText(discardWithinAdvice)) { String throwExceptionOnRejection = MessagingAnnotationUtils.resolveAttribute(annotations, "throwExceptionOnRejection", String.class); if (StringUtils.hasText(throwExceptionOnRejection)) { String discardChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "discardChannel", String.class); if (StringUtils.hasText(discardChannelName)) { filter.setDiscardChannelName(discardChannelName);
if (result != null && result instanceof AbstractEndpoint) { AbstractEndpoint endpoint = (AbstractEndpoint) result; String autoStartup = MessagingAnnotationUtils.resolveAttribute(annotations, "autoStartup", String.class); if (StringUtils.hasText(autoStartup)) { String phase = MessagingAnnotationUtils.resolveAttribute(annotations, "phase", String.class); if (StringUtils.hasText(phase)) { phase = getBeanFactory().resolveEmbeddedValue(phase);
protected AbstractEndpoint createEndpoint(MessageHandler handler, Method method, List<Annotation> annotations) { AbstractEndpoint endpoint = null; String inputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, getInputChannelAttribute(), String.class); if (StringUtils.hasText(inputChannelName)) { MessageChannel inputChannel; try { inputChannel = this.channelResolver.resolveDestination(inputChannelName); } catch (DestinationResolutionException e) { if (e.getCause() instanceof NoSuchBeanDefinitionException) { inputChannel = new DirectChannel(); this.beanFactory.registerSingleton(inputChannelName, inputChannel); inputChannel = (MessageChannel) this.beanFactory.initializeBean(inputChannel, inputChannelName); if (this.disposables != null) { this.disposables.add((DisposableBean) inputChannel); } } else { throw e; } } Assert.notNull(inputChannel, "failed to resolve inputChannel '" + inputChannelName + "'"); endpoint = doCreateEndpoint(handler, inputChannel, annotations); } return endpoint; }
@Override protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { String applySequence = MessagingAnnotationUtils.resolveAttribute(annotations, "applySequence", String.class);
correlationStrategy, releaseStrategy); String discardChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "discardChannel", String.class); if (StringUtils.hasText(discardChannelName)) { handler.setDiscardChannelName(discardChannelName); String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "outputChannel", String.class); if (StringUtils.hasText(outputChannelName)) { handler.setOutputChannelName(outputChannelName); String sendPartialResultsOnExpiry = MessagingAnnotationUtils.resolveAttribute(annotations, "sendPartialResultsOnExpiry", String.class); if (sendPartialResultsOnExpiry != null) {
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)));
protected void configurePollingEndpoint(AbstractPollingEndpoint pollingEndpoint, List<Annotation> annotations) { PollerMetadata pollerMetadata; Poller[] pollers = MessagingAnnotationUtils.resolveAttribute(annotations, "poller", Poller[].class); if (!ObjectUtils.isEmpty(pollers)) { Assert.state(pollers.length == 1,
@Override protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { LoggingHandler.Level level = MessagingAnnotationUtils.resolveAttribute(annotations, "level", LoggingHandler.Level.class); LoggingHandler loggingHandler = new LoggingHandler(level.name()); MethodInvokingMessageProcessor<String> processor = new MethodInvokingMessageProcessor<>(bean, method); processor.setBeanFactory(this.beanFactory); loggingHandler.setLogExpression(new FunctionExpression<>(processor::processMessage)); return loggingHandler; }
String sendTimeout = MessagingAnnotationUtils.resolveAttribute(annotations, "sendTimeout", String.class); if (sendTimeout != null) { String resolvedValue = this.beanFactory.resolveEmbeddedValue(sendTimeout);
protected void setOutputChannelIfPresent(List<Annotation> annotations, AbstractReplyProducingMessageHandler handler) { String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "outputChannel", String.class); if (StringUtils.hasText(outputChannelName)) { handler.setOutputChannelName(outputChannelName); } }
@Override protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { BridgeHandler handler = new BridgeHandler(); String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "value", String.class); if (StringUtils.hasText(outputChannelName)) { handler.setOutputChannelName(outputChannelName); } return handler; }