Skip to content

Commit 965fca8

Browse files
committed
Polishing
1 parent faab220 commit 965fca8

File tree

8 files changed

+46
-42
lines changed

8 files changed

+46
-42
lines changed

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public Class<?> getDeclaringClass() {
207207

208208
/**
209209
* Return the index of the method/constructor parameter.
210-
* @return the parameter index (never negative)
210+
* @return the parameter index (-1 in case of the return type)
211211
*/
212212
public int getParameterIndex() {
213213
return this.parameterIndex;

spring-jms/src/main/java/org/springframework/jms/listener/adapter/AbstractAdaptableMessageListener.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import org.springframework.util.Assert;
4141

4242
/**
43-
* An abstract {@link MessageListener} adapter providing the necessary infrastructure
44-
* to extract the payload of a {@link Message}
43+
* An abstract JMS {@link MessageListener} adapter providing the necessary
44+
* infrastructure to extract the payload of a JMS {@link Message}.
4545
*
4646
* @author Juergen Hoeller
4747
* @author Stephane Nicoll
@@ -217,7 +217,7 @@ protected Object extractMessage(Message message) {
217217
return message;
218218
}
219219
catch (JMSException ex) {
220-
throw new MessageConversionException("Could not unmarshal message", ex);
220+
throw new MessageConversionException("Could not convert JMS message", ex);
221221
}
222222
}
223223

@@ -246,10 +246,12 @@ protected void handleResult(Object result, Message request, Session session) {
246246
sendResponse(session, destination, response);
247247
}
248248
catch (Exception ex) {
249-
throw new ReplyFailureException("Failed to send reply with payload '" + result + "'", ex);
249+
throw new ReplyFailureException("Failed to send reply with payload [" + result + "]", ex);
250250
}
251251
}
252+
252253
else {
254+
// No JMS Session available
253255
if (logger.isWarnEnabled()) {
254256
logger.warn("Listener method returned result [" + result +
255257
"]: not generating response message for it because of no JMS Session given");
@@ -266,25 +268,21 @@ protected void handleResult(Object result, Message request, Session session) {
266268
* @see #setMessageConverter
267269
*/
268270
protected Message buildMessage(Session session, Object result) throws JMSException {
269-
Object content = (result instanceof JmsResponse
270-
? ((JmsResponse<?>) result).getResponse() : result);
271+
Object content = (result instanceof JmsResponse ? ((JmsResponse<?>) result).getResponse() : result);
272+
if (content instanceof org.springframework.messaging.Message) {
273+
return this.messagingMessageConverter.toMessage(content, session);
274+
}
271275

272276
MessageConverter converter = getMessageConverter();
273277
if (converter != null) {
274-
if (content instanceof org.springframework.messaging.Message) {
275-
return this.messagingMessageConverter.toMessage(content, session);
276-
}
277-
else {
278-
return converter.toMessage(content, session);
279-
}
278+
return converter.toMessage(content, session);
280279
}
281-
else {
282-
if (!(content instanceof Message)) {
283-
throw new MessageConversionException(
284-
"No MessageConverter specified - cannot handle message [" + content + "]");
285-
}
286-
return (Message) content;
280+
281+
if (!(content instanceof Message)) {
282+
throw new MessageConversionException(
283+
"No MessageConverter specified - cannot handle message [" + content + "]");
287284
}
285+
return (Message) content;
288286
}
289287

290288
/**
@@ -307,6 +305,7 @@ protected void postProcessResponse(Message request, Message response) throws JMS
307305

308306
private Destination getResponseDestination(Message request, Message response, Session session, Object result)
309307
throws JMSException {
308+
310309
if (result instanceof JmsResponse) {
311310
JmsResponse<?> jmsResponse = (JmsResponse) result;
312311
Destination destination = jmsResponse.resolveDestination(getDestinationResolver(), session);
@@ -418,7 +417,7 @@ protected Message createMessageForPayload(Object payload, Session session) throw
418417
if (converter != null) {
419418
return converter.toMessage(payload, session);
420419
}
421-
throw new IllegalStateException("No message converter, cannot handle '" + payload + "'");
420+
throw new IllegalStateException("No message converter - cannot handle [" + payload + "]");
422421
}
423422
}
424423

spring-jms/src/main/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ protected Message<?> toMessagingMessage(javax.jms.Message jmsMessage) {
7777
return (Message<?>) getMessagingMessageConverter().fromMessage(jmsMessage);
7878
}
7979
catch (JMSException ex) {
80-
throw new MessageConversionException("Could not unmarshal message", ex);
80+
throw new MessageConversionException("Could not convert JMS message", ex);
8181
}
8282
}
8383

@@ -90,8 +90,8 @@ private Object invokeHandler(javax.jms.Message jmsMessage, Session session, Mess
9090
return this.handlerMethod.invoke(message, jmsMessage, session);
9191
}
9292
catch (MessagingException ex) {
93-
throw new ListenerExecutionFailedException(createMessagingErrorMessage("Listener method could not " +
94-
"be invoked with the incoming message"), ex);
93+
throw new ListenerExecutionFailedException(
94+
createMessagingErrorMessage("Listener method could not be invoked with incoming message"), ex);
9595
}
9696
catch (Exception ex) {
9797
throw new ListenerExecutionFailedException("Listener method '" +

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/JsonViewRequestBodyAdvice.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,39 @@
2828
import org.springframework.http.converter.json.MappingJacksonInputMessage;
2929

3030
/**
31-
* A {@code RequestBodyAdvice} implementation that adds support for
32-
* Jackson's {@code @JsonView} annotation declared on a Spring MVC
33-
* {@code @HttpEntity} and {@code @RequestBody} method parameters.
31+
* A {@link RequestBodyAdvice} implementation that adds support for Jackson's
32+
* {@code @JsonView} annotation declared on a Spring MVC {@code @HttpEntity}
33+
* or {@code @RequestBody} method parameter.
3434
*
35-
* <p>The deserialization view specified in the annotation will be passed in to
36-
* the {@code MappingJackson2HttpMessageConverter} which will then use it to
37-
* deserialize the request body with.
35+
* <p>The deserialization view specified in the annotation will be passed in to the
36+
* {@link org.springframework.http.converter.json.MappingJackson2HttpMessageConverter}
37+
* which will then use it to deserialize the request body with.
3838
*
3939
* <p>Note that despite {@code @JsonView} allowing for more than one class to
4040
* be specified, the use for a request body advice is only supported with
4141
* exactly one class argument. Consider the use of a composite interface.
4242
*
43-
* <p>Jackson 2.5.0 or later is required.
43+
* <p>Jackson 2.5 or later is required for parameter-level use of {@code @JsonView}.
4444
*
4545
* @author Sebastien Deleuze
4646
* @since 4.2
47+
* @see com.fasterxml.jackson.annotation.JsonView
4748
* @see com.fasterxml.jackson.databind.ObjectMapper#readerWithView(Class)
4849
*/
4950
public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter {
5051

5152
@Override
5253
public boolean supports(MethodParameter methodParameter, Type targetType,
5354
Class<? extends HttpMessageConverter<?>> converterType) {
55+
5456
return (AbstractJackson2HttpMessageConverter.class.isAssignableFrom(converterType) &&
5557
methodParameter.getParameterAnnotation(JsonView.class) != null);
5658
}
5759

5860
@Override
5961
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter,
6062
Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException {
63+
6164
JsonView annotation = methodParameter.getParameterAnnotation(JsonView.class);
6265
Class<?>[] classes = annotation.value();
6366
if (classes.length != 1) {

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/JsonViewResponseBodyAdvice.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,20 +26,21 @@
2626
import org.springframework.http.server.ServerHttpResponse;
2727

2828
/**
29-
* A {@code ResponseBodyAdvice} implementation that adds support for
30-
* Jackson's {@code @JsonView} annotation declared on a Spring MVC
31-
* {@code @RequestMapping} or {@code @ExceptionHandler} method.
29+
* A {@link ResponseBodyAdvice} implementation that adds support for Jackson's
30+
* {@code @JsonView} annotation declared on a Spring MVC {@code @RequestMapping}
31+
* or {@code @ExceptionHandler} method.
3232
*
33-
* <p>The serialization view specified in the annotation will be passed in to
34-
* the {@code MappingJackson2HttpMessageConverter} which will then use it to
35-
* serialize the response body with.
33+
* <p>The serialization view specified in the annotation will be passed in to the
34+
* {@link org.springframework.http.converter.json.MappingJackson2HttpMessageConverter}
35+
* which will then use it to serialize the response body with.
3636
*
3737
* <p>Note that despite {@code @JsonView} allowing for more than one class to
3838
* be specified, the use for a response body advice is only supported with
3939
* exactly one class argument. Consider the use of a composite interface.
4040
*
4141
* @author Rossen Stoyanchev
4242
* @since 4.1
43+
* @see com.fasterxml.jackson.annotation.JsonView
4344
* @see com.fasterxml.jackson.databind.ObjectMapper#writerWithView(Class)
4445
*/
4546
public class JsonViewResponseBodyAdvice extends AbstractMappingJacksonResponseBodyAdvice {

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/InfoReceiver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.socket.sockjs.client;
1718

1819
import java.net.URI;
@@ -43,4 +44,4 @@ public interface InfoReceiver {
4344
*/
4445
String executeInfoRequest(URI infoUrl, HttpHeaders headers);
4546

46-
}
47+
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/Transport.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,8 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.web.socket.sockjs.client;
1716

17+
package org.springframework.web.socket.sockjs.client;
1818

1919
import java.util.List;
2020

@@ -40,7 +40,6 @@ public interface Transport {
4040

4141
/**
4242
* Connect the transport.
43-
*
4443
* @param request the transport request.
4544
* @param webSocketHandler the application handler to delegate lifecycle events to.
4645
* @return a future to indicate success or failure to connect.

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/XhrTransport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.socket.sockjs.client;
1718

1819
import java.net.URI;

0 commit comments

Comments
 (0)