Class OptionsAndArgs

java.lang.Object
org.jolokia.jvmagent.client.util.OptionsAndArgs

public final class OptionsAndArgs extends Object
Class representing options and arguments known to the client launcher. It also knows how to parse the command line.
Since:
12.08.11
Author:
roland
  • Constructor Details

    • OptionsAndArgs

      public OptionsAndArgs(Set<String> pCommands, String... pArgs)
      Parse a list of arguments. Options start with '--' (long form) or '-' (short form) and are defined in and . For options with arguments, the argument can bei either provided in the form '--option=value' or '--option value'. Everything which is not an option is considered to be an argument. Two arguments are allowed: The command (first) and the PID (second). Any non-numeric PID is considered to be a pattern. Either getPid() or getProcessPattern() is set.

      If no PID/pattern and no command is given the "list" command is implied. If as first argument a pure numeric value or a pattern (which must not be equal to a valid command) is given, then "toggle" is infered with the given PID/pattern.

      Parameters:
      pCommands - set of commands which are known
      pArgs - arguments as given on the command line
      Throws:
      IllegalArgumentException - if parsing fails
  • Method Details

    • toAgentArg

      public String toAgentArg()
      Convert options to agent readable options (i.e. a single string with options separated by commas)
      Returns:
      agent string
    • getPid

      public String getPid()
      Process id as given as argument (if any). If a pattern for matching the process name is used, this method returns null.
      Returns:
      process id or null
    • getProcessPattern

      public Pattern getProcessPattern()
      A pattern used for matching a process name. If getPid() return a non-null value, this method returns always null
      Returns:
      pattern to match a process name or null
    • getCommand

      public String getCommand()
      The command given as argument
      Returns:
      command
    • getExtraArgs

      public List<String> getExtraArgs()
      Get extra arguments in addition to the command, or an empty list
    • isQuiet

      public boolean isQuiet()
      Whether the program should be silent
      Returns:
      true if quiet mode is selected
    • getPort

      public String getPort()
      Get the configured port
    • getStartTimeout

      public int getStartTimeout()
      Get start timeout in milliseconds (defaults to 500ms).
      Returns:
    • isVerbose

      public boolean isVerbose()
      Verbose output if this is true
      Returns:
      true if verbose output is requested
    • needsVm

      public boolean needsVm()
      Return true if this command required an attached VM or false otherwise
      Returns:
      true if the command requires an attached VM
    • getJarFilePath

      public String getJarFilePath()
      Path to this agents jar file
      Returns:
      full path to jar file
    • getJarFileName

      public String getJarFileName()
      Name of the agents jar file
      Returns:
      short name of jar file containing this agent.
    • lookupJarFile

      public static File lookupJarFile()
      Lookup the JAR File from where this class is loaded
      Returns:
      File pointing to the JAR-File from where this class was loaded.