1 7 package org.ejtools.util; 8 9 import java.io.IOException ; 10 import java.io.InputStream ; 11 import java.util.Properties ; 12 13 import javax.naming.Context ; 14 15 import org.apache.log4j.Category; 16 17 23 public abstract class JNDI 24 { 25 26 static Category logger = Category.getInstance(JNDI.class); 27 28 29 30 public static void setJNDIProperties() 31 { 32 try 33 { 34 InputStream in = JNDI.class.getResourceAsStream("/jndi.properties"); 35 36 if (in != null) 37 { 38 logger.debug("Found jndi.properties in classpath"); 39 40 Properties props = new Properties (); 42 props.load(in); 43 in.close(); 44 45 logger.debug("Setting VM environment"); 46 47 System.setProperty(Context.INITIAL_CONTEXT_FACTORY, props.getProperty(Context.INITIAL_CONTEXT_FACTORY, "")); 49 System.setProperty(Context.URL_PKG_PREFIXES, props.getProperty(Context.URL_PKG_PREFIXES, "")); 50 System.setProperty(Context.PROVIDER_URL, props.getProperty(Context.PROVIDER_URL, "")); 51 } 52 } 53 catch (IOException ioe) 54 { 55 logger.warn("Exception while loading jndi.properties " + ioe.getMessage()); 57 } 58 } 59 } 60 | Popular Tags |