accountingservicesfactory.java

来自「网上购物系统,实现了一个具体的框架」· Java 代码 · 共 42 行

JAVA
42
字号
/**
 * @name ServicesFactory.java
 * @author Administrator/pan
 * @version 1.1
 * @date 2009/2/16
 */
package com.digitstore.process.server;

import com.digitstore.process.server.account.IAccountingAdapter;
import com.digitstore.process.server.account.ICreditAuthorzationService;
import com.digitstore.process.server.tax.ITaxCalculatorAdapter;

//提供各种接口单子实例的抽象工厂
public class AccountingServicesFactory {
	private IAccountingAdapter accountingAdapter;
	private ICreditAuthorzationService credtiAuthorzationService;
	private ITaxCalculatorAdapter taxCalculatorAdapter;
	private static AccountingServicesFactory servicesFactory;
	
	//返回本工厂的单子
	public static synchronized AccountingServicesFactory getInstance(){
		if(servicesFactory == null){
			servicesFactory = new AccountingServicesFactory();
		}
		return servicesFactory;
	}
	
	//返回与外部信用卡系统交互的接口类
	public IAccountingAdapter getAccountingAdapter() throws InstantiationException, IllegalAccessException, ClassNotFoundException{
		try{
			if(accountingAdapter == null) {
			String className = System.getProperty("taxculculator.class.name");
			accountingAdapter = (IAccountingAdapter)Class.forName(className).newInstance();
		}
	} catch(Exception e){
	       e.printStackTrace();
	}
	return accountingAdapter;
	}

}

⌨️ 快捷键说明

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