Add a BeanParseListener interface to DynamicOptions.

This interface extends the DynamicBean interface allowing beans to
access the Bean immediately before or after option parsing is done on the
DynamicBeans.  The plumbing is added to both the SSH and RestAPI layers
to actually call this bean during parsing.

Change-Id: Id39edfedc9612c42b8c35470e52cacc05d86bf43
This commit is contained in:
Martin Fick
2016-09-13 10:08:14 -06:00
committed by Zac Livingston
parent 4f083a841d
commit 156c9c9fac
3 changed files with 74 additions and 17 deletions

View File

@@ -63,7 +63,10 @@ class ParameterParser {
T param, ListMultimap<String, String> in, HttpServletRequest req, HttpServletResponse res)
throws IOException {
CmdLineParser clp = parserFactory.create(param);
DynamicOptions.parse(dynamicBeans, clp, param);
DynamicOptions pluginOptions = new DynamicOptions(param, dynamicBeans);
pluginOptions.parseDynamicBeans(clp);
pluginOptions.setDynamicBeans();
pluginOptions.onBeanParseStart();
try {
clp.parseOptionMap(in);
} catch (CmdLineException | NumberFormatException e) {
@@ -84,6 +87,7 @@ class ParameterParser {
replyBinaryResult(req, res, BinaryResult.create(msg.toString()).setContentType("text/plain"));
return false;
}
pluginOptions.onBeanParseEnd();
return true;
}