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

📄 blhlocator.java

📁 以前做的一个j2ee的项目
💻 JAVA
字号:
package gov.gdlt.ssgly.taxcore.comm.servicelocator;

import java.util.Map;
import java.util.HashMap;
import gov.gdlt.ssgly.taxcore.comm.blh.BaseBizLogicHandler;

/**
 * Service Locator模式的实现,定位BLH对象并将BLH对象缓存起来,避免每次动态创建的开销。
 *
 * <p>Title: BLHLocator</p>
 * <p>Description: 税收管理员系统</p>
 * <p>Copyright: Copyright (c) 2005 广州市地方税务局</p>
 * <p>Company: 信息中心</p>
 * @author Lemon
 * @version 1.0
 * @since 2005.8.8.
 */

public class BLHLocator {

    private static BLHLocator instance;
    private Map blhCache;

    // This is private, and can't be instantiated directly
    private BLHLocator() {
        blhCache = new HashMap();
    }

    public static BLHLocator getInstance() {
        if (instance == null) {
            instance = new BLHLocator();
        }
        return instance;
    }

    public BaseBizLogicHandler getBLHandler(String blhClassName) {

        // See if we already have this blh cached
        BaseBizLogicHandler bizHandler = (BaseBizLogicHandler) blhCache.get(
                blhClassName);

        // If not, create it.
        if (bizHandler == null) {
            try {
                Object obj = Class.forName(blhClassName).newInstance();
                bizHandler = (BaseBizLogicHandler) obj;
                // If this is a new ref, save for caching purposes
                blhCache.put(blhClassName, bizHandler);
            } catch (Exception e){
                // log CLASS_NOT_FOUND exception here, etc.
            }
        }

        return bizHandler;
    }
}

⌨️ 快捷键说明

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