📄 eventlistenerconfigloader.java
字号:
package com.exp.web.util.config;
import com.exp.fcl.configs.ConfigLoaderSupport;
import com.exp.fcl.util.StringUtil;
import com.exp.fcl.xml.EXPXMLNode;
import com.exp.web.util.navigation.ForwardMap;
import com.exp.web.util.validator.ValidatorMap;
public class EventListenerConfigLoader extends ConfigLoaderSupport {
private static final String DEFAULT_EVENTLISTENER = "com.exp.web.support.EmptyPageEventListener";
public Object load(String pagePackagePath) {
if (this.document != null) {
String state = this.document.getRoot().getAttributeValue("debug");
boolean isDebug = StringUtil.equalsIgnoreCase(state, "true");
EXPXMLNode item = this.document.getRoot().getChildNode(
pagePackagePath);
EventListenerCfg listenerCfg = null;
if (item != null) {
listenerCfg = parseConfig(item, isDebug);
} else {
System.out.println("警告:" + pagePackagePath + " 事件监听器配置不存在!");
}
if (listenerCfg == null) {
listenerCfg = new EventListenerCfg();
listenerCfg.setListenerClass(DEFAULT_EVENTLISTENER);
}
return listenerCfg;
} else {
throw new RuntimeException("not found config file of listener!");
}
}
protected EventListenerCfg parseConfig(EXPXMLNode node, boolean isDebug) {
String listenerClass = node.getAttributeValue("listener");
if ("".equals(listenerClass)) {
listenerClass = DEFAULT_EVENTLISTENER;
}
EventListenerCfg listener = new EventListenerCfg();
listener.setListenerClass(listenerClass);
//处理导航信息
EXPXMLNode forwardNode = node.getChildNode("forwards");
if (forwardNode != null) {
ForwardMap fMap = new ForwardMap(forwardNode);
listener.setForwardMap(fMap);
}
//处理验证信息
EXPXMLNode validatorsNode = node.getChildNode("validators");
if (validatorsNode != null) {
ValidatorMap vMap = new ValidatorMap(validatorsNode);
listener.setValidatorMap(vMap);
}
EXPXMLNode params = node.getChildNode("params");
if (params != null) {
int count = params.getChildNodesCount();
for (int i = 0; i < count; i++) {
EXPXMLNode param = params.getChildNode(i);
String name = param.getAttributeValue("name");
String value = param.getNodeValue();
listener.addParam(name, value);
}
}
return listener;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -