getAllServiceReferences() for multiple devices
mstocum
Junior Member
Let's say I have multiple DVD players in one system, 41001 and 41002, and I want to grab a reference to 41002 specifically, is there an easy way to do this? I imagine I could call
Would something like
getAllServiceReferences("com.amx.duet.devicesdk.DiscDevice", null)
and iterate over the results, looking for a reference where the DUET_DEVICE property has a device number of 41002, but that seems a bit cumbersome.Would something like
getAllServiceReferences("com.amx.duet.devicesdk.DiscDevice", "(Duet-Device=41002:*)")
work? From the OSGi documentation, it seems it should. Comments
-
Yep. You got it. In fact you can search on any of the properties that are defined in your module manifest so you may find there is something more applicable that the virtual device number / you can define something more logical than a virtual device number. Those filters are LDAP format so you can start combining different properties in all sorts of useful ways.
Also, you may want to consider using getServiceReferences(..) as a opposed to getAllServiceReferences(..). This one only returns service references guaranteed to be classloader compatible with your bundle so will protect you against class cast exceptions when you try to start using it. -
Yep. You got it. In fact you can search on any of the properties that are defined in your module manifest so you may find there is something more applicable that the virtual device number / you can define something more logical than a virtual device number. Those filters are LDAP format so you can start combining different properties in all sorts of useful ways.
Do you have an example you can post? No matter what I try, if I specify any filter, I get nothing back. If I pass null for the filter, I get an array of every module of that type, which I can iterate over.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums