@ Override public void start ( BundleContext context ) { initialContextFactories = initServiceTracker ( context , InitialContextFactory . class , ServiceTrackerCustomizers . ICF_CACHE ) ; objectFactories = initServiceTracker ( context , ObjectFactory . class , ServiceTrackerCustomizers . URL_FACTORY_CACHE ) ; icfBuilders = initServiceTracker ( context , InitialContextFactoryBuilder . class , ServiceTrackerCustomizers . LAZY ) ; urlObjectFactoryFinders = initServiceTracker ( context , URLObjectFactoryFinder . class , ServiceTrackerCustomizers . LAZY ) ; environmentAugmentors = initServiceTracker ( context , EnvironmentAugmentation . class , null ) ; environmentUnaugmentors = initServiceTracker ( context , EnvironmentUnaugmentation . class , null ) ; try { OSGiInitialContextFactoryBuilder builder = new OSGiInitialContextFactoryBuilder ( ) ; setField ( InitialContextFactoryBuilder . class , builder , true ) ; icfBuilder = builder ; } catch ( IllegalStateException e ) { // Log the problem at info level, but only log the exception at debug level, as in many cases this is not a real issue and people // don't want to see stack traces at info level when everything it working as expected. LOGGER . info ( Utils . MESSAGES . getMessage ( "unable.to.set.static.ICFB.already.exists" , getClassName ( InitialContextFactoryBuilder . class ) ) ) ; LOGGER . debug ( Utils . MESSAGES . getMessage ( "unable.to.set.static.ICFB.already.exists" , getClassName ( InitialContextFactoryBuilder . class ) ) , e ) ; } try { OSGiObjectFactoryBuilder builder = new OSGiObjectFactoryBuilder ( context ) ; setField ( ObjectFactoryBuilder . class , builder , true ) ; ofBuilder = builder ; } catch ( IllegalStateException e ) { // Log the problem at info level, but only log the exception at debug level, as in many cases this is not a real issue and people // don't want to see stack traces at info level when everything it working as expected. LOGGER . info ( Utils . MESSAGES . getMessage ( "unable.to.set.static.OFB.already.exists" , getClassName ( ObjectFactoryBuilder . class ) ) ) ; LOGGER . debug ( Utils . MESSAGES . getMessage ( "unable.to.set.static.OFB.already.exists" , getClassName ( ObjectFactoryBuilder . class ) ) , e ) ; } context . registerService ( JNDIProviderAdmin . class . getName ( ) , new ProviderAdminServiceFactory ( context ) , null ) ; context . registerService ( InitialContextFactoryBuilder . class . getName ( ) , new JREInitialContextFactoryBuilder ( ) , null ) ; context . registerService ( JNDIContextManager . class . getName ( ) , new ContextManagerServiceFactory ( ) , null ) ; context . registerService ( AugmenterInvoker . class . getName ( ) , AugmenterInvokerImpl . getInstance ( ) , null ) ; //Start the bundletracker that clears out the cache. (only interested in stopping events) // bt = new BundleTracker(context, Bundle.STOPPING, new ServiceTrackerCustomizers.CacheBundleTrackerCustomizer()); // bt.open(); }
private BundleTracker bt = null ;