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

📄 pjbizbroker.java

📁 此系统为我大家完全开发一个相册管理系统
💻 JAVA
字号:
/* ====================================================================
 * $Id$
 * ====================================================================
 *  文件名    PJBizBroker.java
 *  机能名    
 *  履历      2005-1-27 dlxu 创建新文件  
 *           Copyright 2004 东南大学 All Rights Reserved
 * ====================================================================
 */
package cn.edu.seu.album.common;

import java.io.FileInputStream;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Category;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionMessages;

import cn.edu.seu.album.model.SessionBean;

/**
 * <p> [概 要] </p>
 * <p> [详 细] </p>
 * <p> [备 考] 无。</p>
 *
 * @author dlxu
 * @version 1.0 2005-1-27
 * @since 1.0
 */
public class PJBizBroker {

    /**
     * 日志取得。
     */
    private static final Category cat = Logger.getInstance(PJBizBroker.class);

    /**
     * 业务逻辑影射表
     */
    private static Map bizMap = null;

    /**
     * <p> [概 要] </p>
     * <p> [详 细] </p>
     * <p> [备 考] 无。</p>
     * @param mappingFile
     * @throws Exception
     */
    public static void init(String mappingFile) throws Exception {
        Map bizMapping = new HashMap();

        Properties prop = new Properties();
        prop.load(new FileInputStream(mappingFile));

        for (Enumeration e = prop.keys(); e.hasMoreElements();) {
            String bizKey = (String) e.nextElement();
            String bizValue = (String) prop.get(bizKey);
            try {
                Class bizClass = Class.forName(bizValue);
                bizMapping.put(bizKey, bizClass);
                cat.debug(bizValue + "被成功装载");
            } catch (Exception ex) {
                cat.warn(bizValue + "没有这个Class");
            }
        }

        bizMap = Collections.unmodifiableMap(bizMapping);
    }

    /**
     * <p> [概 要] </p>
     * <p> [详 细] </p>
     * <p> [备 考] 无。</p>
     * @param bizKey
     * @param cond
     * @param msgs
     * @param request
     * @return
     * @throws PJException
     */
    public static PJResult invoke(String bizKey, PJCondition cond,
            ActionMessages msgs, HttpServletRequest request) throws PJException {
        try {
            PJBaseBo biz = (PJBaseBo) ((Class) bizMap.get(bizKey))
                    .newInstance();
            cat.debug("BO的Class名为:" + biz.getClass().getName());
            // 会话Bean设定在条件内
            cond.setSb((SessionBean) request.getSession(true).getAttribute(
                    PJConst.SESSION_BEAN_KEY));
            return biz.gotoBiz(cond, msgs);
        } catch (PJException e) {
            throw e;
        } catch (Exception ex) {
            throw new PJException(ex);
        }
    }
}

⌨️ 快捷键说明

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