Skip to content

Commit

Permalink
Return Registration object when registering interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Scholten committed Nov 24, 2017
1 parent e4560e2 commit 6dd5efe
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -193,19 +193,23 @@ private boolean unsubscribe(QueryDefinition registrationKey, MessageHandler<? su
* respective handlers. The interceptor is invoked separately for each handler instance (in a separate unit of work). * respective handlers. The interceptor is invoked separately for each handler instance (in a separate unit of work).
* *
* @param interceptor the interceptor to invoke before passing a Query to the handler * @param interceptor the interceptor to invoke before passing a Query to the handler
* @return handle to unregister the interceptor
*/ */
public void registerHandlerInterceptor(MessageHandlerInterceptor<QueryMessage<?, ?>> interceptor) { public Registration registerHandlerInterceptor(MessageHandlerInterceptor<QueryMessage<?, ?>> interceptor) {
this.handlerInterceptors.add(interceptor); handlerInterceptors.add(interceptor);
return () -> handlerInterceptors.remove(interceptor);
} }


/** /**
* Registers an interceptor that intercepts Queries as they are sent. Each interceptor is called * Registers an interceptor that intercepts Queries as they are sent. Each interceptor is called
* once, regardless of the type of query (point-to-point or scatter-gather) executed. * once, regardless of the type of query (point-to-point or scatter-gather) executed.
* *
* @param interceptor the interceptor to invoke when sending a Query * @param interceptor the interceptor to invoke when sending a Query
* @return handle to unregister the interceptor
*/ */
public void registerDispatchInterceptor(MessageDispatchInterceptor<QueryMessage<?, ?>> interceptor) { public Registration registerDispatchInterceptor(MessageDispatchInterceptor<QueryMessage<?, ?>> interceptor) {
this.dispatchInterceptors.add(interceptor); dispatchInterceptors.add(interceptor);
return () -> dispatchInterceptors.remove(interceptor);
} }


private <Q, R> Set<MessageHandler<? super QueryMessage<?, ?>>> getHandlersForMessage(QueryMessage<Q, R> queryMessage) { private <Q, R> Set<MessageHandler<? super QueryMessage<?, ?>>> getHandlersForMessage(QueryMessage<Q, R> queryMessage) {
Expand Down

0 comments on commit 6dd5efe

Please sign in to comment.