- ServiceRegistration<B> addingService(final ServiceReference<D> reference, final D dom, final B binding) {
- final Dict props = Dict.fromReference(reference);
- final ServiceRegistration<B> reg = context.registerService(bindingClass, binding, props);
- LOG.debug("Registered {} adapter {} of {} with {} as {}", bindingClass.getName(), binding, dom, props, reg);
- return reg;
+ public void open(final boolean trackAllServices) {
+ LOG.debug("Starting tracker for {}", bindingClass.getName());
+ super.open(trackAllServices);
+ LOG.debug("Tracker for {} started", bindingClass.getName());
+ }
+
+ @Override
+ public ComponentHolder<B> addingService(final ServiceReference<D> reference) {
+ if (reference == null) {
+ LOG.debug("Null reference for {}, ignoring it", bindingClass.getName());
+ return null;
+ }
+ if (reference.getProperty(ServiceProperties.IGNORE_PROP) != null) {
+ LOG.debug("Ignoring reference {} due to {}", reference, ServiceProperties.IGNORE_PROP);
+ return null;
+ }
+
+ final D dom = context.getService(reference);
+ if (dom == null) {
+ LOG.debug("Could not get {} service from {}, ignoring it", bindingClass.getName(), reference);
+ return null;
+ }
+
+ final B binding = bindingFactory.apply(dom);
+ return new ComponentHolder<>(binding, componentFactory.newInstance(Dict.fromReference(reference, binding)));