Skip to content

Commit

Permalink
Adjust QueryMessage to contain a ResponseType i.o. a Class responseType
Browse files Browse the repository at this point in the history
-Adjust QueryMessage to contain a ResponseType i.o. a Class responseType
-Update the GenericQueryMessage to contain a ResponseType
-Adjust the check done in the MethodQueryMessageHandlerDefinition to now
 call the 'matches' function of the ResponseType

[#463]
  • Loading branch information
smcvb committed Jan 23, 2018
1 parent dd59704 commit 54fba17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Expand Up @@ -36,16 +36,16 @@ public class GenericQueryMessage<T, R> extends MessageDecorator<T> implements Qu
private static final long serialVersionUID = -3908412412867063631L; private static final long serialVersionUID = -3908412412867063631L;


private final String queryName; private final String queryName;
private final Class<R> responseType; private final ResponseType<R> responseType;


/** /**
* Initializes the message with the given {@code payload} and expected {@code responseType}. The query name is * Initializes the message with the given {@code payload} and expected {@code responseType}. The query name is
* set to the fully qualified class name of the {@code payload}. * set to the fully qualified class name of the {@code payload}.
* *
* @param payload The payload expressing the query * @param payload The payload expressing the query
* @param responseType The expected response type * @param responseType The expected response type of type {@link org.axonframework.queryhandling.ResponseType}
*/ */
public GenericQueryMessage(T payload, Class<R> responseType) { public GenericQueryMessage(T payload, ResponseType<R> responseType) {
this(payload, payload.getClass().getName(), responseType); this(payload, payload.getClass().getName(), responseType);
} }


Expand All @@ -54,9 +54,9 @@ public GenericQueryMessage(T payload, Class<R> responseType) {
* *
* @param payload The payload expressing the query * @param payload The payload expressing the query
* @param queryName The name identifying the query to execute * @param queryName The name identifying the query to execute
* @param responseType The expected response type * @param responseType The expected response type of type {@link org.axonframework.queryhandling.ResponseType}
*/ */
public GenericQueryMessage(T payload, String queryName, Class<R> responseType) { public GenericQueryMessage(T payload, String queryName, ResponseType<R> responseType) {
this(new GenericMessage<>(payload, MetaData.emptyInstance()), queryName, responseType); this(new GenericMessage<>(payload, MetaData.emptyInstance()), queryName, responseType);
} }


Expand All @@ -66,9 +66,9 @@ public GenericQueryMessage(T payload, String queryName, Class<R> responseType) {
* *
* @param delegate The message containing the payload and meta data for this message * @param delegate The message containing the payload and meta data for this message
* @param queryName The name identifying the query to execute * @param queryName The name identifying the query to execute
* @param responseType The expected response type * @param responseType The expected response type of type {@link org.axonframework.queryhandling.ResponseType}
*/ */
public GenericQueryMessage(Message<T> delegate, String queryName, Class<R> responseType) { public GenericQueryMessage(Message<T> delegate, String queryName, ResponseType<R> responseType) {
super(delegate); super(delegate);
this.responseType = responseType; this.responseType = responseType;
this.queryName = queryName; this.queryName = queryName;
Expand All @@ -81,7 +81,7 @@ public String getQueryName() {




@Override @Override
public Class<R> getResponseType() { public ResponseType<R> getResponseType() {
return responseType; return responseType;
} }


Expand Down
Expand Up @@ -42,7 +42,7 @@ public interface QueryMessage<T, R> extends Message<T> {
* *
* @return the type of response expected by the sender of the query * @return the type of response expected by the sender of the query
*/ */
Class<R> getResponseType(); ResponseType<R> getResponseType();


/** /**
* Returns a copy of this QueryMessage with the given {@code metaData}. The payload remains unchanged. * Returns a copy of this QueryMessage with the given {@code metaData}. The payload remains unchanged.
Expand Down
Expand Up @@ -110,7 +110,7 @@ public boolean canHandle(Message<?> message) {
return super.canHandle(message) return super.canHandle(message)
&& message instanceof QueryMessage && message instanceof QueryMessage
&& queryName.equals(((QueryMessage) message).getQueryName()) && queryName.equals(((QueryMessage) message).getQueryName())
&& ((QueryMessage) message).getResponseType().isAssignableFrom(resultType); && ((QueryMessage) message).getResponseType().matches(resultType);
} }


@Override @Override
Expand Down

0 comments on commit 54fba17

Please sign in to comment.