@PostConstruct
  @SuppressWarnings({"unchecked"})
  @Override
  public synchronized void subscribe() {
    for (final MethodMessageHandler commandHandler : inspector.getHandlers()) {
      CommandHandler<Object> handler =
          new CommandHandler<Object>() {
            @Override
            public Object handle(CommandMessage<Object> command, UnitOfWork unitOfWork)
                throws Throwable {
              T aggregate = loadAggregate(command);
              try {
                return commandHandler.invoke(aggregate, command);
              } catch (InvocationTargetException e) {
                throw e.getCause();
              }
            }
          };
      commandBus.subscribe(commandHandler.getPayloadType(), handler);
      registeredCommandHandlers.put(commandHandler.getPayloadType(), handler);
    }

    for (final ConstructorCommandMessageHandler<T> handler : inspector.getConstructorHandlers()) {
      commandBus.subscribe(
          handler.getPayloadType(), new AnnotatedConstructorCommandHandler(handler));
    }
  }
 /**
  * Create a SagaMethodMessageHandler for the given <code>methodHandler</code>. The
  * SagaMethodMessageHandler add information specific to the behavior of Sagas, such as the
  * association value and creation policy.
  *
  * @param methodHandler The handler for incoming events
  * @return a SagaMethodMessageHandler for the handler
  */
 public static SagaMethodMessageHandler getInstance(MethodMessageHandler methodHandler) {
   Method handlerMethod = methodHandler.getMethod();
   SagaEventHandler handlerAnnotation = handlerMethod.getAnnotation(SagaEventHandler.class);
   String associationPropertyName = handlerAnnotation.associationProperty();
   Method associationProperty;
   try {
     associationProperty =
         methodHandler.getPayloadType().getMethod(methodForProperty(associationPropertyName));
   } catch (NoSuchMethodException e) {
     throw new AxonConfigurationException(
         format(
             "SagaEventHandler %s.%s defines a property %s that is not "
                 + "defined on the Event it declares to handle (%s)",
             methodHandler.getMethod().getDeclaringClass().getName(),
             methodHandler.getMethodName(),
             associationPropertyName,
             methodHandler.getPayloadType().getName()),
         e);
   }
   String associationKey =
       handlerAnnotation.keyName().isEmpty()
           ? associationPropertyName
           : handlerAnnotation.keyName();
   StartSaga startAnnotation = handlerMethod.getAnnotation(StartSaga.class);
   SagaCreationPolicy sagaCreationPolicy;
   if (startAnnotation == null) {
     sagaCreationPolicy = SagaCreationPolicy.NONE;
   } else if (startAnnotation.forceNew()) {
     sagaCreationPolicy = SagaCreationPolicy.ALWAYS;
   } else {
     sagaCreationPolicy = SagaCreationPolicy.IF_NONE_FOUND;
   }
   return new SagaMethodMessageHandler(
       sagaCreationPolicy, methodHandler, associationKey, associationProperty);
 }