Hello,
I am exploring possibility of using felix and osgi in general for
developing home automation project on raspberry pi.
I created PinService of which one instance reflects one physical pin on
RPI. Instances are identified by property value. Now I am building service
which relay on two pins so I need two instances of PinServiceImpl in one
activator.
I am using Felix Dependency Manager to simplify dependencies and to inject
services. Below is a code that I am working with however it is not ideal as
it uses two different classes to inject one service to each class. I would
like to have two instances injected into one class.
Is there out of the box way to achieve this?
Is there better way to manage dependencies in osgi & felix?
in Activator:
public void init(BundleContext bundleContext, DependencyManager
dependencyManager) throws Exception {
{
dependencyManager.add(createComponent()
.setInterface(Object.class.getName(), null)
.setImplementation(PinConsumerFan.class)
.add(createServiceDependency()
.setService(IGPIOPin.class,
"(PinNumber=1)")
.setRequired(true))
.add(createServiceDependency().setService(LogService.class))
);
dependencyManager.add(createComponent()
.setInterface(Object.class.getName(), null)
.setImplementation(PinConsumerDispenser.class)
.add(createServiceDependency()
.setService(IGPIOPin.class,
"(PinNumber=2)")
.setRequired(true))
.add(createServiceDependency().setService(LogService.class))
);
}
Thanks in advance for any hints.
Regards
Jan Roman