Thank you. The log service got me squared away. Newbie mistake.

And thanks for the comment about the ServiceListener. I've been seeing a
lot about utilization of "high level apis" as opposed to "low level" and
I'm just beginning to understand what that means in an osgi world.

Regards,
Shawn

>> From: [email protected]
>>
>> I have been working with OSGi for a few months and recently started
>> learning about and implementing configuration management with with
>> declarative services. I have created a Component Factory following the
>
> The term Component Factory means something else in the DS spec. I think
> you mean Factory Configurations (see 112.7 in the spec).
>
>> Multiton method following the example at
>> http://wiki.osgi.org/wiki/Declarative_Services.
>>
>> Using Apache Web Console I have confirmed that when I create a new
>> component with String instancePid =
>> configAdmin.createFactoryConfiguration(factoryPid, null) the new
> instance
>> shows up in the console and is registered under the appropriate
> interface.
>>
>> I have a ServiceListener listening for service registration. Below is
> and
>
> Why are you implementing ServiceListener if you are using DS? The main
> value of DS is completely avoiding using the raw service API. To use one
> of the services, just have your component reference the service. See 112.3
> in the spec and the @Reference annotation.
>
>> example of the serviceChanged method I have implemented. I get the
>> component ServiceReference but when I try to get the interface from
>> BundleContext it is always null.
>>
>> public void serviceChanged(ServiceEvent event)
>> {
>>    ServiceReference ref = event.getServiceReference();
>>    Object sid = ref.getProperty(Constants.SERVICE_PID);
>>    if(sid != null && sid instanceof String && ( (String)sid
>> ).equals(instancePid ) )
>>    {
>>       if(event.getType() == ServiceEvent.REGISTERED)
>>       {
>>           MyInterface interface =
>> (MyInterface)bundleContext.getService(ref);
>>        >>>> I make it here but interface is always null.
>
> Have you checked the LogService for possible logged exceptions activating
> the components? DS will use a ServiceFactory to register the service and
> then instantiate the component instance to return a service object. If
> there is an exception doing this, null will be returned.
>
>>       }
>>    }
>> }
>>
>> As an alternate approach I tried utilizing a service tracker for
>> MyInterface and addService calls are received, but the incoming
> interface
>> is again always null.
>>
>> I confirmed that the bundle (where I am get the bundle context from) is
>> ACTIVE. I checked ServiceReference.isAssignableTo on my bundle and
>> MyInterface.class.getName() and it returns true.
>>
>> I have dealt with singleton services and never had a problem getting
>> MyInterface using the above approach. Is there something different about
>> how components from a component factory get registered using DS?
>>
>> I use the equinox implementation of ogsi, DS, and CM with BND.
>>
>> I suspect that I'm missing something fundamental, or got my wires
> crossed
>> on utilizing factories versus services, but I can't quite see where the
>> problem is. Any guidance is appreciated.
>
> --
>
> BJ Hargrave
> Senior Technical Staff Member, IBM
> OSGi Fellow and CTO of the OSGi Alliance
> [email protected]
>
> office: +1 386 848 1781
> mobile: +1 386 848 3788
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to