Service Factory with Declared Service [message #1181219] |
Mon, 11 November 2013 08:05  |
Eclipse User |
|
|
|
Hy,
I use a Service Factory to control the creation of my Service Components.
Simply something like this:
public class LoggerServiceFactory implements ServiceFactory<ILogger>
{
@Override
public ILogger getService(Bundle bundle,
ServiceRegistration<ILogger> registration)
{
return new LoggerImpl();
}
@Override
public void ungetService(Bundle bundle,
ServiceRegistration<ILogger> registration, ILogger service) {
}
}
now I can register this factory at the bundle startup:
Hashtable<String, Object> props = new Hashtable<>();
bundleContext.registerService(ILogger.class.getName(), new LoggerFactory(), props);
My question now is:
How can I exchange the programmaticly registration on bundle startup with declarative services?
I have tried to declare it in the XML file like a normal Component but it does not work:
<implementation class="org.my.LoggerServiceFactory"/>
<service>
<provide interface="org.my.ILogger"/>
</service>
Thanks in advance.
Richard
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04011 seconds