Package org.jolokia.jvmagent.client.util
Class OptionsAndArgs
java.lang.Object
org.jolokia.jvmagent.client.util.OptionsAndArgs
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 Summary
ConstructorsConstructorDescriptionOptionsAndArgs(Set<String> pCommands, String... pArgs) Parse a list of arguments. -
Method Summary
Modifier and TypeMethodDescriptionThe command given as argumentGet extra arguments in addition to the command, or an empty listName of the agents jar filePath to this agents jar filegetPid()Process id as given as argument (if any).getPort()Get the configured portA pattern used for matching a process name.intGet start timeout in milliseconds (defaults to 500ms).booleanisQuiet()Whether the program should be silentbooleanVerbose output if this is truestatic FileLookup the JAR File from where this class is loadedbooleanneedsVm()Returntrueif this command required an attached VM orfalseotherwiseConvert options to agent readable options (i.e. a single string with options separated by commas)
-
Constructor Details
-
OptionsAndArgs
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. EithergetPid()orgetProcessPattern()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 knownpArgs- arguments as given on the command line- Throws:
IllegalArgumentException- if parsing fails
-
-
Method Details
-
toAgentArg
Convert options to agent readable options (i.e. a single string with options separated by commas)- Returns:
- agent 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
A pattern used for matching a process name. IfgetPid()return a non-null value, this method returns always null- Returns:
- pattern to match a process name or null
-
getCommand
The command given as argument- Returns:
- command
-
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
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()Returntrueif this command required an attached VM orfalseotherwise- Returns:
- true if the command requires an attached VM
-
getJarFilePath
Path to this agents jar file- Returns:
- full path to jar file
-
getJarFileName
Name of the agents jar file- Returns:
- short name of jar file containing this agent.
-
lookupJarFile
Lookup the JAR File from where this class is loaded- Returns:
- File pointing to the JAR-File from where this class was loaded.
-