📄 genericeventlistenerfactory.java
字号:
/*
* GenericEventListenerFactory.java
*
* Created on 2001/12/10, 15:26
*/
package jp.co.intra_mart.framework.base.event;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
/**
* {@link GenericEventListener}傪惗惉偡傞僀儀儞僩儕僗僫僼傽僋僩儕偱偡丅
* 偙偺僼傽僋僩儕偱巜掕偱偒傞弶婜僷儔儊乕僞偼埲壓偺偲偍傝偱偡丅<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 GenericEventListenerFactory implements EventListenerFactory {
/**
* 曪娷偡傞StandardEventListener偺僋儔僗柤偺僷儔儊乕僞柤
*/
private static final String PARAM_LISTENER = "listener";
/**
* 曪娷偡傞StandardEventListener偺僋儔僗柤
*/
String listenerName;
/**
* GenericEventListenerFactory傪怴婯偵惗惉偟傑偡丅
*/
public GenericEventListenerFactory() {
this.listenerName = null;
}
/**
* 僀儀儞僩儕僗僫傪惗惉偟傑偡丅
*
* @param event 僀儀儞僩
* @return 僀儀儞僩儕僗僫
* @throws EventListenerException 僀儀儞僩儕僗僫偺惗惉偵幐攕
*/
public EventListener create(Event event) throws EventListenerException {
GenericEventListener result = null;
Object listenerObject = null;
StandardEventListener listener = null;
// 僀儀儞僩儕僗僫偺怴婯惗惉
result = new GenericEventListener();
// 僀儀儞僩儕僗僫偺愝掕
if (this.listenerName == null) {
String message = null;
try {
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.event.i18n").getString("GenericEventListenerFactory.IncludedListenerNotDeclared");
} catch (MissingResourceException e) {
}
if (event == null) {
throw new EventListenerException(message + ", event is null");
} else {
throw new EventListenerException(message + ", application = " + event.getApplication() + ", key = " + event.getKey());
}
}
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 + " : listener = " + this.listenerName + ", event is null", e);
} else {
throw new EventListenerException(message + " : listener = " + 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 + " : listener = " + this.listenerName + ", event is null");
} else {
throw new EventListenerException(message + " : listener = " + this.listenerName + ", application = " + event.getApplication() + ", key = " + event.getKey());
}
}
result.setListener(listener);
// 僀儀儞僩儕僗僫傪曉偡
return result;
}
/**
* 弶婜僷儔儊乕僞傪愝掕偟傑偡丅
* 暋悢偺僷儔儊乕僞偑愝掕偝傟傞応崌丄偦偺弴斣偼曐徹偝傟傑偣傫丅
*
* @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 + -