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
Source Project: spring-cloud-stream   Author: spring-cloud   File: StreamListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 5 votes vote down vote up
@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
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 5 votes vote down vote up
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example #4
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 5 votes vote down vote up
@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
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 5 votes vote down vote up
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example #6
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #8
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #9
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerEndpointRegistrar.java    License: MIT License 4 votes vote down vote up
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
@Nullable
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example #10
Source Project: spring-analysis-note   Author: Vip-Augus   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
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #12
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #13
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerEndpointRegistrar.java    License: MIT License 4 votes vote down vote up
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
@Nullable
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example #14
Source Project: java-technology-stack   Author: codeEngraver   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
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #16
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #17
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 4 votes vote down vote up
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	defaultFactory.setBeanFactory(beanFactory);
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example #18
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerEndpointRegistrar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Return the custom {@link MessageHandlerMethodFactory} to use, if any.
 */
public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	return this.messageHandlerMethodFactory;
}
 
Example #19
Source Project: spring4-understanding   Author: langtianya   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
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 2 votes vote down vote up
/**
 * 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
Source Project: spring-analysis-note   Author: Vip-Augus   File: JmsListenerEndpointRegistrar.java    License: MIT License 2 votes vote down vote up
/**
 * 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   Author: Vip-Augus   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
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerAnnotationBeanPostProcessor.java    License: MIT License 2 votes vote down vote up
/**
 * 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
Source Project: java-technology-stack   Author: codeEngraver   File: JmsListenerEndpointRegistrar.java    License: MIT License 2 votes vote down vote up
/**
 * 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   Author: codeEngraver   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
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerAnnotationBeanPostProcessor.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source Project: spring4-understanding   Author: langtianya   File: JmsListenerEndpointRegistrar.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source Project: spring4-understanding   Author: langtianya   File: MethodJmsListenerEndpoint.java    License: Apache License 2.0 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;
}