1 28 29 package com.caucho.config.types; 30 31 import com.caucho.util.L10N; 32 33 import javax.naming.InitialContext ; 34 import javax.naming.NamingException ; 35 import javax.sql.DataSource ; 36 37 40 public class DataSourceBuilder { 41 static L10N L = new L10N(DataSourceBuilder.class); 42 43 private String _jndiPath; 44 45 48 public void addText(String text) 49 { 50 _jndiPath = text; 51 } 52 53 56 public DataSource replaceObject() 57 throws NamingException 58 { 59 if (_jndiPath.startsWith("java:comp/")) 60 return (DataSource ) new InitialContext ().lookup(_jndiPath); 61 else 62 return (DataSource ) new InitialContext ().lookup("java:comp/env/" + 63 _jndiPath); 64 } 65 } 66 | Popular Tags |