1 20 package fr.dyade.aaa.util; 21 22 import javax.naming.*; 23 import java.util.*; 24 25 public class JndiHelper { 26 27 32 public static InitialContext newInitialContext() throws NamingException { 33 return newInitialContext(null); 34 } 35 36 public static InitialContext newInitialContext(Hashtable properties) throws NamingException { 37 ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); 38 Thread.currentThread().setContextClassLoader(JndiHelper.class.getClassLoader()); 39 InitialContext ic = null; 40 if (properties == null) { 41 ic = new InitialContext(); 42 } else { 43 ic = new InitialContext(properties); 44 } 45 Thread.currentThread().setContextClassLoader(currentClassLoader); 46 return ic; 47 } 48 } 49 | Popular Tags |