1 6 package org.logicalcobwebs.proxool.admin.jndi; 7 8 import org.logicalcobwebs.proxool.ProxoolConstants; 9 import org.logicalcobwebs.proxool.ProxoolException; 10 import org.logicalcobwebs.proxool.ProxoolDataSource; 11 12 import javax.naming.InitialContext ; 13 import javax.naming.NamingException ; 14 import javax.sql.DataSource ; 15 import java.util.Properties ; 16 17 24 public class ProxoolJNDIHelper { 25 private ProxoolJNDIHelper() { 26 } 27 28 34 public static void registerDatasource(String alias, Properties jndiProperties) throws ProxoolException { 35 DataSource dataSource = new ProxoolDataSource(alias); 36 final String jndiName = jndiProperties.getProperty(ProxoolConstants.JNDI_NAME); 37 jndiProperties.remove(ProxoolConstants.JNDI_NAME); 38 try { 39 InitialContext initalContext = new InitialContext (jndiProperties); 40 initalContext.rebind(jndiName, dataSource); 41 } catch (NamingException e) { 42 throw new ProxoolException("JNDI binding of DataSource for alias " + alias 43 + " failed.", e); 44 } 45 } 46 } 47 48 | Popular Tags |