1 19 package gcc.naming; 20 21 import gcc.adapter.Adapter; 22 23 import javax.naming.*; 24 import java.util.*; 25 26 public class NameService 27 { 28 protected static NameService _ns = null; 29 30 public static NameService getInstance() 31 { 32 if (_ns == null) 33 { 34 synchronized( NameService.class ) 35 { 36 if (_ns == null) 37 { 38 _ns = new NameService(); 39 _ns.init(); 40 } 41 } 42 } 43 44 return _ns; 45 } 46 47 private gcc.naming.InitialContext _context; 48 49 52 public void bindAdapter(Adapter adp) 53 { 54 NamingContext.getInstance(NameService.class).bindAdapter( adp ); 55 } 56 57 public static gcc.naming.InitialContext getInitialContext() 58 { 59 return getInstance()._context; 60 } 61 62 public HashMap getMap() 63 { 64 return _context.getMap(); 65 } 66 67 public Object lookup(String name) throws NamingException 68 { 69 return _context.lookup(name); 70 } 71 72 protected void init() 73 { 74 _context = new gcc.naming.InitialContext(null); 75 } 76 } 77 | Popular Tags |