Service reference in Activator class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Service reference in Activator class

Dominik Marciniszyn
This post has NOT been accepted by the mailing list yet.
Hi,

I would like to get access to the service by getServiceReference method. I've put my code in Activator class but service reference always returns null. Is it possible to get a service reference in bundle which provides it by placing code in Activator? I mean could I do something to avoid getting null from this service?

Thanks for any help,
Dominik Marciniszyn
Reply | Threaded
Open this post in threaded view
|

Re: Service reference in Activator class

fpapon
This post has NOT been accepted by the mailing list yet.
Hi,

Can you share your Activator code ?

Reply | Threaded
Open this post in threaded view
|

Re: Service reference in Activator class

Dominik Marciniszyn
This post has NOT been accepted by the mailing list yet.
Hi

public class Activator implements BundleActivator {

        public void start(BundleContext context) throws Exception {        
                ServiceReference serviceReference = context.getServiceReference(IMyService.class);
                IMyService locSup = context.getService(serviceReference);
        }
       
        public void stop(BundleContext context) throws Exception {

        }
}

This is my simple Activator class. The IMyService interface contains methods that I need to use when the Service will be avaliable. The default implementation for the interface is located in the bundle itself.