/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @return the {@link MessagingTemplate} instance */ public MessagingTemplate getMessagingTemplate() { if (this.messagingTemplate == null) { synchronized (this) { if (this.messagingTemplate == null) { this.messagingTemplate = new MessagingTemplate(getInputChannel()) { @Override public Message<?> receive() { return receiveAndConvert(Message.class); } @Override public <T> T receiveAndConvert(Class<T> targetClass) { throw new UnsupportedOperationException("The 'receive()/receiveAndConvert()' " + "isn't supported on the 'IntegrationFlow' input channel."); } }; this.messagingTemplate.setBeanFactory(this.beanFactory); } } } return this.messagingTemplate; }
/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @return the {@link MessagingTemplate} instance */ public MessagingTemplate getMessagingTemplate() { if (this.messagingTemplate == null) { synchronized (this) { if (this.messagingTemplate == null) { this.messagingTemplate = new MessagingTemplate(getInputChannel()) { @Override public Message<?> receive() { return receiveAndConvert(Message.class); } @Override public <T> T receiveAndConvert(Class<T> targetClass) { throw new UnsupportedOperationException("The 'receive()/receiveAndConvert()' " + "isn't supported on the 'IntegrationFlow' input channel."); } }; this.messagingTemplate.setBeanFactory(this.beanFactory); } } } return this.messagingTemplate; }