log.debug("processing arguments: " + Strings.join(args, ","));
if (args.length == 0)
{
throw new CommandException("Command requires arguments");
}
String sopts = "-:";
LongOpt[] lopts =
{
};
Getopt getopt = new Getopt(null, args, sopts, lopts);
getopt.setOpterr(false);
int code;
int argidx = 0;
while ((code = getopt.getopt()) != -1)
{
switch (code)
{
case ':":
throw new CommandException
("Option requires an argument: " + args[getopt.getOptind() - 1]);
case '?":
throw new CommandException
("Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1]);
// non-option arguments
case 1:
{
String arg = getopt.getOptarg();
switch (argidx++)
{
case 0:
objectName = createObjectName(arg);
log.debug("mbean name: " + objectName);
break;
}
break;
}
}
}
return true;