📄 genericejbeventlistenerlocalfactory.java
字号:
/*
* GenericEJBEventListnerLocalFactory.java
*/
package jp.co.intra_mart.framework.base.event;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import jp.co.intra_mart.framework.base.event.EJBEventListenerFactory;
import jp.co.intra_mart.framework.base.event.Event;
import jp.co.intra_mart.framework.base.event.EventListener;
import jp.co.intra_mart.framework.base.event.EventListenerException;
/**
* GenericEJBEventListnerLocal傪怴婯偵惗惉偟傑偡丅
*
* @version 1.0
* @since 5.0
*/
public class GenericEJBEventListenerLocalFactory extends EJBEventListenerFactory {
/**
* 僀儀儞僩儕僗僫乕偺僋儔僗柤偺僷儔儊乕僞柤
*/
public static final String LISTENER_PARAM = "listener";
/**
* GenericEJBEventListnerLocal
*/
private GenericEJBEventListenerLocal listener;
/**
* 幚嵺偵張棟傪峴偆StandardEventListener偺僋儔僗柤
*/
private String listenerName;
/**
* GenericEJBEventListnerLocalFactory傪怴婯偵惗惉偟傑偡丅
*/
public GenericEJBEventListenerLocalFactory() {
super();
}
/**
* 僀儀儞僩儕僗僫傪惗惉偟傑偡丅
*
* @param event 僀儀儞僩
* @return 僀儀儞僩儕僗僫
* @throws EventListenerException 僀儀儞僩儕僗僫偺惗惉偵幐攕
*/
public EventListener create(Event event) throws EventListenerException {
if (this.listener == null) {
synchronized(this) {
if (this.listener == null) {
InitialContext context;
GenericEJBEventListenerAgentLocalHome home;
try {
context = new InitialContext();
home = (GenericEJBEventListenerAgentLocalHome)context.lookup(getJNDIName());
} catch (NamingException e) {
throw new EventListenerException(e.getMessage(), e);
} catch (ClassCastException e) {
throw new EventListenerException(e.getMessage(), e);
}
this.listener = new GenericEJBEventListenerLocal(home, getListenerName());
}
}
}
return this.listener;
}
/**
* 弶婜僷儔儊乕僞傪愝掕偟傑偡丅
* 暋悢偺僷儔儊乕僞偑愝掕偝傟傞応崌丄偦偺弴斣偼曐徹偝傟傑偣傫丅
*
* @param name 僷儔儊乕僞柤
* @param value 僷儔儊乕僞偺抣
* @throws EventListenerException 僷儔儊乕僞偺愝掕帪偵椺奜偑敪惗
*/
public void initParam(String name, String value) throws EventListenerException {
if (name.equals(HOME_PARAM)) {
if (value == null || value.equals("")) {
throw new EventListenerException("Initialize parameter is illegal. : " + HOME_PARAM);
}
setJNDIName(value);
} else if (name.equals(LISTENER_PARAM)) {
if (value == null || value.equals("")) {
throw new EventListenerException("Initialize parameter is illegal. : " + LISTENER_PARAM);
}
setListenerName(value);
}
}
/**
* EJBEventListenerAgentBean偺僋儔僗柤傪愝掕偟傑偡丅
*
* @param listenerName EJBEventListenerAgentBean偺僋儔僗柤
*/
protected void setListenerName(String listenerName) {
this.listenerName = listenerName;
}
/**
* EJBEventListenerAgentBean偺僋儔僗柤傪庢摼偟傑偡丅
*
* @return EJBEventListenerAgentBean偺僋儔僗柤
*/
public String getListenerName() {
return this.listenerName;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -