Search in sources :

Example 1 with BeanFactoryChannelResolver

use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.

the class ReactiveStreamsConsumer method onInit.

@Override
protected void onInit() throws Exception {
    super.onInit();
    if (this.errorHandler == null) {
        Assert.notNull(getBeanFactory(), "BeanFactory is required");
        this.errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(getBeanFactory()));
    }
}
Also used : MessagePublishingErrorHandler(org.springframework.integration.channel.MessagePublishingErrorHandler) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver)

Example 2 with BeanFactoryChannelResolver

use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.

the class GatewayProxyFactoryBean method onInit.

@Override
protected void onInit() {
    synchronized (this.initializationMonitor) {
        if (this.initialized) {
            return;
        }
        BeanFactory beanFactory = this.getBeanFactory();
        if (this.channelResolver == null && beanFactory != null) {
            this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
        }
        Class<?> proxyInterface = this.determineServiceInterface();
        Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(proxyInterface);
        for (Method method : methods) {
            MethodInvocationGateway gateway = this.createGatewayForMethod(method);
            this.gatewayMap.put(method, gateway);
        }
        this.serviceProxy = new ProxyFactory(proxyInterface, this).getProxy(this.beanClassLoader);
        if (this.asyncExecutor != null) {
            Callable<String> task = () -> null;
            Future<String> submitType = this.asyncExecutor.submit(task);
            this.asyncSubmitType = submitType.getClass();
            if (this.asyncExecutor instanceof AsyncListenableTaskExecutor) {
                submitType = ((AsyncListenableTaskExecutor) this.asyncExecutor).submitListenable(task);
                this.asyncSubmitListenableType = submitType.getClass();
            }
        }
        this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
        this.initialized = true;
    }
}
Also used : AsyncListenableTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor) ProxyFactory(org.springframework.aop.framework.ProxyFactory) BeanFactory(org.springframework.beans.factory.BeanFactory) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver) Method(java.lang.reflect.Method)

Example 3 with BeanFactoryChannelResolver

use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.

the class PublisherAnnotationAdvisor method setBeanFactory.

@Override
public void setBeanFactory(BeanFactory beanFactory) {
    this.interceptor.setChannelResolver(new BeanFactoryChannelResolver(beanFactory));
    this.interceptor.setBeanFactory(beanFactory);
}
Also used : BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver)

Example 4 with BeanFactoryChannelResolver

use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.

the class MessageBusParserTests method testErrorChannelReference.

@Test
public void testErrorChannelReference() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("messageBusWithErrorChannel.xml", this.getClass());
    BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver(context);
    assertEquals(context.getBean("errorChannel"), resolver.resolveDestination("errorChannel"));
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver) Test(org.junit.Test)

Example 5 with BeanFactoryChannelResolver

use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.

the class MessagingTemplate method setBeanFactory.

/**
 * Overridden to set the destination resolver to a {@link BeanFactoryChannelResolver}.
 */
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    // NOSONAR - non-sync is ok here
    this.beanFactory = beanFactory;
    super.setDestinationResolver(new BeanFactoryChannelResolver(beanFactory));
}
Also used : BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver)

Aggregations

BeanFactoryChannelResolver (org.springframework.integration.support.channel.BeanFactoryChannelResolver)25 Test (org.junit.Test)11 MessageChannel (org.springframework.messaging.MessageChannel)7 ErrorHandlingTaskExecutor (org.springframework.integration.util.ErrorHandlingTaskExecutor)6 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 MessagePublishingErrorHandler (org.springframework.integration.channel.MessagePublishingErrorHandler)5 GenericMessage (org.springframework.messaging.support.GenericMessage)5 DirectChannel (org.springframework.integration.channel.DirectChannel)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 BeanFactory (org.springframework.beans.factory.BeanFactory)3 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)3 DestinationResolutionException (org.springframework.messaging.core.DestinationResolutionException)3 Date (java.util.Date)2 MimeMessage (javax.mail.internet.MimeMessage)2 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)2 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)2 SimpleAsyncTaskExecutor (org.springframework.core.task.SimpleAsyncTaskExecutor)2 Message (org.springframework.messaging.Message)2 MessagingException (org.springframework.messaging.MessagingException)2 PollableChannel (org.springframework.messaging.PollableChannel)2