/**
  * Invokes the @CommandHandler annotated method that accepts the given <code>command</code>.
  *
  * @param command The command to handle
  * @param unitOfWork The UnitOfWork the command is processed in
  * @return the result of the command handling. Is <code>null</code> when the annotated handler has
  *     a <code>void</code> return value.
  * @throws NoHandlerForCommandException when no handler is found for given <code>command</code>.
  * @throws Throwable any exception occurring while handling the command
  */
 @Override
 public Object handle(CommandMessage<Object> command, UnitOfWork unitOfWork) throws Throwable {
   try {
     return invoker.invokeHandlerMethod(command, ErrorReportingNoMethodFoundCallback.INSTANCE);
   } catch (InvocationTargetException e) {
     throw e.getCause();
   }
 }
 @SuppressWarnings({"unchecked"})
 private <T> List<Class<? extends T>> findAcceptedHandlerParameters() {
   final List<Class<? extends T>> handlerParameters = new LinkedList<Class<? extends T>>();
   for (Method m : ReflectionUtils.methodsOf(invoker.getTargetType())) {
     if (m.isAnnotationPresent(CommandHandler.class)) {
       handlerParameters.add((Class<T>) m.getParameterTypes()[0]);
     }
   }
   return handlerParameters;
 }
コード例 #3
0
 /**
  * Invoke the annotated Event Handler method for the given <code>event</code> on the target Saga.
  *
  * @param event The event to invoke the Event Handler for
  */
 public void invokeSagaEventHandlerMethod(EventMessage event) {
   try {
     invoker.invokeHandlerMethod(event);
   } catch (IllegalAccessException e) {
     throw new EventHandlerInvocationException(
         "Access to the Saga Event handler method was denied.", e);
   } catch (InvocationTargetException e) {
     throw new EventHandlerInvocationException(
         "An exception occurred while invoking the handler method.", e);
   }
 }
コード例 #4
0
 /**
  * Calls the appropriate handler method with the provided event.
  *
  * @param event The event to handle
  * @see org.axonframework.eventsourcing.annotation.EventSourcingHandler
  * @see org.axonframework.eventhandling.annotation.EventHandler
  */
 @Override
 protected void handle(DomainEventMessage event) {
   ensureInspectorInitialized();
   ensureInvokerInitialized();
   eventHandlerInvoker.invokeHandlerMethod(event);
 }
コード例 #5
0
 /** {@inheritDoc} */
 @Override
 public void handle(EventMessage event) {
   invoker.invokeHandlerMethod(event);
 }
コード例 #6
0
 /**
  * Indicates whether the handler of the target event indicates an ending event handler (i.e. is
  * annotated with {@link EndSaga}).
  *
  * @param event The event to investigate the handler for
  * @return <code>true</code> if handling the given <code>event</code> should end the lifecycle of
  *     the Saga, <code>false</code> otherwise.
  */
 public boolean isEndingEvent(EventMessage event) {
   MethodMessageHandler handler = invoker.findHandlerMethod(event);
   return handler != null && handler.getMethod().isAnnotationPresent(EndSaga.class);
 }