Hi Jean-Philippe,

I actually don’t understand what you really mean by “correct value taken from a 
java service and not directly from a file”.
Do you mean an OSGi service that can provide the required information? Or do 
you mean a standard OSGi service like the config admin service? Or do you want 
to get the information from a properties file without reading it in code?

If the value is provided by a method of an OSGi service you have actually two 
options:
Reference the service, instantiate another bean for your parameter (e.g. one of 
type String) using the method as factory method and the referenced service as a 
factory. This has the disadvantage that the substitution is static (so even if 
the value changes in the service it will not in your TestClass instance). 
Alternatively you could change the test class to use the referenced service 
directly. In that case the implementation could query the value at each usage 
und would get the changes from the service.

If you read properties files or the config admin service there are properties 
placeholders for that. With the config admin properties there is also some 
dynamics possible but I haven’t really tried that out.

Best regards
Stephan


From: CLEMENT Jean-Philippe [mailto:[email protected]]
Sent: Dienstag, 3. September 2013 17:07
To: [email protected]
Subject: Blueprint string substitution / placeholder

Hi,

I would like to replace Blueprint string values, for instance in:
            <bean id=”sample” class=”test.TestClass”>
                        <argument value=”$(to.replace)” />
            </bean>

Where $(to.replace) would be substituted by the correct value taken from a java 
service and not directly from a file.

What would be the simplest way to do so? Is there a way to map a placeholder to 
a bean?

Best regards,
Jean-Philippe

[@@ OPEN @@]

Reply via email to