in jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Registry.java [50:88]
public OSGi<T> waitForService(String filterString) {
Filter filter;
try {
filter = FrameworkUtil.createFilter(filterString);
}
catch (InvalidSyntaxException e) {
throw new RuntimeException();
}
return fromOsgiRunnable((bc, p) -> {
synchronized (Registry.this) {
FilteredPublisher<T> ep = new FilteredPublisher<>(p, filter);
_publishers.add(ep);
for (ServiceWithProperties<T> serviceWithProperties :
new ArrayList<>(_servicesWithPropertiesList)) {
ep.publishIfMatched(
serviceWithProperties.service,
serviceWithProperties.properties);
}
return () -> {
synchronized (Registry.this) {
_publishers.remove(ep);
for (ServiceWithProperties<T> serviceWithProperties :
new ArrayList<>(_servicesWithPropertiesList)) {
ep.retract(serviceWithProperties.service);
}
}
};
}
});
}