public AllActiveEnginesChain(BundleContext context, String name) { if(context == null){ throw new IllegalArgumentException("The parsed BundleContext MUST NOT be NULL!"); } if(name == null || name.isEmpty()){ throw new IllegalArgumentException("The parsed Chain name MUST NOT be NULL!"); } this.context = context; this.name = name; Set<String> trackAll = Collections.emptySet(); this.tracker = new EnginesTracker(context, trackAll, //empty set to track all engines this); this.tracker.open(); }
@Activate protected void activate(ComponentContext ctx) { final BundleContext bc = ctx.getBundleContext(); engineTracker = new EnginesTracker(bc, Collections.<String>emptySet(), new ServiceTrackerCustomizer() { @Override public Object addingService(ServiceReference reference) { Object service = bc.getService(reference); if(service != null){ _enginesCache = null; //rebuild the cache on the next call } return service; } @Override public void modifiedService(ServiceReference reference, Object service) { _enginesCache = null; //rebuild the cache on the next call } @Override public void removedService(ServiceReference reference, Object service) { if(reference != null){ bc.ungetService(reference); _enginesCache = null; //rebuild the cache on the next call } } }); engineTracker.open(); }
@Activate protected void activate(ComponentContext ctx) { final BundleContext bc = ctx.getBundleContext(); engineTracker = new EnginesTracker(bc, Collections.<String>emptySet(), new ServiceTrackerCustomizer() { @Override public Object addingService(ServiceReference reference) { Object service = bc.getService(reference); if(service != null){ _enginesCache = null; //rebuild the cache on the next call } return service; } @Override public void modifiedService(ServiceReference reference, Object service) { _enginesCache = null; //rebuild the cache on the next call } @Override public void removedService(ServiceReference reference, Object service) { if(reference != null){ bc.ungetService(reference); _enginesCache = null; //rebuild the cache on the next call } } }); engineTracker.open(); }
tracker = new EnginesTracker(ctx.getBundleContext(), chain.keySet(),this); tracker.open();