List of usage examples for java.util Dictionary remove
public abstract V remove(Object key);
From source file:Main.java
public static void main(String[] args) { Dictionary d = new Hashtable(); // add some elements d.put("1", "from java2s.com"); d.put("2", "Cocoa"); d.put("5", "from java2s.com"); // remove one element System.out.println(d.get("5")); System.out.println(d.remove("5") + " has been removed"); System.out.println(d.get("5")); }
From source file:edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal.PscFelixPersistenceManagerTest.java
public void testStoreAsUpdate() throws Exception { {// w ww. ja v a 2 s. c om Dictionary d = manager.load(GOOD_PID); d.put("favorite", "mezzanine"); d.put("first", 'W'); d.remove("letters"); manager.store(GOOD_PID, d); } Dictionary reloaded = manager.load(GOOD_PID); assertEquals("Updated value not updated", "mezzanine", reloaded.get("favorite")); assertNull("Removed property still present", reloaded.get("letters")); assertEquals("New property not present", 'W', reloaded.get("first")); }
From source file:com.oracle.osgi.jmx.compendium.ConfigAdminManager.java
@SuppressWarnings("unchecked") public void deleteProperty(String pid, String key) throws IOException { Configuration conf = admin.getConfiguration(pid, null); Dictionary props = conf.getProperties(); if (props != null) { props.remove(key); conf.update(props);/*from w w w . jav a 2s.c om*/ } }
From source file:com.oracle.osgi.jmx.compendium.ConfigAdminManager.java
@SuppressWarnings("unchecked") public void deleteProperty(String pid, String location, String key) throws IOException { Configuration conf = admin.getConfiguration(pid, location); Dictionary props = conf.getProperties(); if (props != null) { props.remove(key); conf.update(props);/*from ww w. j a v a2 s . c o m*/ } }
From source file:org.codice.pubsub.stomp.SubscriptionQueryMessageListener.java
private void removeSubscriptionFromMap(String subscriptionId) { Dictionary props = getSubscriptionMap(); props.remove(subscriptionId); setSubscriptionMap(props);/*from w w w . jav a2 s.c o m*/ }
From source file:com.oracle.osgi.jmx.compendium.ConfigAdminManager.java
@SuppressWarnings("unchecked") public void deletePropertyFromConfigurations(String filter, String key) throws IOException { Configuration[] confs;// w w w. ja v a 2s . co m try { confs = admin.listConfigurations(filter); } catch (InvalidSyntaxException e) { log.error("Invalid filter argument: " + filter, e); throw new IllegalArgumentException("Invalid filter: " + e); } if (confs != null) { for (Configuration conf : confs) { Dictionary dic = conf.getProperties(); if (dic != null) { dic.remove(key); conf.update(dic); } } } }
From source file:org.apache.ace.configurator.ConfiguratorTest.java
@Test(groups = { UNIT }) public void testAddFactoryConfiguration() throws Exception { String pid = "test-add"; String factoryPID = "testFactory"; Properties props = createProperties(); saveConfiguration(pid, "testFactory", props); Dictionary<String, ?> configuration = getAndWaitForConfigurationUpdate(factoryPID); assertNotNull(configuration, "No configuration received from configurator"); assertEquals(configuration.remove("factory.instance.pid"), "testFactory_test-add", "Incorrect factory instance pid was added to the configuration"); assertEquals(createProperties(), configuration, "Configuration content is unexpected"); }
From source file:org.codice.ddf.configuration.admin.ExportMigrationConfigurationAdminEntry.java
public boolean store() { if (!stored) { LOGGER.debug("Exporting configuration [{}] to [{}]...", configuration.getPid(), entry.getPath()); final Dictionary<String, Object> props = configuration.getProperties(); // just make sure the pid, bundle location, and factory pid are correct as sometimes they // might/* w ww . j a va2 s .c om*/ // get out of sync by an invalid update to the properties and we do rely on those at import // time final String factoryPid = configuration.getFactoryPid(); if (factoryPid != null) { props.put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid); } else { props.remove(ConfigurationAdmin.SERVICE_FACTORYPID); } props.put(Constants.SERVICE_PID, configuration.getPid()); final String location = configuration.getBundleLocation(); if (location != null) { props.put(ConfigurationAdmin.SERVICE_BUNDLELOCATION, location); } else { props.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION); } this.stored = entry.store((r, out) -> persister.write(out, props)); } return stored; }
From source file:org.codice.ddf.configuration.admin.ImportMigrationConfigurationAdminContext.java
@Nullable private ImportMigrationConfigurationAdminEntry proxy(ImportMigrationEntry entry) { final Path path = entry.getPath(); final String extn = FilenameUtils.getExtension(path.toString()); final PersistenceStrategy ps = admin.getPersister(extn); if (ps == null) { context.getReport().record(new MigrationException( "Import error: persistence strategy [%s] for configuration [%s] is not defined.", extn, path)); } else {// w w w . j a va 2 s .co m final Dictionary<String, Object> properties; InputStream is = null; try { is = entry.getInputStream().orElseThrow(() -> new MigrationException( "Import error: failed to read configuration [%s]; not exported.", path)); properties = readProperties(entry, ps, is); } catch (IOException e) { throw new MigrationException("Import error: failed to read configuration [%s]; %s.", path, e); } finally { Closeables.closeQuietly(is); } // note: we also remove bunde location, factory pid, and pid from the dictionary as we do not // want to restore those later final String pid = Objects.toString(properties.remove(Constants.SERVICE_PID), null); if (pid == null) { // this should never happen unless someone created the zip file manually and messed up the // config file context.getReport() .record(new MigrationException("Import error: missing pid from configuration [%s].", path)); } else { final String bundleLocation = Objects .toString(properties.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION), null); final String factoryPid = Objects.toString(properties.remove(ConfigurationAdmin.SERVICE_FACTORYPID), null); try { return new ImportMigrationConfigurationAdminEntry(configurationAdmin, entry, bundleLocation, factoryPid, pid, properties, getAndRemoveMemoryConfig(factoryPid, pid, properties, entry.getPath())); } catch (MigrationException e) { // don't throw it back yet as we want to detect as many as possible so just record it context.getReport().record(e); } } } this.isValid = false; return null; }
From source file:org.codice.ddf.configuration.admin.ImportMigrationConfigurationAdminEntry.java
private boolean propertiesMatch() { final Dictionary<String, Object> props = memoryConfiguration.getProperties(); if (props == null) { return false; }/*from w w w. j ava2 s .com*/ // remove bundle location, factory pid, and pid from the dictionary as we do not want to match // these props.remove(ConfigurationAdmin.SERVICE_FACTORYPID); props.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION); props.remove(Constants.SERVICE_PID); if (properties.size() != props.size()) { return false; } // @formatter:off - to shut up checkstyle!!!!!!! for (final Enumeration<String> e = properties.keys(); e.hasMoreElements();) { // @formatter:on final String key = e.nextElement(); if (!Objects.deepEquals(properties.get(key), props.get(key))) { return false; } } return true; }