a7e4c9650fe0a85f3e2f69b0a17db74a3f536c02
[utils] /
1 package org.wamblee.support.jndi;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import javax.naming.InitialContext;
7 import javax.naming.Name;
8 import javax.naming.NamingException;
9
10 public class StubInitialContext extends InitialContext {
11         private Map<String, Object> bindings = new HashMap<String, Object>();
12
13         public StubInitialContext() throws NamingException { 
14                 super(true);
15         }
16         
17         @Override
18         public void bind(String name, Object obj) throws NamingException {
19                 bindings.put(name, obj);
20         }
21
22         @Override
23         public Object lookup(String name) throws NamingException {
24                 return bindings.get(name);
25         }
26         
27         @Override
28         public Object lookup(Name name) throws NamingException {
29                 return super.lookup(name.toString());
30         }
31 }