public Future dispatch()

in src/main/java/org/apache/fineract/cn/command/internal/CommandBus.java [108:131]


  public <C, T> Future<T> dispatch(final C command, final Class<T> clazz) throws CommandProcessingException {
    this.logger.debug("CommandBus::dispatch-sync called.");
    // store command
    final CommandSource commandSource = this.storeCommand(command);
    CommandHandlerHolder commandHandlerHolder = null;
    try {
      // find command handling method
      commandHandlerHolder = this.findCommandHandler(command);
      commandHandlerHolder.logStart(command);

      final Object result = commandHandlerHolder.method().invoke(commandHandlerHolder.aggregate(), command);
      this.updateCommandSource(commandSource, null);

      commandHandlerHolder.logFinish(result);

      if (commandHandlerHolder.eventEmitter() != null) {
        this.fireEvent(result, commandHandlerHolder.eventEmitter());
      }

      return new AsyncResult<>(clazz.cast(result));
    } catch (final Throwable th) {
      throw this.handle(th, commandSource, (commandHandlerHolder != null ? commandHandlerHolder.exceptionTypes() : null));
    }
  }