[
https://issues.apache.org/jira/browse/FELIX-5355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15642636#comment-15642636
]
Pierre De Rop commented on FELIX-5355:
--------------------------------------
Committed in revision 1768405 a candidate fix for the support of dots in
configuration proxies.
added a patch in Configurable.java where the following conventions are now used:
- when a configuration proxy is accessing a given configuration key, first
javabean convention is used, as before, in order to lookup the property from
the dictionary:
getFooBar() or fooBar() method will access to "fooBar" property.
- then if no property value is found from the dictionary, then camel case
convention is used to lookup the property from the dictionary:
getFooBar() or fooBar() will access to "foo.bar" property
- else, if no property value is found, then metatype osgi spec is applied: any
single underscore is replaced by ".", unless a double "__" is found, in this
case the sequence of two underscores is replaced by a single underscore:
foo_bar() will access to "foo.bar"
foo__bar() will access to "foo_bar"
foo_BaR() will access to foo.BaR" property
See integration test in
org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5355_ConfigTypesWithDotsTest.java
> Allow to use properties having dots with configuration proxies
> --------------------------------------------------------------
>
> Key: FELIX-5355
> URL: https://issues.apache.org/jira/browse/FELIX-5355
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager
> Affects Versions: org.apache.felix.dependencymanager-r8
> Reporter: Pierre De Rop
> Assignee: Pierre De Rop
> Priority: Minor
> Fix For: org.apache.felix.dependencymanager-r9
>
> Attachments: FELIX-5355.patch
>
>
> Recently, a new feature has been introduced in DM to allow injecting
> type-safe configuration proxies when a ConfigurationDependency is used (see
> FELIX-5177).
> The principle is to deduce the name of a given property from a corresponding
> method name of the configuration proxy interface.
> However, in some cases, you have some component depending on some
> configuration with properties having some dots ("."), and this character
> can't be used in java methods. Of course, the properties can be renamed to
> new names without dots, but in some cases, when you want to use configuration
> proxies on some legacy components, you often can't modify the existing
> configuration properties.
> So, I would like to propose the attached patch which allows the support of
> dots in properties. the patch does the same done by DS: it maps the "\_"
> charater to ".". And if the property contains "\_" character, then you can
> use a double "__" underscore:
> For example, assuming you have the two properties in the configuration:
> {code}
> foo.param1=123
> foo_param2=456
> {code}
> then you can use the following method names:
> {code}
> public interface MyConfig {
> public String getFoo_param1(); // maps to "foo.param1"
> public String getFoo__param2(); // maps to "foo_param2"
> }
> {code}
> Is there any objections if I commit the attached patch ?
> thanks.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)