Skip to content

Commit

Permalink
handle arrays for pids (openhab#557)
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Kreuzer <[email protected]>
  • Loading branch information
kaikreuzer authored and maggu2810 committed Feb 10, 2019
1 parent c5047f2 commit e96aa52
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,16 @@ private List<ConfigurableServiceDTO> getConfigurableServices() {
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)
Expand Down

0 comments on commit e96aa52

Please sign in to comment.