/**
   * Executes the command
   *
   * @throws CommandException
   */
  public void runCommand() throws CommandException, CommandValidationException {
    validateOptions();

    String addon = null;
    try {
      addon = (String) operands.firstElement();
      AddonControl ac = new AddonControl();
      ac.uninstall(addon);
    } catch (Throwable t) {
      CLILogger.getInstance().printDetailMessage(t.getLocalizedMessage());
      throw new CommandException(getLocalizedString("UninstallAddonFailed", new Object[] {addon}));
    }

    CLILogger.getInstance()
        .printDetailMessage(getLocalizedString("UninstallAddonCompleted", new Object[] {addon}));
  }
  /**
   * This routine will display the exception message if the option --terse is given. This routine
   * will get the root of the exception and display the message. It will then wrap it with
   * CommaneException and throw the exception to be handled by CLI framework.
   *
   * @param e
   * @throws CommandException
   */
  public void displayExceptionMessage(Exception e) throws CommandException {
    // get the root cause of the exception
    Throwable rootException = ExceptionUtil.getRootCause(e);

    if (rootException.getLocalizedMessage() != null)
      CLILogger.getInstance().printDetailMessage(rootException.getLocalizedMessage());
    throw new CommandException(getLocalizedString("CommandUnSuccessful", new Object[] {name}), e);
  }
  /**
   * An abstract method that Executes the command
   *
   * @throws CommandException
   */
  public void runCommand() throws CommandException, CommandValidationException {
    if (!validateOptions()) throw new CommandValidationException("Validation is false");

    // use http connector
    MBeanServerConnection mbsc =
        getMBeanServerConnection(
            getHost(), getPort(),
            getUser(), getPassword());
    final String targetName = (String) getOption(TARGET_NAME);

    // if targetName is not null, then try to get the Config ObjectName of the
    // target before creating the resource because we don't want to create
    // the resource if the target does not exist.
    ObjectName scON =
        (targetName != null && !targetName.equals(DOMAIN))
            ? getTargetConfigObjectName(mbsc, targetName)
            : null;

    final Object[] params = getParamsInfo();
    final String operationName = getOperationName();
    final String[] types = getTypesInfo();

    try {
      Object returnValue =
          mbsc.invoke(Util.newObjectName(DOMAIN_CONFIG_OBJECT_NAME), operationName, params, types);
      if (scON != null) {
        // create reference to the target
        mbsc.invoke(
            scON,
            "createResourceRefConfig",
            new Object[] {new String((String) getOperands().get(0))},
            new String[] {"java.lang.String"});
      }
      CLILogger.getInstance()
          .printDetailMessage(getLocalizedString("CommandSuccessful", new Object[] {name}));

    } catch (Exception e) {
      displayExceptionMessage(e);
    }
  }