本文整理匯總了Java中cn.aofeng.common4j.xml.DomUtil類的典型用法代碼示例。如果您正苦於以下問題:Java DomUtil類的具體用法?Java DomUtil怎麽用?Java DomUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DomUtil類屬於cn.aofeng.common4j.xml包,在下文中一共展示了DomUtil類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import cn.aofeng.common4j.xml.DomUtil; //導入依賴的package包/類
/**
* 從配置文件中載入事件類型及其事件監聽器
*/
@SuppressWarnings({"rawtypes" })
public void init() {
if (_isStarted.get()) {
return;
}
// 先初始化線程池
_threadpool.init();
// 讀取配置文件event4j.xml,生成事件及其監聽器集合列表
Document document = DomUtil.createDocument(_configFile);
Element rootNode = document.getDocumentElement();
NodeParser rootParser = new NodeParser(rootNode);
List<Node> eventNodes = rootParser.getChildNodes();
for (Node eventNode : eventNodes) {
NodeParser eventParset = new NodeParser(eventNode);
String eventType = eventParset.getAttributeValue("type");
Delegator deletator = createDelegator(eventParset);
deletator.setThreadPool( (ThreadPool) _threadpool );
deletator.init();
_eventMap.put(eventType, deletator);
}
if (_logger.isInfoEnabled()) {
Iterator<Entry<String, Delegator>> delegatorIterator = iterator();
while (delegatorIterator.hasNext()) {
Entry<String, Delegator> entry = (Entry<String, Delegator>) delegatorIterator.next();
_logger.info( String.format("event '%s' has listeners:", entry.getKey()) );
Iterator<EventListener> listenerIterator = entry.getValue().iterator();
while (listenerIterator.hasNext()) {
EventListener eventListener = (EventListener) listenerIterator.next();
_logger.info(" "+eventListener.getClass().getName());
}
}
}
_isStarted.set(true);
}
示例2: initConfig
import cn.aofeng.common4j.xml.DomUtil; //導入依賴的package包/類
private void initConfig() {
Document document = DomUtil.createDocument(_configFile);
Element root = document.getDocumentElement();
NodeParser rootParser = new NodeParser(root);
List<Node> nodeList = rootParser.getChildNodes();
for (Node node : nodeList) {
NodeParser nodeParser = new NodeParser(node);
if ( "pool".equals(node.getNodeName()) ) {
ThreadPoolInfo info = new ThreadPoolInfo();
info.setName(nodeParser.getAttributeValue("name"));
info.setCoreSize(Integer.parseInt(nodeParser.getChildNodeValue("corePoolSize")));
info.setMaxSize(Integer.parseInt(nodeParser.getChildNodeValue("maxPoolSize")));
info.setThreadKeepAliveTime(Long.parseLong(nodeParser.getChildNodeValue("keepAliveTime")));
info.setQueueSize(Integer.parseInt(nodeParser.getChildNodeValue("workQueueSize")));
_multiThreadPoolInfo.put(info.getName(), info);
} else if ( "threadpoolstate".equals(node.getNodeName()) ) {
_threadPoolStateSwitch = computeSwitchValue(nodeParser);
_threadPoolStateInterval = computeIntervalValue(nodeParser);
} else if ( "threadstate".equals(node.getNodeName()) ) {
_threadStateSwitch = computeSwitchValue(nodeParser);
_threadStateInterval = computeIntervalValue(nodeParser);
} else if ( "threadstack".equals(node.getNodeName()) ) {
_threadStackSwitch = computeSwitchValue(nodeParser);
_threadStackInterval = computeIntervalValue(nodeParser);
}
} // end of for
}