@Override
  public void doAction(String action) throws PluginException {
    String appManager = getAppManagerName();

    String name = getConfig().getValue(WebsphereProductPlugin.PROP_APP_NAME);
    Object[] args = new Object[] {name};

    String method;

    if (action.equals("start")) {
      method = "startApplication";
    } else if (action.equals("stop")) {
      method = "stopApplication";
    } else {
      throw new PluginException("unsupported action=" + action);
    }

    getLog()
        .debug("doAction: action=" + action + ", method=" + method + ", appManager=" + appManager);

    try {
      this.jmxProps.list(System.out);

      WebsphereUtil.invoke(appManager, this.jmxProps, method, args, APP_SIG);
      setResult(RESULT_SUCCESS);
    } catch (PluginException e) {
      setResult(RESULT_FAILURE);
      getLog().debug("doAction: invoke failed", e);
      throw new PluginException(e.getMessage(), e);
    }

    getLog().debug("doAction: result=" + getResult());
  }
  /**
   * Send an agent a plugin configuration. This is needed when agents restart, since they do not
   * persist control plugin configuration.
   */
  private ControlGetPluginConfig_result cmdControlGetPluginConfig(ControlGetPluginConfig_args args)
      throws LatherRemoteException {
    ControlGetPluginConfig_result res;

    byte[] cfg;

    try {
      cfg = controlManager.getPluginConfiguration(args.getPluginName(), args.getMerge());
    } catch (PluginException exc) {
      log.warn("Error getting control config for plugin '" + args.getPluginName() + "'", exc);
      throw new LatherRemoteException(
          "Error getting control config "
              + "for plugin '"
              + args.getPluginName()
              + "': "
              + exc.getMessage());
    }

    res = new ControlGetPluginConfig_result();
    res.setConfig(cfg);
    return res;
  }
 /**
  * Retrieves the listener properties from the server.xml file, then creates the jmx.url based on
  * the properties.
  *
  * @param config The ConfigResponse object.
  * @param basePath The base file path of the configuration, "/conf/server.xml" is added to this.
  * @return Whether the configuration was found and set on the config response object.
  * @throws PluginException
  */
 private boolean configureListenerMxURL(ConfigResponse config, String basePath)
     throws PluginException {
   boolean found = false;
   XmlPropertiesFileRetriever propertiesRetriever = new ServerXmlPropertiesRetriever();
   try {
     Map<String, String> listenerProperties =
         propertiesRetriever.getPropertiesFromFile(
             basePath + "/conf/server.xml",
             "Listener",
             "className",
             "com.springsource.tcserver.serviceability.rmi.JmxSocketListener");
     if (!listenerProperties.isEmpty()) {
       String addressProperty = listenerProperties.get("address");
       if (addressProperty == null) {
         addressProperty = listenerProperties.get("bind");
       }
       String bindAddressValue = getValueFromPropertiesFile(basePath, addressProperty);
       String portValue = getValueFromPropertiesFile(basePath, listenerProperties.get("port"));
       config.setValue(
           mxUtil.getJmxUrlProperty(),
           "service:jmx:rmi:///jndi/rmi://" + bindAddressValue + ":" + portValue + "/jmxrmi");
       found = true;
     }
   } catch (PluginException e) {
     // the properties were not accessible
     config.setValue(mxUtil.getJmxUrlProperty(), DEFAULT_JMX_URL);
     logger.warn(
         "Unable to retrieve properties for discovery, using default "
             + mxUtil.getJmxUrlProperty()
             + "="
             + DEFAULT_JMX_URL);
     if (logger.isDebugEnabled()) {
       logger.debug(e.getMessage(), e);
     }
   }
   return found;
 }