本文整理汇总了Java中org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver类的典型用法代码示例。如果您正苦于以下问题:Java HandlerMethodArgumentResolver类的具体用法?Java HandlerMethodArgumentResolver怎么用?Java HandlerMethodArgumentResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HandlerMethodArgumentResolver类属于org.springframework.messaging.handler.invocation包,在下文中一共展示了HandlerMethodArgumentResolver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: HandlerMethodService
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
public HandlerMethodService(ConversionService conversionService,
List<HandlerMethodArgumentResolver> customArgumentResolvers,
ObjectMapper objectMapper, ApplicationContext applicationContext) {
this.conversionService = conversionService;
this.parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
this.argumentResolvers = new HandlerMethodArgumentResolverComposite();
ConfigurableBeanFactory beanFactory = ClassUtils.isAssignableValue(
ConfigurableApplicationContext.class, applicationContext)
? ((ConfigurableApplicationContext) applicationContext)
.getBeanFactory()
: null;
this.argumentResolvers.addResolver(
new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
this.argumentResolvers.addResolver(new HeadersMethodArgumentResolver());
this.argumentResolvers.addResolver(new WampMessageMethodArgumentResolver());
this.argumentResolvers.addResolver(new PrincipalMethodArgumentResolver());
this.argumentResolvers.addResolver(new WampSessionIdMethodArgumentResolver());
this.argumentResolvers.addResolvers(customArgumentResolvers);
this.objectMapper = objectMapper;
}
开发者ID:ralscha,项目名称:wamp2spring,代码行数:25,代码来源:HandlerMethodService.java
示例2: afterPropertiesSet
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
if (beanFactory instanceof ListableBeanFactory) {
Map<String, HandlerMethodArgumentResolver> instances =
((ListableBeanFactory) this.beanFactory).getBeansOfType(HandlerMethodArgumentResolver.class);
if (null != instances && instances.size() > 0) {
handlerMethodArgumentResolvers.addAll(instances.values());
}
}
if (null == messageHandlerMethodFactory) {
messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
}
if (endpointRegistry instanceof JmsListenerEndpointRegistryAdapter) {
JmsListenerEndpointRegistryAdapter methodEndpointRegistry =
(JmsListenerEndpointRegistryAdapter) endpointRegistry;
methodEndpointRegistry.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
}
}
开发者ID:kinglcc,项目名称:spring-boot-jms,代码行数:21,代码来源:MethodJmsListenerConfigurer.java
示例3: initArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
ConfigurableBeanFactory beanFactory = (getApplicationContext() instanceof ConfigurableApplicationContext ?
((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null);
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>();
// Annotation-based argument resolution
resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
resolvers.add(new HeadersMethodArgumentResolver());
resolvers.add(new DestinationVariableMethodArgumentResolver(this.conversionService));
// Type-based argument resolution
resolvers.add(new PrincipalMethodArgumentResolver());
resolvers.add(new MessageMethodArgumentResolver());
resolvers.addAll(getCustomArgumentResolvers());
resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));
return resolvers;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:SimpAnnotationMethodMessageHandler.java
示例4: simpAnnotationMethodMessageHandler
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() {
SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler();
handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes());
handler.setMessageConverter(brokerMessageConverter());
handler.setValidator(simpValidator());
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>();
addArgumentResolvers(argumentResolvers);
handler.setCustomArgumentResolvers(argumentResolvers);
List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>();
addReturnValueHandlers(returnValueHandlers);
handler.setCustomReturnValueHandlers(returnValueHandlers);
PathMatcher pathMatcher = this.getBrokerRegistry().getPathMatcher();
if (pathMatcher != null) {
handler.setPathMatcher(pathMatcher);
}
return handler;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AbstractMessageBrokerConfiguration.java
示例5: initArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>();
ConfigurableBeanFactory cbf = (this.beanFactory instanceof ConfigurableBeanFactory ?
(ConfigurableBeanFactory) this.beanFactory : null);
// Annotation-based argument resolution
resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, cbf));
resolvers.add(new HeadersMethodArgumentResolver());
// Type-based argument resolution
resolvers.add(new MessageMethodArgumentResolver());
if (this.customArgumentResolvers != null) {
resolvers.addAll(this.customArgumentResolvers);
}
resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));
return resolvers;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:DefaultMessageHandlerMethodFactory.java
示例6: overrideArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void overrideArgumentResolvers() throws Exception {
DefaultMessageHandlerMethodFactory instance = createInstance();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<HandlerMethodArgumentResolver>();
customResolvers.add(new CustomHandlerMethodArgumentResolver());
instance.setArgumentResolvers(customResolvers);
instance.afterPropertiesSet();
Message<String> message = MessageBuilder.withPayload("sample").build();
// This will work as the local resolver is set
InvocableHandlerMethod invocableHandlerMethod =
createInvocableHandlerMethod(instance, "customArgumentResolver", Locale.class);
invocableHandlerMethod.invoke(message);
assertMethodInvocation(sample, "customArgumentResolver");
// This won't work as no resolver is known for the payload
InvocableHandlerMethod invocableHandlerMethod2 =
createInvocableHandlerMethod(instance, "simpleString", String.class);
thrown.expect(IllegalStateException.class);
thrown.expectMessage("No suitable resolver for");
invocableHandlerMethod2.invoke(message);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:DefaultMessageHandlerMethodFactoryTests.java
示例7: customArgumentAndReturnValueTypes
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void customArgumentAndReturnValueTypes() {
loadBeanDefinitions("websocket-config-broker-custom-argument-and-return-value-types.xml");
SimpAnnotationMethodMessageHandler handler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class);
List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers();
assertEquals(2, customResolvers.size());
assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0)));
assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(1)));
List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers();
assertEquals(2, customHandlers.size());
assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0)));
assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(1)));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:MessageBrokerBeanDefinitionParserTests.java
示例8: sqsMessageHandler
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public QueueMessageHandler sqsMessageHandler() {
Collection<MessageConverter> converters = new ArrayList<>();
MappingJackson2MessageConverter jacksonConverter = new MappingJackson2MessageConverter();
jacksonConverter.setSerializedPayloadClass(String.class);
jacksonConverter.setStrictContentTypeMatch(false);
converters.add(jacksonConverter);
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
CompositeMessageConverter compositeMessageConverter = new CompositeMessageConverter(converters);
resolvers.add(new NotificationMessageArgumentResolver(compositeMessageConverter));
resolvers.add(new PayloadArgumentResolver(compositeMessageConverter));
QueueMessageHandler handler = sqsMessageHandlerFactory().createQueueMessageHandler();
handler.setArgumentResolvers(resolvers);
return handler;
}
开发者ID:kalnee,项目名称:trivor,代码行数:18,代码来源:AWSConfig.java
示例9: annotationMethodMessageHandler
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public MessageHandler annotationMethodMessageHandler(
ConfigurableApplicationContext configurableApplicationContext) {
AuthenticationHandler authenticationHandler = authenticationHandler();
if (authenticationHandler != null) {
configurableApplicationContext.getBeanFactory()
.registerSingleton("authenticationHandler", authenticationHandler);
}
WampAnnotationMethodMessageHandler messageHandler = new WampAnnotationMethodMessageHandler(
clientInboundChannel(), clientOutboundChannel(), eventMessenger(),
conversionService(), methodParameterConverter(), pathMatcher(),
methodMessageHandlerMessageSelector(), messageConverter());
messageHandler.setAuthenticationRequiredGlobal(authenticationRequired());
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
addArgumentResolvers(argumentResolvers);
messageHandler.setCustomArgumentResolvers(argumentResolvers);
return messageHandler;
}
开发者ID:ralscha,项目名称:wampspring,代码行数:24,代码来源:DefaultWampConfiguration.java
示例10: initArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
protected List<? extends HandlerMethodArgumentResolver> initArgumentResolvers() {
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(getCustomArgumentResolvers());
resolvers.add(new HeaderMethodArgumentResolver(null, null));
resolvers.add(new HeadersMethodArgumentResolver());
resolvers.add(new NotificationSubjectArgumentResolver());
resolvers.add(new AcknowledgmentHandlerMethodArgumentResolver(ACKNOWLEDGMENT));
resolvers.add(new VisibilityHandlerMethodArgumentResolver(VISIBILITY));
CompositeMessageConverter compositeMessageConverter = createPayloadArgumentCompositeConverter();
resolvers.add(new NotificationMessageArgumentResolver(compositeMessageConverter));
resolvers.add(new PayloadArgumentResolver(compositeMessageConverter, new NoOpValidator()));
return resolvers;
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:18,代码来源:QueueMessageHandler.java
示例11: receiveMessage_withCustomArgumentResolvers_shouldCallThemBeforeTheDefaultOnes
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void receiveMessage_withCustomArgumentResolvers_shouldCallThemBeforeTheDefaultOnes() throws Exception {
// Arrange
StaticApplicationContext applicationContext = new StaticApplicationContext();
applicationContext.registerSingleton("incomingMessageHandler", IncomingMessageHandler.class);
HandlerMethodArgumentResolver handlerMethodArgumentResolver = mock(HandlerMethodArgumentResolver.class);
when(handlerMethodArgumentResolver.supportsParameter(any(MethodParameter.class))).thenReturn(true);
when(handlerMethodArgumentResolver.resolveArgument(any(MethodParameter.class), any(Message.class))).thenReturn("Hello from a sender");
MutablePropertyValues properties = new MutablePropertyValues(
Collections.singletonList(new PropertyValue("customArgumentResolvers", handlerMethodArgumentResolver)));
applicationContext.registerSingleton("queueMessageHandler", QueueMessageHandler.class, properties);
applicationContext.refresh();
QueueMessageHandler queueMessageHandler = applicationContext.getBean(QueueMessageHandler.class);
// Act
queueMessageHandler.handleMessage(MessageBuilder.withPayload("Hello from a sender")
.setHeader(QueueMessageHandler.LOGICAL_RESOURCE_ID, "receive").build());
// Assert
verify(handlerMethodArgumentResolver, times(1)).resolveArgument(any(MethodParameter.class), any(Message.class));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:QueueMessageHandlerTest.java
示例12: handlerMethodService
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public HandlerMethodService handlerMethodService(
ApplicationContext applicationContext) {
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
addArgumentResolvers(argumentResolvers);
for (WampConfigurer wc : this.configurers) {
wc.addArgumentResolvers(argumentResolvers);
}
return new HandlerMethodService(conversionService(), argumentResolvers,
new ObjectMapper(), applicationContext);
}
开发者ID:ralscha,项目名称:wamp2spring,代码行数:14,代码来源:WampConfiguration.java
示例13: setArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
/**
* Configure the complete list of supported argument types effectively overriding
* the ones configured by default. This is an advanced option. For most use cases
* it should be sufficient to use {@link #setCustomArgumentResolvers(java.util.List)}.
*/
public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
if (argumentResolvers == null) {
this.argumentResolvers.clear();
return;
}
this.argumentResolvers.addResolvers(argumentResolvers);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DefaultMessageHandlerMethodFactory.java
示例14: customArgumentAndReturnValueTypes
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void customArgumentAndReturnValueTypes() throws Exception {
SimpAnnotationMethodMessageHandler handler = this.customContext.getBean(SimpAnnotationMethodMessageHandler.class);
List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers();
assertEquals(1, customResolvers.size());
assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0)));
List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers();
assertEquals(1, customHandlers.size());
assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0)));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:MessageBrokerConfigurationTests.java
示例15: customArgumentResolver
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void customArgumentResolver() throws Exception {
DefaultMessageHandlerMethodFactory instance = createInstance();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<HandlerMethodArgumentResolver>();
customResolvers.add(new CustomHandlerMethodArgumentResolver());
instance.setCustomArgumentResolvers(customResolvers);
instance.afterPropertiesSet();
InvocableHandlerMethod invocableHandlerMethod =
createInvocableHandlerMethod(instance, "customArgumentResolver", Locale.class);
invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build());
assertMethodInvocation(sample, "customArgumentResolver");
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DefaultMessageHandlerMethodFactoryTests.java
示例16: initArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
private List<? extends HandlerMethodArgumentResolver> initArgumentResolvers() {
ConfigurableBeanFactory beanFactory = ClassUtils.isAssignableValue(
ConfigurableApplicationContext.class, this.applicationContext)
? ((ConfigurableApplicationContext) this.applicationContext)
.getBeanFactory()
: null;
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
// Annotation-based argument resolution
resolvers.add(
new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
resolvers.add(new HeadersMethodArgumentResolver());
resolvers.add(
new DestinationVariableMethodArgumentResolver(this.conversionService));
// Type-based argument resolution
resolvers.add(new PrincipalMethodArgumentResolver());
resolvers.add(new WampSessionMethodArgumentResolver());
resolvers.add(new MessageMethodArgumentResolver(this.messageConverter));
resolvers.addAll(getCustomArgumentResolvers());
resolvers.add(new PayloadArgumentResolver(this.applicationContext,
this.methodParameterConverter));
return resolvers;
}
开发者ID:ralscha,项目名称:wampspring,代码行数:29,代码来源:WampAnnotationMethodMessageHandler.java
示例17: setCustomArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
/**
* Sets the list of custom {@code HandlerMethodArgumentResolver}s that will be used
* after resolvers for supported argument type.
* @param customArgumentResolvers the list of resolvers; never {@code null}.
*/
public void setCustomArgumentResolvers(
List<HandlerMethodArgumentResolver> customArgumentResolvers) {
this.customArgumentResolvers.clear();
if (customArgumentResolvers != null) {
this.customArgumentResolvers.addAll(customArgumentResolvers);
}
}
开发者ID:ralscha,项目名称:wampspring,代码行数:13,代码来源:WampAnnotationMethodMessageHandler.java
示例18: setArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
/**
* Configure the complete list of supported argument types effectively overriding the
* ones configured by default. This is an advanced option. For most use cases it
* should be sufficient to use {@link #setCustomArgumentResolvers(java.util.List)}.
*/
public void setArgumentResolvers(
List<HandlerMethodArgumentResolver> argumentResolvers) {
if (argumentResolvers == null) {
this.argumentResolvers.clear();
return;
}
this.argumentResolvers.addResolvers(argumentResolvers);
}
开发者ID:ralscha,项目名称:wampspring,代码行数:14,代码来源:WampAnnotationMethodMessageHandler.java
示例19: addArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
protected void addArgumentResolvers(
@SuppressWarnings("unused") List<HandlerMethodArgumentResolver> argumentResolvers) {
// nothing here
}
开发者ID:ralscha,项目名称:wamp2spring,代码行数:5,代码来源:WampConfiguration.java
示例20: addArgumentResolvers
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> arg0) {
}
开发者ID:weechang,项目名称:Taroco,代码行数:4,代码来源:WebSocketConfiguration.java
注:本文中的org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论