On 10/18/11 10:41 PM, Marshall Schor wrote:
I'm thinking (outloud) here of another kind of approach. Suppose we keep the
idea that the main "place" for parameter definitions / settings, is in the XML.
Perhaps we could use injection ideas + Java annotations to simplify the Java
code.
Here's how it might work. You would define the parameters, etc., externally in
the XML, as is now done. But in the Java code, you would write something like
// this form if the name of the external parm differs from the variable name
@uimaParameter(ExternalParmName1)
String myStringParm;
// this form if the name of the external parm is the same as the variable
name
@uimaParameter
int myIntParam;
One of the things with the current approach which always annoys me is that I
have to specify the "configurationParameters" element over and over again,
and that it can easily get out of sync with the current implementation.
I always thought that we should cut it out, and put it in another xml
descriptor
which is included in the jar file.
But today it might be better to use annotations to define these
configuration
parameters, when they are strongly attached to the implementation.
When I can rely on the framework to check for my configuration
parameters settings (e.g. throw an
exception when one is not provided by a user) then I don't need to do
this error checking
twice (which e.g. OpenNLP does) and therefore I have to write less code
to do the same.
Additionally using annotations to inject parameters into instance
variables makes things
even easier and nicer to use.
Jörn