Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
510 C HAPTER 15 Web applications and web services In a second bundle, add a ServiceTracker that finds the "remote" service in list- ing 15.21. Because all of this example is happening in the same OSG i framework (it isn't distributed), you explicitly look for the service.imported service property to ensure that you find the "remote" version of your service versus the local service, both of which are published in the local framework's service registry. Listing 15.21 Tracking the "remote" service Filter filter = context.createFilter( "(&(" + Constants.OBJECTCLASS + "=" + Foo.class.getName() + ")(service.imported=*))"); ServiceTracker tracker = new ServiceTracker(context, filter, null) { @Override public Object addingService(ServiceReference reference) { System.out.println("Found " + reference + " !!!!!!!"); return super.addingService(reference); } @Override public void removedService(ServiceReference reference, Object service) { System.out.println("Lost " + reference + " !!!!!!!"); super.removedService(reference, service); } }; tracker.open();