/** * Returns a map file containing the parsed contents of a configuration. * * @param name The configuration name. * @return * The parsed configuration. * <br>Never <jk>null</jk>. * @throws IOException */ public synchronized ConfigMap getMap(String name) throws IOException { ConfigMap cm = configMaps.get(name); if (cm != null) return cm; cm = new ConfigMap(this, name); ConfigMap cm2 = configMaps.putIfAbsent(name, cm); if (cm2 != null) return cm2; register(name, cm); return cm; }
/** * Returns a map file containing the parsed contents of a configuration. * * @param name The configuration name. * @return * The parsed configuration. * <br>Never <jk>null</jk>. * @throws IOException */ public synchronized ConfigMap getMap(String name) throws IOException { name = resolveName(name); ConfigMap cm = configMaps.get(name); if (cm != null) return cm; cm = new ConfigMap(this, name); ConfigMap cm2 = configMaps.putIfAbsent(name, cm); if (cm2 != null) return cm2; register(name, cm); return cm; }
/** * Returns a map file containing the parsed contents of a configuration. * * @param name The configuration name. * @return * The parsed configuration. * <br>Never <jk>null</jk>. * @throws IOException */ public synchronized ConfigMap getMap(String name) throws IOException { name = resolveName(name); ConfigMap cm = configMaps.get(name); if (cm != null) return cm; cm = new ConfigMap(this, name); ConfigMap cm2 = configMaps.putIfAbsent(name, cm); if (cm2 != null) return cm2; register(name, cm); return cm; }
/** * Overwrites the contents of the config file. * * @param contents The new contents of the config file. * @param synchronous Wait until the change has been persisted before returning this map. * @return This object (for method chaining). * @throws IOException * @throws InterruptedException */ public ConfigMap load(String contents, boolean synchronous) throws IOException, InterruptedException { if (synchronous) { final CountDownLatch latch = new CountDownLatch(1); ConfigStoreListener l = new ConfigStoreListener() { @Override public void onChange(String contents) { latch.countDown(); } }; store.register(name, l); store.write(name, null, contents); latch.await(30, TimeUnit.SECONDS); store.unregister(name, l); } else { store.write(name, null, contents); } return this; }
/** * Overwrites the contents of the config file. * * @param contents The new contents of the config file. * @param synchronous Wait until the change has been persisted before returning this map. * @return This object (for method chaining). * @throws IOException * @throws InterruptedException */ public ConfigMap load(String contents, boolean synchronous) throws IOException, InterruptedException { if (synchronous) { final CountDownLatch latch = new CountDownLatch(1); ConfigStoreListener l = new ConfigStoreListener() { @Override public void onChange(String contents) { latch.countDown(); } }; store.register(name, l); store.write(name, null, contents); latch.await(30, TimeUnit.SECONDS); store.unregister(name, l); } else { store.write(name, null, contents); } return this; }
/** * Overwrites the contents of the config file. * * @param contents The new contents of the config file. * @param synchronous Wait until the change has been persisted before returning this map. * @return This object (for method chaining). * @throws IOException * @throws InterruptedException */ public ConfigMap load(String contents, boolean synchronous) throws IOException, InterruptedException { if (synchronous) { final CountDownLatch latch = new CountDownLatch(1); ConfigStoreListener l = new ConfigStoreListener() { @Override public void onChange(String contents) { latch.countDown(); } }; store.register(name, l); store.write(name, null, contents); latch.await(30, TimeUnit.SECONDS); store.unregister(name, l); } else { store.write(name, null, contents); } return this; }