1 37 38 package com.sun.j2ee.blueprints.util.dao; 39 40 import javax.naming.NamingException ; 41 import javax.naming.InitialContext ; 42 43 public class DAOFactory { 44 45 55 public static Object getDAO(String daoEnvEntry) throws DAOSystemException { 56 try { 57 InitialContext ic = new InitialContext (); 58 String className = (String ) ic.lookup(daoEnvEntry); 59 return Class.forName(className).newInstance(); 60 } catch (NamingException ne) { 61 throw new DAOSystemException("DAOFactory.getDAO(" + daoEnvEntry +"): NamingException while getting DAO type : \n" + ne.getMessage()); 62 } catch (Exception se) { 63 throw new DAOSystemException("DAOFactory.getDAO(" + daoEnvEntry +"): Exception while getting DAO type : \n" + se.getMessage()); 64 } 65 } 66 } 67 | Popular Tags |