Off the record

Aller au contenu | Aller au menu | Aller à la recherche

lundi 16 juin 2008

Update an XML node with Java and XPathAPI

Once you have the Document object, and want to update a Node...

Element e = (Element) XPathAPI.selectSingleNode((Node) document.getDocumentElement(), xpath);

That's it.

-> Might be smart to check that e is not null before trying to set the content ! :-)

mardi 3 juin 2008

Inject properties via a file with Spring

Easy !

<bean id="SAPconnectionProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location">

This configuration will create at runtime a Properties object and fill it with the properties contained in
Then i just have to inject this bean in a containing bean, which has indeed a member such as described below :

private Properties SAPconnectionProperties;
And appropriate getter and setter of course...