public static void setPersistentFileForConfigAdmin()

in components/camel-blueprint-main/src/main/java/org/apache/camel/blueprint/CamelBlueprintHelper.java [228:269]


    public static void setPersistentFileForConfigAdmin(BundleContext bundleContext, String pid,
                                                       String fileName, final Dictionary props,
                                                       String symbolicName, Set<Long> bpEvents,
                                                       boolean expectReload) throws IOException, InterruptedException {
        if (pid != null) {
            if (fileName == null) {
                throw new IllegalArgumentException("The persistent file should not be null");
            } else {
                File load = new File(fileName);
                LOG.debug("Loading properties from OSGi config admin file: {}", load);
                org.apache.felix.utils.properties.Properties cfg = new org.apache.felix.utils.properties.Properties(load);
                for (Object key : cfg.keySet()) {
                    props.put(key, cfg.get(key));
                }

                ConfigurationAdmin configAdmin = CamelBlueprintHelper
                    .getOsgiService(bundleContext, ConfigurationAdmin.class);
                if (configAdmin != null) {
                    // ensure we update
                    // we *have to* use "null" as 2nd arg to have correct bundle location for Configuration object
                    final Configuration config = configAdmin.getConfiguration(pid, null);
                    LOG.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
                    // we may have update and in consequence, BP container reload, let's wait for it to
                    // be CREATED again
                    if (expectReload) {
                        CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, bundleContext, symbolicName, BlueprintEvent.CREATED, new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    config.update(props);
                                } catch (IOException e) {
                                    throw new RuntimeException(e.getMessage(), e);
                                }
                            }
                        });
                    } else {
                        config.update(props);
                    }
                }
            }
        }
    }