karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david.a.jen...@gmail.com>
Subject Re: How's config connected to a bundle
Date Wed, 06 Dec 2017 21:36:55 GMT
I’d expect your component with a specified PID to work, are you sure it didn’t?  It turns
out that DS cannot reliably set the bundle location; when it tried to it turns out there is
an unavoidable race condition.  Therefore DS does not try to set the bundle location, so don’t
expect it to change.

I generally use the default component pid (the fully qualified class name or component name
if specified) or give it a name distinct from the bundle name unless the config is shared
by several components in the same bundle.

david jencks

> On Dec 6, 2017, at 11:43 AM, Steinar Bang <sb@dod.no> wrote:
> How's karaf config connected to a bundle?
> I tried matching on bundle name.  Ie. I have a bundle with symbolic-name
> no.priv.bang.sonar.sonar-collector-webhook so I tried creating a config
> with a PID identical to this, ie.
> config:edit no.priv.bang.sonar.sonar-collector-webhook
> config:property-set sonar.collector.jdbc.url "jdbc:postgresql:///sonarcollector"
> config:property-set sonar.collector.jdbc.user "karaf"
> config:update
> but the resulting config isn't fed to a component in the bundle.  All I
> get there, is the stuff sett in the attributes.
> Ie. what I received in the activate method is this:
> {alias=/sonar-collector, component.name=no.priv.bang.sonar.collector.webhook.SonarCollectorServlet,
> I tried adding the pid like I found in this example:
> https://github.com/paremus/hello-examples/blob/37c9b2b1ac430227f0d92bf336be6cf5a59c079a/helloworld/helloworld-ds/src/main/java/com/example/hello/impl/GreetingImpl.java#L19
> ie. like so:
> @Component(service={Servlet.class}, property={"alias=/sonar-collector"}, configurationPid
= "no.priv.bang.sonar.sonar-collector-webhook" )
> public class SonarCollectorServlet extends HttpServlet {
>    ...
>    @Activate
>    public void activate(Map<String, Object> config) {
>    ...
> but that didn't help.
> The config can be found but show up as without a null BundleLocation:
> karaf@root()> config:list "(service.pid=no.priv.bang.sonar.sonar-collector-webhook)"
> ----------------------------------------------------------------
> Pid:            no.priv.bang.sonar.sonar-collector-webhook
> BundleLocation: null
> Properties:
>    service.pid = no.priv.bang.sonar.sonar-collector-webhook
>    sonar.collector.jdbc.url = jdbc:postgresql:///sonarcollector
>    sonar.collector.jdbc.user = karaf
> karaf@root()>
> Would it have helped if my bundle had shown up in the BundleLocation?
> What does it take to get a bundle there?
> Thanks!
> - Steinar

View raw message