Source:
<code>public GwtConfigComponent findWireComponentConfigurationFromPid(GwtXSRFToken xsrfToken, String pid, String factoryPid, Map<String, Object> extraProps) throws GwtKuraException { this.checkXSRFToken(xsrfToken); ConfigurationService cs = ServiceLocator.getInstance().getService(ConfigurationService.class); GwtConfigComponent comp = null; try { ComponentConfiguration conf = cs.getComponentConfiguration(pid); boolean checkIfWireComponentIsDeleted = false; if (conf != null) { checkIfWireComponentIsDeleted = conf.getConfigurationProperties().containsKey(DELETED_WIRE_COMPONENT); } if (conf == null || checkIfWireComponentIsDeleted) { conf = cs.getDefaultComponentConfiguration(factoryPid); if (conf != null) { conf.getConfigurationProperties().put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid); } if (conf != null && conf.getDefinition() == null) { String temporaryName = String.valueOf(System.nanoTime()); cs.createFactoryConfiguration(factoryPid, temporaryName, extraProps, false); try { <START> <END> final BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); String filterString = "(" + ConfigurationService.KURA_SERVICE_PID + "=" + temporaryName + ")"; Filter filter = bundleContext.createFilter(filterString); final ServiceTracker wireComponentTracker = new ServiceTracker(bundleContext, filter, null); wireComponentTracker.open(); wireComponentTracker.waitForService(SERVICE_WAIT_TIMEOUT); wireComponentTracker.close(); conf = cs.getComponentConfiguration(temporaryName); comp = createMetatypeOnlyGwtComponentConfiguration(conf); return comp; } catch (Exception ex) { throw new GwtKuraException(ex.getMessage()); } finally { cs.deleteFactoryConfiguration(temporaryName, false); } } } comp = createMetatypeOnlyGwtComponentConfiguration(conf); } catch (KuraException e) { throw new GwtKuraException("Could not retrieve component configuration!"); } return comp; }</code><technical_language>Yes, right. Thread.sleep guarantee services running, waitForService(long). feature requires, fit CountDownLatch Cyclic Barrier guarantee if if service is running, Worker Thread is working in asynchronous call in GWT, halt continue if temporary factory service is running in runtime</technical_language>

Target:
public GwtConfigComponent findWireComponentConfigurationFromPid(GwtXSRFToken xsrfToken, String pid, String factoryPid, Map<String, Object> extraProps) throws GwtKuraException { this.checkXSRFToken(xsrfToken); ConfigurationService cs = ServiceLocator.getInstance().getService(ConfigurationService.class); GwtConfigComponent comp = null; try { ComponentConfiguration conf = cs.getComponentConfiguration(pid); boolean checkIfWireComponentIsDeleted = false; if (conf != null) { checkIfWireComponentIsDeleted = conf.getConfigurationProperties().containsKey(DELETED_WIRE_COMPONENT); } if (conf == null || checkIfWireComponentIsDeleted) { conf = cs.getDefaultComponentConfiguration(factoryPid); if (conf != null) { conf.getConfigurationProperties().put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid); } if (conf != null && conf.getDefinition() == null) { String temporaryName = String.valueOf(System.nanoTime()); cs.createFactoryConfiguration(factoryPid, temporaryName, extraProps, false); try { String filterString = "(" + ConfigurationService.KURA_SERVICE_PID + "=" + temporaryName + ")"; ServiceUtil.waitForService(filterString, SERVICE_WAIT_TIMEOUT, TimeUnit.SECONDS); conf = cs.getComponentConfiguration(temporaryName); comp = createMetatypeOnlyGwtComponentConfiguration(conf); return comp; } catch (Exception ex) { throw new GwtKuraException(ex.getMessage()); } finally { cs.deleteFactoryConfiguration(temporaryName, false); } } } comp = createMetatypeOnlyGwtComponentConfiguration(conf); } catch (KuraException e) { throw new GwtKuraException("Could not retrieve component configuration!"); } return comp; }