- public java.lang.AutoCloseable createInstance() {
- ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
-
- final KitchenServiceImpl kitchenService = new KitchenServiceImpl(toasterService);
-
- final Registration<NotificationListener> toasterListenerReg =
- getNotificationServiceDependency().registerNotificationListener( kitchenService );
-
- final KitchenServiceRuntimeRegistration runtimeReg =
- getRootRuntimeBeanRegistratorWrapper().register( kitchenService );
+ public AutoCloseable createInstance() {
+ // The KitchenServiceImpl instance is created and advertised with the OSGi registry via blueprint
+ // so obtain it here so we can return it to the config system. It's possible the blueprint container
+ // hasn't been created yet so we busy wait 5 min for the service.
+ final WaitingServiceTracker<KitchenService> tracker = WaitingServiceTracker.create(
+ KitchenService.class, bundleContext);
+ final KitchenService kitchenService = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);