Thursday Nov 06, 2008

Admin CLI Pluggability - defining options and operands

GlassFish v3 Prelude formally launched today.  It's one of a kind app server based on OSGi modularity and HK2 component systems. With this architecture, developers can easily provide commands making CLI extensible and pluggable.  Sreeni has written an excellent blog on creating a CLI command.  He also provided a sample command to try out.   Believe me... it's that easy to write CLI command.


In this blog, I'll extend a bit more about defining a command's options and operands. Command's options and operands are variables denoted by the Param annotation:



@Param

String name;


Parameters can be added to @Param to determine the characteristic of the option or operand.  Here are the valid parameters:



  • primary - indicate that the variable is an operand.  If not defined, then the variable is an option.

  • name - option name. If not defined, then the variable name is the name of the option.

  • optional - indicate if the variable is an optional option or operand.  Default is true.

  • DefaultValue - default value of the option or operand.

  • AcceptableValues - comma separated acceptable values

  • ShortName - short name for te option. It has to be specified wit one character. e.g. "asadmin command-name -<short-name>=<option-value>"

  • Password - indicate if option is a password. If the option is a password, then the password value is declared in a passwordfile with the entrh, AS_ADMIN_<option-name>;=<password-value>. The passwordfile is passed in to asadmin command with --passwordfile option.

@Param variables can be of following types:





















 Type  Command line is specified as:

 java.lan.String  --option-name option-value

 java.util.Properties  --option-name key1=value1;key2=value2

 java.util.List  --option-name value1,value2

 java.util.Boolean  --option-name if option is true and --no-option-name if option is false.



I will provide some examples in follow-up blogs.

About

janeyoung

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News
Blogroll

No bookmarks in folder