handle arrays for pids (#557)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2019-02-10 21:57:23 +01:00 committed by Markus Rathgeb
parent c5047f23af
commit e96aa523fc

View File

@ -310,10 +310,16 @@ public class ConfigurableServiceResource implements RESTResource {
private String getServiceId(ServiceReference<?> serviceReference) {
Object pid = serviceReference.getProperty(Constants.SERVICE_PID);
if (pid != null) {
return (String) pid;
} else {
return (String) serviceReference.getProperty(ComponentConstants.COMPONENT_NAME);
if (pid instanceof String) {
return (String) pid;
} else {
String[] pidArray = (String[]) pid;
if (pidArray.length > 0) {
return pidArray[0];
}
}
}
return (String) serviceReference.getProperty(ComponentConstants.COMPONENT_NAME);
}
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)