If you look at the existing stages, for example, the HTTP Client stages, you will see how they use the TimeNowEL
class to do this. You need to add elDefs
and evaluation
attributes to the @ConfigDef
annotation on your config parameter, like this:
evaluation = ConfigDef.Evaluation.EXPLICIT,
elDefs = { TimeNowEL.class },
You'll also need to add code to the processor to explicitly evaluate the config parameter:
// Field declarations
private ELVars configVars;
private ELEval configEval;
// Config property field name
private static final String CONFIG_NAME = "myConfig";
...
// in the processor init() method
configVars = context.createELVars();
configEval = context.createELEval(CONFIG_NAME);
...
// Per record, or per batch - however often you want to do this
TimeNowEL.setTimeNowInContext(resourceVars, new Date());
String evaluatedConfig = resourceEval.eval(resourceVars, myConfig, String.class);
Finally, since TimeEL
is not a part of the official API for custom stages, you will need to build the stagesupport
jar from source in the main datacollector
source tree, and include it in your custom processor. See the custom destination tutorial for details - that destination uses commonlib
for CSV formatting; you should be able to do something similar with stagesupport
.
Be aware that stagesupport
is not an official API; it can change without warning from one release to the next.