Dear Peter,
Thanks very much.
Thanks & Regards
Syed
8553043179
On Wednesday 25 September 2013 03:06 PM, [email protected]
wrote:
Send osgi-dev mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://mail.osgi.org/mailman/listinfo/osgi-dev
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of osgi-dev digest..."
Today's Topics:
1. Re: Component factory and declarative services (BJ Hargrave)
2. Re: Component factory and declarative services ([email protected])
3. How to start with Osgi ([email protected])
4. Re: How to start with Osgi (Peter Kriens)
----------------------------------------------------------------------
Message: 1
Date: Tue, 24 Sep 2013 17:20:18 -0400
From: BJ Hargrave <[email protected]>
To: OSGi Developer Mail List <[email protected]>
Subject: Re: [osgi-dev] Component factory and declarative services
Message-ID:
<of671b2616.349d2aa6-on85257bf0.007485ac-85257bf0.00753...@us.ibm.com>
Content-Type: text/plain; charset="us-ascii"
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.
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev