📄 ex8_3.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -