增加定时器功能
This commit is contained in:
@@ -1,46 +1,66 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.map.CaseInsensitiveMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import com.beust.jcommander.internal.Sets;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
|
||||
import jersey.repackaged.com.google.common.collect.Lists;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class ServiceConfigTemplateUtil {
|
||||
|
||||
private Logger logger = Logger.getLogger(getClass());
|
||||
private static final Logger logger = Logger.getLogger(ServiceConfigTemplateUtil.class);
|
||||
|
||||
private Node root;
|
||||
private static Node root;
|
||||
|
||||
static {
|
||||
if(root == null) {//2018年12月28日11:37:50 fang 改为只加载一次,且方法改为 static
|
||||
SAXReader reader = new SAXReader();
|
||||
org.dom4j.Document document = null;
|
||||
String configPath = "/service/service_config.xml";
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = ServiceConfigTemplateUtil.class.getResourceAsStream(configPath);
|
||||
document = reader.read(is);
|
||||
root = document.getRootElement();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(is != null ){
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置文件内容
|
||||
* @return
|
||||
*/
|
||||
public ServiceConfigTemplateUtil(){
|
||||
SAXReader reader = new SAXReader();
|
||||
org.dom4j.Document document = null;
|
||||
String configPath = "/service/service_config.xml";
|
||||
try {
|
||||
document = reader.read(ServiceConfigTemplateUtil.class.getResourceAsStream(configPath));
|
||||
root = document.getRootElement();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取业务节点列表
|
||||
* @return
|
||||
*/
|
||||
public List<Node> getServiceNodeList(){
|
||||
public static List<Node> getServiceNodeList(){
|
||||
List<Node> nodes = root.selectNodes("service");
|
||||
return nodes;
|
||||
}
|
||||
@@ -48,7 +68,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取业务列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceList(){
|
||||
public static List<Map<String,Object>> getServiceList(){
|
||||
List<Map<String,Object>> list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
@@ -63,12 +83,47 @@ public class ServiceConfigTemplateUtil {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> getCompileTableName(){
|
||||
Set<String> result = Sets.newHashSet();
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
String ev = element.attribute("tableName").getStringValue();
|
||||
if(StringUtils.isNotBlank(ev)) {
|
||||
result.add(ev.toLowerCase());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类名 获取对应的 表名
|
||||
* @param className
|
||||
* @return
|
||||
*/
|
||||
public static String getCfgTableNameByClassName(String className) {
|
||||
if(className == null) return null;
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
String ev = element.attribute("tableName").getStringValue();
|
||||
String cn = element.attribute("className").getStringValue();
|
||||
if(className.equalsIgnoreCase(cn)) {
|
||||
return ev.toLowerCase();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param functionId
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
|
||||
public static List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
|
||||
List<Map<String,Object>> list =new ArrayList();
|
||||
if(!StringUtil.isEmpty(functionId)) {
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(functionId);
|
||||
@@ -133,7 +188,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取业务配置列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceCfgList(Element serviceNode){
|
||||
public static List<Map<String,Object>> getServiceCfgList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("serviceCfg");
|
||||
for(Element element:elements){
|
||||
@@ -149,7 +204,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取用户自定义域列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getUserRegionList(Element serviceNode){
|
||||
public static List<Map<String,Object>> getUserRegionList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("userRegion");
|
||||
for(Element element:elements){
|
||||
@@ -167,7 +222,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* @param attribute
|
||||
* @return
|
||||
*/
|
||||
public List getXmlParamListByTag(String tag,String attribute){
|
||||
public static List getXmlParamListByTag(String tag,String attribute){
|
||||
List list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes(tag);
|
||||
for(Element element:elements){
|
||||
@@ -196,6 +251,7 @@ public class ServiceConfigTemplateUtil {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user