Re: [loom] [dna] Properties in component configurations

Peter Donald <peter-4lf8KW9E9MLMqX/[email protected]>
Newsgroups gmane.comp.java.jcontainer.interest
Message-ID <[email protected]>
On Fri, 14 Nov 2003 12:34 pm, Ryan Hoegg wrote:
> Wanted to get your thoughts on using properties in component
> configuration like in maven / jelly.
>
> My first thought is that it should be done transparently by the
> container, but I don't know if that should somehow be mentioned in DNA.
> Thoughts?

I definetly prefer this way. If I understand you correctly what you want to be 
able to do is something like variable interpolation in configuration ala

<foo>
  <dir>${loom.home}</dir>
</foo>

If you look in the CLIMain class in Loom you will see that we actually do this 
for kernel.xml. 

final Properties params = new Properties();
params.setProperty( "loom.home", home.getAbsolutePath() );
final Configuration root = ConfigUtil.expandValues( original, params );

So loom.home will be expanded in config xml. You could easily expand this to 
work with all components aswell. Maybe expand a set of default properties + 
any defined in SAR-INF/config.properties or something.

Alternatively you could use Jexl (http://jakarta.apache.org/commons/jexl) to 
expand properties (which is what maven uses). Jexl is good in that you get to 
do manipulation on objects (string caternating or cutting etc) and can invoke 
methods etc on values.

The final method would be to treat the whole config.xml as a jelly script and 
process it. 

The ConfigUtil post-processes the configuration after parsing but a far better 
approach would be to write an XMLFilterImpl that expands the variables it 
finds etc.

-- 
Cheers,

Peter Donald
The big mistake that men make is that when they turn thirteen or fourteen and
all of a sudden they've reached puberty, they believe that they like women.
Actually, you're just horny. It doesn't mean you like women any more at
twenty-one than you did at ten.                --Jules Feiffer (cartoonist)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.