07-30-07 12:11 AM
Hey Guys,
Here's a tiny segment of code that shows how simple it could be to store the
xml configuration file in the DIT using the DAS. This comes from the DAS w
hich stores some of it's own configuration in the DIT.
LdapDASHelper.readDasMeta(
dasMetaDataGraph,
context,
metaDataObjectToRelativeDNCache );
This method first tries to read the configuration DataGraph (server.xml in D
IT). If it does not exist (First time server is started), it creates an ins
tance of the model and writes it to the DIT. The model of server.xml contai
ns all the server.xml defau
lts, so now all the defaults are stored in the DIT. Later, when needing to
change configuration values, the root object bean is gotten from the dasMeta
DataGraph like this:
Configuration configuration = dasMetaDataGraph.getRootDataObject();
The configuration object represent the root element of the configuration fil
e, and is generated from the XML Schema that contains the structure of the s
erver.xml file.
When changing the configuration, just turn on change logging on the DataGrap
h and when done, turn it off. Then use the DAS to write the changes. And t
hat's it. So it would be something like this:
dasMetaDataGraph.turnOnChangeLogging();
Make changes to Configuration and objects contained by configuration.
Then turn off change logging:
dasMetaDataGraph.turnOffChangeLogging();
And update the DIT:
LdapDASHelper.update(
dasMetaDataGraph,
context);
And finito.
Cheers,
- Ole
[ Post a follow-up to this message ]
|