Polishing
This commit is contained in:
parent
8196af4bc5
commit
f06581f5b8
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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.
|
||||
|
|
@ -31,11 +31,11 @@ import org.springframework.messaging.MessageHeaders;
|
|||
public interface MessageConverter {
|
||||
|
||||
/**
|
||||
* Convert the payload of a {@link Message} from serialized form to a typed Object of
|
||||
* the specified target class. The {@link MessageHeaders#CONTENT_TYPE} header should
|
||||
* indicate the MIME type to convert from.
|
||||
* <p>If the converter does not support the specified media type or cannot perform the
|
||||
* conversion, it should return {@code null}.
|
||||
* Convert the payload of a {@link Message} from a serialized form to a typed Object
|
||||
* of the specified target class. The {@link MessageHeaders#CONTENT_TYPE} header
|
||||
* should indicate the MIME type to convert from.
|
||||
* <p>If the converter does not support the specified media type or cannot perform
|
||||
* the conversion, it should return {@code null}.
|
||||
* @param message the input message
|
||||
* @param targetClass the target class for the conversion
|
||||
* @return the result of the conversion, or {@code null} if the converter cannot
|
||||
|
|
@ -47,15 +47,15 @@ public interface MessageConverter {
|
|||
* Create a {@link Message} whose payload is the result of converting the given
|
||||
* payload Object to serialized form. The optional {@link MessageHeaders} parameter
|
||||
* may contain a {@link MessageHeaders#CONTENT_TYPE} header to specify the target
|
||||
* media type for the conversion and it may contain additional headers to be added to
|
||||
* the message.
|
||||
* <p>If the converter does not support the specified media type or cannot perform the
|
||||
* conversion, it should return {@code null}.
|
||||
* media type for the conversion and it may contain additional headers to be added
|
||||
* to the message.
|
||||
* <p>If the converter does not support the specified media type or cannot perform
|
||||
* the conversion, it should return {@code null}.
|
||||
* @param payload the Object to convert
|
||||
* @param header optional headers for the message, may be {@code null}
|
||||
* @return the new message or {@code null} if the converter does not support the
|
||||
* @param headers optional headers for the message (may be {@code null})
|
||||
* @return the new message, or {@code null} if the converter does not support the
|
||||
* Object type or the target media type
|
||||
*/
|
||||
Message<?> toMessage(Object payload, MessageHeaders header);
|
||||
Message<?> toMessage(Object payload, MessageHeaders headers);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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.
|
||||
|
|
@ -46,7 +46,6 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
|
|||
|
||||
/**
|
||||
* Send a message to the given user.
|
||||
*
|
||||
* @param user the user that should receive the message.
|
||||
* @param destination the destination to send the message to.
|
||||
* @param payload the payload to send
|
||||
|
|
@ -55,13 +54,11 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
|
|||
|
||||
/**
|
||||
* Send a message to the given user.
|
||||
*
|
||||
* <p>By default headers are interpreted as native headers (e.g. STOMP) and
|
||||
* are saved under a special key in the resulting Spring
|
||||
* {@link org.springframework.messaging.Message Message}. In effect when the
|
||||
* message leaves the application, the provided headers are included with it
|
||||
* and delivered to the destination (e.g. the STOMP client or broker).
|
||||
*
|
||||
* <p>If the map already contains the key
|
||||
* {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS "nativeHeaders"}
|
||||
* or was prepared with
|
||||
|
|
@ -69,36 +66,31 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
|
|||
* then the headers are used directly. A common expected case is providing a
|
||||
* content type (to influence the message conversion) and native headers.
|
||||
* This may be done as follows:
|
||||
*
|
||||
* <pre class="code">
|
||||
* SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
* accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
|
||||
* accessor.setNativeHeader("foo", "bar");
|
||||
* accessor.setLeaveMutable(true);
|
||||
* MessageHeaders headers = accessor.getMessageHeaders();
|
||||
*
|
||||
* messagingTemplate.convertAndSendToUser(user, destination, payload, headers);
|
||||
* </pre>
|
||||
*
|
||||
* <p><strong>Note:</strong> if the {@code MessageHeaders} are mutable as in
|
||||
* the above example, implementations of this interface should take notice and
|
||||
* update the headers in the same instance (rather than copy or re-create it)
|
||||
* and then set it immutable before sending the final message.
|
||||
*
|
||||
* @param user the user that should receive the message, must not be {@code null}
|
||||
* @param destination the destination to send the message to, must not be {@code null}
|
||||
* @param payload the payload to send, may be {@code null}
|
||||
* @param headers the message headers, may be {@code null}
|
||||
* @param user the user that should receive the message (must not be {@code null})
|
||||
* @param destination the destination to send the message to (must not be {@code null})
|
||||
* @param payload the payload to send (may be {@code null})
|
||||
* @param headers the message headers (may be {@code null})
|
||||
*/
|
||||
void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers)
|
||||
throws MessagingException;
|
||||
|
||||
/**
|
||||
* Send a message to the given user.
|
||||
*
|
||||
* @param user the user that should receive the message, must not be {@code null}
|
||||
* @param destination the destination to send the message to, must not be {@code null}
|
||||
* @param payload the payload to send, may be {@code null}
|
||||
* @param user the user that should receive the message (must not be {@code null})
|
||||
* @param destination the destination to send the message to (must not be {@code null})
|
||||
* @param payload the payload to send (may be {@code null})
|
||||
* @param postProcessor a postProcessor to post-process or modify the created message
|
||||
*/
|
||||
void convertAndSendToUser(String user, String destination, Object payload,
|
||||
|
|
@ -106,12 +98,10 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
|
|||
|
||||
/**
|
||||
* Send a message to the given user.
|
||||
*
|
||||
* <p>See {@link #convertAndSend(Object, Object, java.util.Map)} for important
|
||||
* notes regarding the input headers.
|
||||
*
|
||||
* @param user the user that should receive the message.
|
||||
* @param destination the destination to send the message to.
|
||||
* @param user the user that should receive the message
|
||||
* @param destination the destination to send the message to
|
||||
* @param payload the payload to send
|
||||
* @param headers the message headers
|
||||
* @param postProcessor a postProcessor to post-process or modify the created message
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a rae TransactionStatus instance for the given arguments.
|
||||
* Create a TransactionStatus instance for the given arguments.
|
||||
*/
|
||||
protected DefaultTransactionStatus newTransactionStatus(
|
||||
TransactionDefinition definition, Object transaction, boolean newTransaction,
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) {
|
||||
try {
|
||||
if (inputMessage instanceof MappingJacksonInputMessage) {
|
||||
Class<?> deserializationView = ((MappingJacksonInputMessage)inputMessage).getDeserializationView();
|
||||
Class<?> deserializationView = ((MappingJacksonInputMessage) inputMessage).getDeserializationView();
|
||||
if (deserializationView != null) {
|
||||
return this.objectMapper.readerWithView(deserializationView)
|
||||
.withType(javaType).readValue(inputMessage.getBody());
|
||||
|
|
|
|||
|
|
@ -49,14 +49,6 @@ public class MappingJacksonInputMessage implements HttpInputMessage {
|
|||
}
|
||||
|
||||
|
||||
public void setDeserializationView(Class<?> deserializationView) {
|
||||
this.deserializationView = deserializationView;
|
||||
}
|
||||
|
||||
public Class<?> getDeserializationView() {
|
||||
return deserializationView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() throws IOException {
|
||||
return this.body;
|
||||
|
|
@ -67,4 +59,12 @@ public class MappingJacksonInputMessage implements HttpInputMessage {
|
|||
return this.headers;
|
||||
}
|
||||
|
||||
public void setDeserializationView(Class<?> deserializationView) {
|
||||
this.deserializationView = deserializationView;
|
||||
}
|
||||
|
||||
public Class<?> getDeserializationView() {
|
||||
return this.deserializationView;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue