ex8_3.txt
来自「j2ee core design patterns」· 文本 代码 · 共 32 行
TXT
32 行
Example 8.3 OracleDAOFactory.java: Data Access Object Strategy Using Factory Method [GoF]
package com.corej2eepatterns.dao;
// imports
public class OracleDAOFactory extends DAOFactory {
// package level constant used look up the
// DataSource name using JNDI
static String DATASOURCE_DB_NAME =
"java:comp/env/jdbc/CJPOraDB";
public static CustomerDAO getCustomerDAO()
throws DAOException {
return (CustomerDAO) createDAO(CustomerDAO.class);
}
public static EmployeeDAO getEmployeeDAO()
throws DAOException {
return (EmployeeDAO) createDAO(EmployeeDAO.class);
}
// create other DAO instances
. . .
// method to create a DAO instance. Can be optimized to
// cache the DAO Class instead of creating it everytime.
private Object createDAO(Class classObj)
throws DAOException {
// create a new DAO using classObj.newInstance() or
// obtain it from a cache and return the DAO instance
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?