Marcus Crafter wrote:
> Hi All,
>
> Hope all is well.
>
> Currently in our project we're doing an internal migration from
> hand made classes to avalon components (yippee!).
>
> We've come across the occasion several times where we would like to
> access a global configuration value, set outside of that
> components configuration hierarchy in an xconf file.
>
> I've brought this up before in an earlier post, and a
> suggestion from Giacomo was to use ECM's Context to store these global
> values.
>
> I like this idea, but it means having to manually read the
> configuration file before passing it onwards to ECM.
>
> No problem, but how about automating this a little by enhancing
> ECM/ComponentManager so that root level attributes in xconf files are
> automatically added to ECM's Context ?
>
> ie:
>
> <application version="value" variable1="value" variable2="">
> <component>
> ...
> </component>
> ...
> ...
> </application>
>
> ...
>
> String version = this.context.get("version");
>
> This would remove the need to do this step manually, and would
> provide a nice place for globals.
It would be possible, and every container has their own requirements.
With the ContainerManager work going on, you would extend the configure
method and extract what you need ahead of time. You also have to
consider that Context does not limit you to strings. So how would you
represent non-string constants?
To make it clear what are global values, I would do something like this:
<application>
<context><!-- can be renamed to "global" or whatever -->
<!-- defaults to string -->
<entry name="version" value="1.0.3"/>
<entry name="work-dir" value="/tmp/application/${version}/"
type="java.io.File"/>
<!-- Type must accept 1 string in constructor -->
</context>
<component/>
</application>
This would allow you to resolve your context values with other entries
(already available with Context), as well as have additional types than
simply String--provided that the constructor accepts one String in the
constructor.
--
"They that give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
- Benjamin Franklin
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>