Java Code Examples for org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory

The following examples show how to use org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * This operations ensures that required dependencies are not accidentally injected
 * early given that this bean is BPP.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void injectAndPostProcessDependencies() {
	Collection<StreamListenerParameterAdapter> streamListenerParameterAdapters = this.applicationContext
			.getBeansOfType(StreamListenerParameterAdapter.class).values();
	Collection<StreamListenerResultAdapter> streamListenerResultAdapters = this.applicationContext
			.getBeansOfType(StreamListenerResultAdapter.class).values();
	this.binderAwareChannelResolver = this.applicationContext
			.getBean("binderAwareChannelResolver", DestinationResolver.class);
	this.messageHandlerMethodFactory = this.applicationContext
			.getBean("integrationMessageHandlerMethodFactory", MessageHandlerMethodFactory.class);
	this.springIntegrationProperties = this.applicationContext
			.getBean(SpringIntegrationProperties.class);

	this.streamListenerSetupMethodOrchestrators.addAll(this.applicationContext
			.getBeansOfType(StreamListenerSetupMethodOrchestrator.class).values());

	// Default orchestrator for StreamListener method invocation is added last into
	// the LinkedHashSet.
	this.streamListenerSetupMethodOrchestrators.add(
			new DefaultStreamListenerSetupMethodOrchestrator(this.applicationContext,
					streamListenerParameterAdapters, streamListenerResultAdapters));

	this.streamListenerCallbacks.forEach(Runnable::run);
}
 
Example 2
@Override
public void afterSingletonsInstantiated() {
	// Remove resolved singleton classes from cache
	this.nonAnnotatedClasses.clear();

	if (this.beanFactory instanceof ListableBeanFactory) {
		// Apply JmsListenerConfigurer beans from the BeanFactory, if any
		Map<String, JmsListenerConfigurer> beans =
				((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
		List<JmsListenerConfigurer> configurers = new ArrayList<>(beans.values());
		AnnotationAwareOrderComparator.sort(configurers);
		for (JmsListenerConfigurer configurer : configurers) {
			configurer.configureJmsListeners(this.registrar);
		}
	}

	if (this.containerFactoryBeanName != null) {
		this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName);
	}

	if (this.registrar.getEndpointRegistry() == null) {
		// Determine JmsListenerEndpointRegistry bean from the BeanFactory
		if (this.endpointRegistry == null) {
			Assert.state(this.beanFactory != null, "BeanFactory must be set to find endpoint registry by bean name");
			this.endpointRegistry = this.beanFactory.getBean(
					JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME, JmsListenerEndpointRegistry.class);
		}
		this.registrar.setEndpointRegistry(this.endpointRegistry);
	}


	// Set the custom handler method factory once resolved by the configurer
	MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
	if (handlerMethodFactory != null) {
		this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
	}

	// Actually register all listeners
	this.registrar.afterPropertiesSet();
}
 
Example 3
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 4
@Override
public void afterSingletonsInstantiated() {
	// Remove resolved singleton classes from cache
	this.nonAnnotatedClasses.clear();

	if (this.beanFactory instanceof ListableBeanFactory) {
		// Apply JmsListenerConfigurer beans from the BeanFactory, if any
		Map<String, JmsListenerConfigurer> beans =
				((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
		List<JmsListenerConfigurer> configurers = new ArrayList<>(beans.values());
		AnnotationAwareOrderComparator.sort(configurers);
		for (JmsListenerConfigurer configurer : configurers) {
			configurer.configureJmsListeners(this.registrar);
		}
	}

	if (this.containerFactoryBeanName != null) {
		this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName);
	}

	if (this.registrar.getEndpointRegistry() == null) {
		// Determine JmsListenerEndpointRegistry bean from the BeanFactory
		if (this.endpointRegistry == null) {
			Assert.state(this.beanFactory != null, "BeanFactory must be set to find endpoint registry by bean name");
			this.endpointRegistry = this.beanFactory.getBean(
					JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME, JmsListenerEndpointRegistry.class);
		}
		this.registrar.setEndpointRegistry(this.endpointRegistry);
	}


	// Set the custom handler method factory once resolved by the configurer
	MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
	if (handlerMethodFactory != null) {
		this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
	}

	// Actually register all listeners
	this.registrar.afterPropertiesSet();
}
 
Example 5
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 6
@Override
public void afterSingletonsInstantiated() {
	this.registrar.setBeanFactory(this.beanFactory);

	if (this.beanFactory instanceof ListableBeanFactory) {
		Map<String, JmsListenerConfigurer> instances =
				((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
		for (JmsListenerConfigurer configurer : instances.values()) {
			configurer.configureJmsListeners(this.registrar);
		}
	}

	if (this.registrar.getEndpointRegistry() == null) {
		if (this.endpointRegistry == null) {
			Assert.state(this.beanFactory != null, "BeanFactory must be set to find endpoint registry by bean name");
			this.endpointRegistry = this.beanFactory.getBean(
					JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME, JmsListenerEndpointRegistry.class);
		}
		this.registrar.setEndpointRegistry(this.endpointRegistry);
	}

	if (this.containerFactoryBeanName != null) {
		this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName);
	}

	// Set the custom handler method factory once resolved by the configurer
	MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
	if (handlerMethodFactory != null) {
		this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
	}

	// Actually register all listeners
	this.registrar.afterPropertiesSet();
}
 
Example 7
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 8
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example 9
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
@Nullable
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example 10
Source Project: spring-analysis-note   Source File: EnableJmsTests.java    License: MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 11
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 12
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example 13
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
@Nullable
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example 14
Source Project: java-technology-stack   Source File: EnableJmsTests.java    License: MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 15
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 16
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example 17
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	defaultFactory.setBeanFactory(beanFactory);
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 18
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example 19
Source Project: spring4-understanding   Source File: EnableJmsTests.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 20
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} Javadoc for more details.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
}
 
Example 21
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} javadoc for more details.
 */
public void setMessageHandlerMethodFactory(@Nullable MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 22
Source Project: spring-analysis-note   Source File: MethodJmsListenerEndpoint.java    License: MIT License 2 votes vote down vote up
/**
 * Set the {@link MessageHandlerMethodFactory} to use to build the
 * {@link InvocableHandlerMethod} responsible to manage the invocation
 * of this endpoint.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 23
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} Javadoc for more details.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
}
 
Example 24
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} javadoc for more details.
 */
public void setMessageHandlerMethodFactory(@Nullable MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 25
Source Project: java-technology-stack   Source File: MethodJmsListenerEndpoint.java    License: MIT License 2 votes vote down vote up
/**
 * Set the {@link MessageHandlerMethodFactory} to use to build the
 * {@link InvocableHandlerMethod} responsible to manage the invocation
 * of this endpoint.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 26
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} Javadoc for more details.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
}
 
Example 27
/**
 * Set the {@link MessageHandlerMethodFactory} to use to configure the message
 * listener responsible to serve an endpoint detected by this processor.
 * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it
 * can be configured further to support additional method arguments
 * or to customize conversion and validation support. See
 * {@link DefaultMessageHandlerMethodFactory} javadoc for more details.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example 28
/**
 * Set the {@link MessageHandlerMethodFactory} to use to build the
 * {@link InvocableHandlerMethod} responsible to manage the invocation
 * of this endpoint.
 */
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}