//获取XML字符串
Document document = DocumentHelper.parseText(configInfo);
//获取根节点
Element config = document.getRootElement();//获取根节点
//是否回调方法
if ("0".equals(config.attribute("isCallBack").getText())) {
Iterator it = config.elementIterator();
while (it.hasNext()) {
Element el = (Element) it.next();
String name = el.getName();
String text = el.getText();
if (name.equals("className")) {
callMap.put(name, text);
} else if (name.equals("method")) {
callMap.put(name, text);
} else if (name.equals("url")) {
resultMap.put(name, text);
}
}
}
if (callMap != null && callMap.size() > 0 ) {
try {
// 使用spring容器调用类方法 直接用反射调用类方法会导致注解dao为null
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
Class cls = Class.forName((String) callMap.get("className"));
Method method = cls.getMethod((String) callMap.get("method"), Map.class);
method.invoke(wac.getBean(cls), resultMap);
} catch (Exception e) {
e.printStackTrace();
}