new component: LoadPropertyFile

Steve Loughran <[email protected]> Tue, 28 Feb 2006 17:06:03 +0000
Newsgroups gmane.comp.java.smartfrog.devel
Message-ID <[email protected]>
There's a new component in the CVS repository, in the core/smartfrog 
section.

LoadPropertyFile, that lurks in services/os/Java will take the filename 
(untested) or resource name (tested) of a java properties file, and load 
it in its sfStart method, turning every property therein into an 
attribute of the component. It also sets up a list of tuples, 
properties, to the values of each pair. you can feed this in to anything 
that takes a list of properties, like the Ant component. Oh, that list 
is sorted.

 From the tests


#test1.properties

prop1=prop1
prop2=prop2
prop.three=prop3
4=prop4

and the deployment descriptor

#include "/org/smartfrog/services/filesystem/components.sf"
#include "/org/smartfrog/services/assertions/components.sf"
#include "/org/smartfrog/services/os/java/components.sf"

ResourceProperty extends Compound {

     sfSyncTerminate true;

     test1 extends LoadPropertyFile {
       resource "/org/smartfrog/test/system/java/test1.properties";
     }

     assertProp1 extends Assert {
       equalsString1 "prop1";
       equalsString2 LAZY test1:prop1;
     }

     assertProp2 extends Assert {
       equalsString1 "prop2";
       equalsString2 LAZY test1:prop2;
     }

    assertProp3 extends Assert {
       equalsString1 "prop3";
       equalsString2 LAZY test1:prop.three;
     }

}


We can use this to extract version info from a properties file into a 
.sf descriptor. If we move our version info storage to such a property 
file, we can have ant extract the version info from a classpath without 
having to run the version program, which is a pretty slow and complex 
way of doing it.

We can also dynamically pull in information from any properties file and 
work with it.

Next on the todo list (alongside tests for the untested bits), will be 
writing out a properties file. This lets anything that uses them as 
configuration files be easily configured.

Please play with the component if you have a need. I'm exploring some of 
the ways of binding smartfrog to new data structures in it, so things 
that work in this component may feed in to an xml component...

-steve


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642