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

📄 standardeventlistenerfactory.java

📁 intra_mart是日本NDD公司开发的著名企业应用解决方案中间件。集成了J2ee服务器
💻 JAVA
字号:
/*
 * StandardEventListenerFactory.java
 *
 * Created on 2001/12/05, 18:37
 */

package jp.co.intra_mart.framework.base.event;

import java.util.ResourceBundle;

import java.util.MissingResourceException;

/**
 * 捠忢偺Java僋儔僗偺僀儀儞僩儕僗僫傪惗惉偟傑偡丅
 * 偙偺僼傽僋僩儕偱巜掕偱偒傞弶婜僷儔儊乕僞偼埲壓偺偲偍傝偱偡丅<BR>
 * <TABLE border="1">
 *     <TR>
 *         <TH>僷儔儊乕僞柤</TH>
 *         <TH>抣</TH>
 *     </TR>
 *     <TR>
 *         <TD>listener</TD>
 *         <TD>惗惉偡傞僀儀儞僩儕僗僫</TD>
 *     </TR>
 * </TABLE>
 *
 * @author INTRAMART
 * @version 1.0
 */
public class StandardEventListenerFactory implements EventListenerFactory {

    /**
     * 僀儀儞僩儕僗僫偺僷儔儊乕僞柤
     */
    private static final String PARAM_LISTENER = "listener";

    /**
     * 惗惉偡傞StandardEventListener偺僋儔僗柤
     */
    String listenerName;

    /**
     * StandardEventListenerFactory傪怴婯偵惗惉偟傑偡丅
     */
    public StandardEventListenerFactory() {
    }

    /**
     * 僀儀儞僩儕僗僫傪惗惉偟傑偡丅
     * 弶婜僷儔儊乕僞偱巜掕偝傟偨僋儔僗傪僀儀儞僩儕僗僫偲偟偰惗惉偟傑偡丅
     * 弶婜僷儔儊乕僞偱巜掕偝傟偨僋儔僗偼{@link StandardEventListener}傪宲彸偟偰偄傞昁梫偑偁傝傑偡丅
     *
     * @param event 僀儀儞僩
     * @return 僀儀儞僩儕僗僫
     * @throws EventListenerException 僀儀儞僩儕僗僫偺惗惉偵幐攕
     */
    public EventListener create(Event event) throws EventListenerException {
        Object listenerObject = null;
        StandardEventListener listener = null;

        try {
            listenerObject = Class.forName(this.listenerName).newInstance();
        } catch (Exception e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.event.i18n").getString("Common.FailedToCreateEventListener");
            } catch (MissingResourceException ex) {
            }
            if (event == null) {
                throw new EventListenerException(message + " : class = " + this.listenerName + ", event is null", e);
            } else {
                throw new EventListenerException(message + " : class = " + this.listenerName + ", application = " + event.getApplication() + ", key = " + event.getKey(), e);
            }
        }
        if (listenerObject instanceof StandardEventListener) {
            listener = (StandardEventListener)listenerObject;
        } else {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.event.i18n").getString("Common.EventListenerExtended");
            } catch (MissingResourceException e) {
            }
            if (event == null) {
                throw new EventListenerException(message + " : class = " + this.listenerName + ", factory = " + this.getClass().getName() + ", event is null");
            } else {
                throw new EventListenerException(message + " : class = " + this.listenerName + ", factory = " + this.getClass().getName() + ", application = " + event.getApplication() + ", key = " + event.getKey());
            }
        }

        return listener;
    }

    /**
     * 弶婜僷儔儊乕僞傪愝掕偟傑偡丅
     * 暋悢偺僷儔儊乕僞偑愝掕偝傟傞応崌丄偦偺弴斣偼曐徹偝傟傑偣傫丅
     *
     * @param name 僷儔儊乕僞柤
     * @param value 僷儔儊乕僞偺抣
     * @throws EventListenerException 僷儔儊乕僞偺愝掕帪偵椺奜偑敪惗
     */
    public void initParam(String name, String value) throws EventListenerException {

        if (name != null) {
            if (name.equals(PARAM_LISTENER)) {
                // 僷儔儊乕僞偱巜掕偝傟偨僀儀儞僩儕僗僫偺惗惉
                this.listenerName = value;
            }
        }
    }
}

⌨️ 快捷键说明

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