⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex8_4.txt

📁 j2ee core design patterns
💻 TXT
字号:
Example 8.4 	DAOFactory.java: Data Access Object Factory Strategy Using Abstract Factory [GoF]
package com.corej2eepatterns.dao;

// imports

// Abstract class DAO Factory
public abstract class DAOFactory {

	// List of DAO types supported by the factory
	public static final int CLOUDSCAPE = 1;
	public static final int ORACLE = 2;
	public static final int SYBASE = 3;
	. . .

	// There will be a method for each DAO that can be 
	// created. The concrete factories will have to 
	// implement these methods.
	public abstract CustomerDAO getCustomerDAO()
			throws DAOException;
	public abstract EmployeeDAO getEmployeeDAO()
			throws DAOException;
	. . .

	public static DAOFactory getDAOFactory(int whichFactory) {
		switch (whichFactory) {
		case CLOUDSCAPE:
			return new CloudscapeDAOFactory();
 		case ORACLE:
			return new OracleDAOFactory();
		case SYBASE:
			return new SybaseDAOFactory();
		. . .
		default: 
			return null;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -