/** * 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; }
if (i == 10) throw new ConfigException("Unable to store contents of config to store."); String currentContents = store.write(name, contents, newContents); if (currentContents == null) break;
if (i == 10) throw new ConfigException("Unable to store contents of config to store."); String currentContents = store.write(name, contents, newContents); if (currentContents == null) break;
if (i == 10) throw new ConfigException("Unable to store contents of config to store."); String currentContents = store.write(name, contents, newContents); if (currentContents == null) break;