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

The following examples show how to use org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory. 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 File: StreamListenerAnnotationBeanPostProcessor.java    From spring-cloud-stream with 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 File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with 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 File: JmsListenerAnnotationBeanPostProcessor.java    From spring4-understanding with 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 #4
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with 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 #5
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with 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 #6
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with 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 #7
Source File: JmsListenerEndpointRegistrar.java    From spring-analysis-note with 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 #8
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring4-understanding with 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 #9
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #10
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #11
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #12
Source File: EnableJmsTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example #13
Source File: JmsListenerEndpointRegistrar.java    From spring4-understanding with 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 #14
Source File: JmsListenerEndpointRegistrar.java    From java-technology-stack with 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 #15
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #16
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 4 votes vote down vote up
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
	if (this.messageHandlerMethodFactory == null) {
		this.messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
	}
	return this.messageHandlerMethodFactory;
}
 
Example #17
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 4 votes vote down vote up
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
	this.messageHandlerMethodFactory = messageHandlerMethodFactory;
}
 
Example #18
Source File: EnableJmsTests.java    From spring4-understanding with 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 #19
Source File: EnableJmsTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example #20
Source File: MethodJmsListenerEndpoint.java    From spring4-understanding with 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;
}
 
Example #21
Source File: JmsListenerEndpointRegistrar.java    From spring4-understanding with 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 #22
Source File: JmsListenerEndpointRegistrar.java    From spring-analysis-note with 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 #23
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with 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 File: JmsListenerAnnotationBeanPostProcessor.java    From spring4-understanding with 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 #25
Source File: MethodJmsListenerEndpoint.java    From java-technology-stack with 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 File: JmsListenerEndpointRegistrar.java    From java-technology-stack with 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 #27
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with 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 #28
Source File: MethodJmsListenerEndpoint.java    From spring-analysis-note with 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;
}