@Override public <T extends Domain> T getDomainEndpoint(Class<T> domainType, String location, String context) { Filter filter = utilsService.getFilterForLocation(domainType, location, context); return utilsService.getOsgiServiceProxy(filter, domainType); }
@Override public <T extends Domain> T getDomainEndpoint(Class<T> domainType, String location) { Filter filter = utilsService.getFilterForLocation(domainType, location); return utilsService.getOsgiServiceProxy(filter, domainType); }
@Override public <T extends Domain> List<T> getDomainEndpoints(Class<T> domainType, String location, String context) { Filter filterForLocation = utilsService.getFilterForLocation(domainType, location); ServiceReference[] allServiceReferences; try { allServiceReferences = bundleContext.getAllServiceReferences(domainType.getName(), filterForLocation.toString()); } catch (InvalidSyntaxException e) { // this can never happen, because the filter has been compiled before throw new RuntimeException(e); } List<T> result = new ArrayList<T>(); if (allServiceReferences == null) { LOGGER.info("no references found for filter: {}", filterForLocation); return result; } LOGGER.debug("found {} references for {}", allServiceReferences.length, filterForLocation); for (ServiceReference ref : allServiceReferences) { Object serviceId = ref.getProperty(Constants.SERVICE_ID); String filterString = String.format("(%s=%s)", Constants.SERVICE_ID, serviceId); try { T osgiServiceProxy = utilsService.getOsgiServiceProxy(FrameworkUtil.createFilter(filterString), domainType); result.add(osgiServiceProxy); } catch (InvalidSyntaxException e) { throw new RuntimeException(e); } } return result; }