Input Arguments of Java Plugin
Please make sure you have the basic knowledge about Java Plugin before continue reading.
You should definitely need some arguments / configs to run your plugin, for a general plugin test flow, it will take some arguments as input, and the test result will be the output.
graph TD;
A[Input Arguments] --> B[Plugin];
B -- execute --> Output;
And there are two types of arguments: dynamic ones and static ones. In Java Plugin, those dynamic arguments are called Parameters, which will be passed from command line, and the static ones are called Configurations, which will be read from config file. Java Plugin Framework supports auto parsing arguments into provided Java Entity.
Plugin Parameter (dynamic arguments) ¶
Usage ¶
Below is a brief command line example to execute a hello-world plugin jar:
java -jar hello-world.jar -url "https://mct.webex.com/healthcheck" -positiveMatch "OKOKOK"
-url "https://mct.webex.com/healthcheck" -positiveMatch "OKOKOK" are the command line arguments. In this case, if you provide a Java Entity whose field matches above parameter key, the value will be auto mapped:
// entity to hold command line arguments
public class Parameter {
private String url;
private String positiveMatch;
// getter and setter
}
On this example, an instance of Parameter with value {url="https://mct.webex.com/healthcheck", positiveMatch="OKOKOK"} will be created at runtime, and it will be passed to plugin's execute() method.
Supported Command Line Format ¶
- camel case key: such as
-positiveMatch "OKOKOK", can be mapped to fieldParameter.positiveMatch. - dash separated key: such as
-positive-match "OKOKOK", can be mapped to fieldParameter.positiveMatch. - underline separated key: such as
-positive_match "OKOKOK", can be mapped to fieldParameter.positiveMatch.
Plugin Configuration (static arguments) ¶
Below is a brief config file example of hello-world plugin:
connectionTimeout = 10000
socketTimeout = 10000
In this case, if you provide a Java Entity whose field matches above property key, the value will be auto mapped:
// entity to hold configuration properties
public class Config {
private int connectionTimeout;
private int socketTimeout;
// getter and setter
}
On this example, an instance of Config with value {connectionTimeout=10000", socketTimeout=10000} will be created at runtime, and it will be passed to plugin's execute() method.
Supported Property Format ¶
- case-insensitive matched key: such as
connectiontimeout = 10000, can be mapped to fieldConfig.connectionTimeout. - dot separated case-insensitive matched key: such as
connection.timeout = 10000, can be mapped to fieldConfig.connectionTimeout. - dot separated last word case-insensitive matched key: such as
http.connectiontimeout = 10000, can be mapped to fieldConfig.connectionTimeout.