karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Ward <tim.w...@paremus.com>
Subject Re: How's config connected to a bundle
Date Thu, 07 Dec 2017 08:59:13 GMT
Hi Steinar,

That does look like it should be working - what do the scr commands display when you look
at your component? 

Note that your component will be activated without any configuration (for example if your
configuration doesn’t exist when the component’s bundle is started) because it is using
the default configuration policy of optional. This is why you see the component start up with
just the default properties. If starting without configuration causes your component to fail
then you should change this policy.

Tim

> On 6 Dec 2017, at 21:36, David Jencks <david.a.jencks@gmail.com> wrote:
> 
> 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,
component.id=2}
>> 
>> 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
>> 
> 


Mime
View raw message