Get Profile property in Java code at run time in fabric
Issue
- Properties can be fetched using property-placeholder referring to a particular pid
- For known property key name(e.g. prop.key), one can retrieve the value using in blueprint or using @PropertyInject in Java.
- How to retrieve a value without dynamic property key.
E.g. A property file may have 100s properties:
prop.key.1=value1
prop.key.2=value2
...
prop.key.999=value999
-
Based on user input n (1...999), we need to retrieve corresponding property value
-
Assume there is a properties file (e.g. sample.properties) inside a fuse profile, and is defined inside the blueprint file
<cm:property-placeholder persistent-id="sample" />
**And a route is also inside the blueprint file**
<camelContext ...>
<route id="....">
...
<bean ref="someClass" method="process" />
...
</route>
</camelContext>
- The question is, how to access the properties inside the process function?
class SomeClass {
@PropertyInject(value = "mykey.count")
private String numOfKeys;
public void process(Exchange exchange) {
// This is just some example...
for (int i=0;i<Integer.valueOf(numOfKeys);i++) {
////////// Here is the question: How to get the property mykey.*?
}
}
}
Environment
- Red Hat JBoss Fuse
- 6.3.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.