Ejemplo n.º 1
0
  /**
   * Returns an appropriate commandStrategy after determining it using the CommandContext of the
   * request. If no such Strategy is found then a default strategy is returned back.
   *
   * @param commandContext
   * @return CommandStrategy
   * @see org.mifosplatform.batch.command.internal.UnknownCommandStrategy
   */
  public CommandStrategy getCommandStrategy(final CommandContext commandContext) {

    if (this.commandStrategies.containsKey(commandContext)) {
      return (CommandStrategy)
          this.applicationContext.getBean(this.commandStrategies.get(commandContext));
    }

    for (ConcurrentHashMap.Entry<CommandContext, String> entry :
        this.commandStrategies.entrySet()) {
      if (commandContext.matcher(entry.getKey())) {
        return (CommandStrategy)
            this.applicationContext.getBean(this.commandStrategies.get(entry.getKey()));
      }
    }

    return new UnknownCommandStrategy();
  }