@Test public void testMergeEnvs() throws Exception { Properties src = new Properties(); Properties dest = new Properties(); src.put("hello", "world"); src.put("a", "b"); src.put("1", "2"); dest.put("a", "z"); Hashtable result = JndiContextFactory.merge(src, dest); assertTrue(result.containsKey("hello")); assertEquals("z", result.get("a").toString()); }
protected static Hashtable merge(Hashtable<?, ?> defaultEnv, Hashtable environment) { Hashtable result = (Hashtable) environment.clone(); for (Map.Entry e : defaultEnv.entrySet()) { if (!environment.containsKey(e.getKey())) { result.put(e.getKey(), e.getValue()); } } return result; }
JndiContextFactory implements InitialContextFactory { protected static Hashtable merge(Hashtable<?, ?> defaultEnv, Hashtable environment) { Hashtable result = (Hashtable) environment.clone(); for (Map.Entry e : defaultEnv.entrySet()) { if (!environment.containsKey(e.getKey())) { result.put(e.getKey(), e.getValue()); } } return result; } }
JndiContextFactory implements InitialContextFactory { protected static Hashtable merge(Hashtable<?, ?> defaultEnv, Hashtable environment) { Hashtable result = (Hashtable) environment.clone(); for (Map.Entry e : defaultEnv.entrySet()) { if (!environment.containsKey(e.getKey())) { result.put(e.getKey(), e.getValue()); } } return result; } JndiContextFactory();  JndiContextFactory(Hashtable environment); }
JndiContextFactory implements InitialContextFactory { protected static Hashtable merge(Hashtable<?, ?> defaultEnv, Hashtable environment) { Hashtable result = (Hashtable) environment.clone(); for (Map.Entry e : defaultEnv.entrySet()) { if (!environment.containsKey(e.getKey())) { result.put(e.getKey(), e.getValue()); } } return result; } JndiContextFactory();  JndiContextFactory(Hashtable environment); @Override Context getInitialContext(Hashtable environment); }
JndiContextFactory implements InitialContextFactory { protected static Hashtable merge(Hashtable<?, ?> defaultEnv, Hashtable environment) { Hashtable result = (Hashtable) environment.clone(); for (Map.Entry e : defaultEnv.entrySet()) { if (!environment.containsKey(e.getKey())) { result.put(e.getKey(), e.getValue()); } } return result; } JndiContextFactory();  JndiContextFactory(Hashtable environment); @Override Context getInitialContext(Hashtable environment);  }