|
|
Re: Loading DS service from XML file [message #1111539 is a reply to message #1110937] |
Wed, 18 September 2013 11:02 |
ALex W Messages: 56 Registered: July 2012 |
Member |
|
|
Hello,
I didn't know LDAP filter.
I was reading how it works, and it seems like it only means that a service requires a specific service (one that matches the filter).
Unless there is something I'm missing, this is not what I want.
The user should have the choice to select a service.
Let's say I want to communicate with a physical device (arduino, Raspberry), and there are multiple available protocols (Serial, USB, or Ethernet)
The specific controller for the Arduino or the Raspberry Pi can use any of the communication, it's only a choice of the user, depending on which connection he chose.
I don't know if I'm being clear, but there is no technical constraint in the choice of the implementation, except the physical setup.
|
|
|
Re: Loading DS service from XML file [message #1111570 is a reply to message #1111539] |
Wed, 18 September 2013 11:56 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You can query the OSGi-Registry using the LDAP-Filter so let's assume
you have a service named DeviceService and you contribute those through DS:
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="usb.deviceservice">
> <implementation class="usb.USBDeviceService"/>
> <service>
> <provide interface="services.DeviceService"/>
> </service>
> <property name="deviceType" type="String" value="USB"/>
> </scr:component>
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="serial.deviceservice">
> <implementation class="serial.SerialDeviceService"/>
> <service>
> <provide interface="services.DeviceService"/>
> </service>
> <property name="deviceType" type="String" value="Serial"/>
> </scr:component>
If you know want to find all services who have deviceType==Serial you
query for them as:
BundleContext bc = ...;
Collection<ServiceReference<DeviceService>> ref =
bc.getServiceReferences(DeviceService.class, "(deviceType=Serial)");
if you know let the user choose the deviceType in the UI and e.g. store
it into your preferences all parts can reach out to the preference and
find the appropriate services
Tom
On 18.09.13 13:02, ALex W wrote:
> Hello,
>
> I didn't know LDAP filter. I was reading how it works, and it seems like
> it only means that a service requires a specific service (one that
> matches the filter).
> Unless there is something I'm missing, this is not what I want.
> The user should have the choice to select a service. Let's say I want to
> communicate with a physical device (arduino, Raspberry), and there are
> multiple available protocols (Serial, USB, or Ethernet)
>
> The specific controller for the Arduino or the Raspberry Pi can use any
> of the communication, it's only a choice of the user, depending on which
> connection he chose.
>
> I don't know if I'm being clear, but there is no technical constraint in
> the choice of the implementation, except the physical setup.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03975 seconds