提交 965fca80 编写于 作者: J Juergen Hoeller

Polishing

上级 faab2209
......@@ -207,7 +207,7 @@ public class MethodParameter {
/**
* Return the index of the method/constructor parameter.
* @return the parameter index (never negative)
* @return the parameter index (-1 in case of the return type)
*/
public int getParameterIndex() {
return this.parameterIndex;
......
......@@ -40,8 +40,8 @@ import org.springframework.jms.support.destination.DynamicDestinationResolver;
import org.springframework.util.Assert;
/**
* An abstract {@link MessageListener} adapter providing the necessary infrastructure
* to extract the payload of a {@link Message}
* An abstract JMS {@link MessageListener} adapter providing the necessary
* infrastructure to extract the payload of a JMS {@link Message}.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
......@@ -217,7 +217,7 @@ public abstract class AbstractAdaptableMessageListener
return message;
}
catch (JMSException ex) {
throw new MessageConversionException("Could not unmarshal message", ex);
throw new MessageConversionException("Could not convert JMS message", ex);
}
}
......@@ -246,10 +246,12 @@ public abstract class AbstractAdaptableMessageListener
sendResponse(session, destination, response);
}
catch (Exception ex) {
throw new ReplyFailureException("Failed to send reply with payload '" + result + "'", ex);
throw new ReplyFailureException("Failed to send reply with payload [" + result + "]", ex);
}
}
else {
// No JMS Session available
if (logger.isWarnEnabled()) {
logger.warn("Listener method returned result [" + result +
"]: not generating response message for it because of no JMS Session given");
......@@ -266,25 +268,21 @@ public abstract class AbstractAdaptableMessageListener
* @see #setMessageConverter
*/
protected Message buildMessage(Session session, Object result) throws JMSException {
Object content = (result instanceof JmsResponse
? ((JmsResponse<?>) result).getResponse() : result);
Object content = (result instanceof JmsResponse ? ((JmsResponse<?>) result).getResponse() : result);
if (content instanceof org.springframework.messaging.Message) {
return this.messagingMessageConverter.toMessage(content, session);
}
MessageConverter converter = getMessageConverter();
if (converter != null) {
if (content instanceof org.springframework.messaging.Message) {
return this.messagingMessageConverter.toMessage(content, session);
}
else {
return converter.toMessage(content, session);
}
return converter.toMessage(content, session);
}
else {
if (!(content instanceof Message)) {
throw new MessageConversionException(
"No MessageConverter specified - cannot handle message [" + content + "]");
}
return (Message) content;
if (!(content instanceof Message)) {
throw new MessageConversionException(
"No MessageConverter specified - cannot handle message [" + content + "]");
}
return (Message) content;
}
/**
......@@ -307,6 +305,7 @@ public abstract class AbstractAdaptableMessageListener
private Destination getResponseDestination(Message request, Message response, Session session, Object result)
throws JMSException {
if (result instanceof JmsResponse) {
JmsResponse<?> jmsResponse = (JmsResponse) result;
Destination destination = jmsResponse.resolveDestination(getDestinationResolver(), session);
......@@ -418,7 +417,7 @@ public abstract class AbstractAdaptableMessageListener
if (converter != null) {
return converter.toMessage(payload, session);
}
throw new IllegalStateException("No message converter, cannot handle '" + payload + "'");
throw new IllegalStateException("No message converter - cannot handle [" + payload + "]");
}
}
......
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -77,7 +77,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
return (Message<?>) getMessagingMessageConverter().fromMessage(jmsMessage);
}
catch (JMSException ex) {
throw new MessageConversionException("Could not unmarshal message", ex);
throw new MessageConversionException("Could not convert JMS message", ex);
}
}
......@@ -90,8 +90,8 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
return this.handlerMethod.invoke(message, jmsMessage, session);
}
catch (MessagingException ex) {
throw new ListenerExecutionFailedException(createMessagingErrorMessage("Listener method could not " +
"be invoked with the incoming message"), ex);
throw new ListenerExecutionFailedException(
createMessagingErrorMessage("Listener method could not be invoked with incoming message"), ex);
}
catch (Exception ex) {
throw new ListenerExecutionFailedException("Listener method '" +
......
......@@ -28,22 +28,23 @@ import org.springframework.http.converter.json.AbstractJackson2HttpMessageConver
import org.springframework.http.converter.json.MappingJacksonInputMessage;
/**
* A {@code RequestBodyAdvice} implementation that adds support for
* Jackson's {@code @JsonView} annotation declared on a Spring MVC
* {@code @HttpEntity} and {@code @RequestBody} method parameters.
* A {@link RequestBodyAdvice} implementation that adds support for Jackson's
* {@code @JsonView} annotation declared on a Spring MVC {@code @HttpEntity}
* or {@code @RequestBody} method parameter.
*
* <p>The deserialization view specified in the annotation will be passed in to
* the {@code MappingJackson2HttpMessageConverter} which will then use it to
* deserialize the request body with.
* <p>The deserialization view specified in the annotation will be passed in to the
* {@link org.springframework.http.converter.json.MappingJackson2HttpMessageConverter}
* which will then use it to deserialize the request body with.
*
* <p>Note that despite {@code @JsonView} allowing for more than one class to
* be specified, the use for a request body advice is only supported with
* exactly one class argument. Consider the use of a composite interface.
*
* <p>Jackson 2.5.0 or later is required.
* <p>Jackson 2.5 or later is required for parameter-level use of {@code @JsonView}.
*
* @author Sebastien Deleuze
* @since 4.2
* @see com.fasterxml.jackson.annotation.JsonView
* @see com.fasterxml.jackson.databind.ObjectMapper#readerWithView(Class)
*/
public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter {
......@@ -51,6 +52,7 @@ public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter {
@Override
public boolean supports(MethodParameter methodParameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType) {
return (AbstractJackson2HttpMessageConverter.class.isAssignableFrom(converterType) &&
methodParameter.getParameterAnnotation(JsonView.class) != null);
}
......@@ -58,6 +60,7 @@ public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter {
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter,
Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException {
JsonView annotation = methodParameter.getParameterAnnotation(JsonView.class);
Class<?>[] classes = annotation.value();
if (classes.length != 1) {
......
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -26,13 +26,13 @@ import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
/**
* A {@code ResponseBodyAdvice} implementation that adds support for
* Jackson's {@code @JsonView} annotation declared on a Spring MVC
* {@code @RequestMapping} or {@code @ExceptionHandler} method.
* A {@link ResponseBodyAdvice} implementation that adds support for Jackson's
* {@code @JsonView} annotation declared on a Spring MVC {@code @RequestMapping}
* or {@code @ExceptionHandler} method.
*
* <p>The serialization view specified in the annotation will be passed in to
* the {@code MappingJackson2HttpMessageConverter} which will then use it to
* serialize the response body with.
* <p>The serialization view specified in the annotation will be passed in to the
* {@link org.springframework.http.converter.json.MappingJackson2HttpMessageConverter}
* which will then use it to serialize the response body with.
*
* <p>Note that despite {@code @JsonView} allowing for more than one class to
* be specified, the use for a response body advice is only supported with
......@@ -40,6 +40,7 @@ import org.springframework.http.server.ServerHttpResponse;
*
* @author Rossen Stoyanchev
* @since 4.1
* @see com.fasterxml.jackson.annotation.JsonView
* @see com.fasterxml.jackson.databind.ObjectMapper#writerWithView(Class)
*/
public class JsonViewResponseBodyAdvice extends AbstractMappingJacksonResponseBodyAdvice {
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.socket.sockjs.client;
import java.net.URI;
......@@ -43,4 +44,4 @@ public interface InfoReceiver {
*/
String executeInfoRequest(URI infoUrl, HttpHeaders headers);
}
\ No newline at end of file
}
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.socket.sockjs.client;
package org.springframework.web.socket.sockjs.client;
import java.util.List;
......@@ -40,7 +40,6 @@ public interface Transport {
/**
* Connect the transport.
*
* @param request the transport request.
* @param webSocketHandler the application handler to delegate lifecycle events to.
* @return a future to indicate success or failure to connect.
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.socket.sockjs.client;
import java.net.URI;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册