You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Christian Schneider <ch...@die-schneider.net> on 2018/04/18 16:00:53 UTC
Working with String[] configs in DS
We have a component that requires an array of strings. See the code below
for the config declaration.
public @interface Config {
@AttributeDefinition(name = "Services list")
String[] services_list();
}
This works if we set the config attribute to be an array. It does not seem
to work though
when I configure the config using a .cfg file in karaf.
As far as I know there I can only use plain strings. So our list can be
represented as Service1,Service2 but this is not automatically converted to
an array.
I already asked this in osgi-dev and Neil answered that this will not work
out of the box.
So I wonder if we could tweak the handling of .cfg files in felix
fileinstall (I hope this is the correct project) so it already parses the
values and returns a String[].
Possible syntaxes could be:
String1,String2
[String1,String2]
I guess the second syntax would be safer as it is unlikely that this is
used in a config already.
What do you think?
Christian
--
--
Christian Schneider
http://www.liquid-reality.de
Computer Scientist
http://www.adobe.com
Re: Working with String[] configs in DS
Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Wednesday 18 April 2018 18:00:53 Christian Schneider wrote:
> We have a component that requires an array of strings. See the code below
> for the config declaration.
>
>
> public @interface Config {
>
>
> @AttributeDefinition(name = "Services list")
>
> String[] services_list();
>
>
> }
>
> This works if we set the config attribute to be an array. It does not seem
> to work though
> when I configure the config using a .cfg file in karaf.
>
> As far as I know there I can only use plain strings. So our list can be
> represented as Service1,Service2 but this is not automatically converted to
> an array.
>
> I already asked this in osgi-dev and Neil answered that this will not work
> out of the box.
> So I wonder if we could tweak the handling of .cfg files in felix
> fileinstall (I hope this is the correct project) so it already parses the
> values and returns a String[].
>
> Possible syntaxes could be:
> String1,String2
> [String1,String2]
>
> I guess the second syntax would be safer as it is unlikely that this is
> used in a config already.
>
> What do you think?
Works fine when using .config-files, see related issues in Karaf's JIRA and
Sling's configurations for Karaf, e.g.
https://github.com/apache/sling-org-apache-sling-karaf-configs/blob/master/src/main/resources/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-sling.config
Regards,
O.
> Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org