📄 webconfig.java
字号:
package com.cownew.PIS.framework.web.helper;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import com.cownew.ctk.common.ExceptionUtils;
import com.cownew.ctk.common.StringUtils;
import com.cownew.ctk.constant.StringConst;
import com.cownew.ctk.io.ResourceUtils;
public class WebConfig
{
private String serverURL;
private String metaDataPath;
private String entityCacheFile;
private boolean metaCacheEnabled;
private static WebConfig instance;
private WebConfig()
{
super();
}
public static WebConfig getInstance()
{
if (instance == null)
{
instance = new WebConfig();
try
{
instance.initConfig();
} catch (Exception e)
{
ExceptionUtils.toRuntimeException(e);
}
}
return instance;
}
protected void initConfig() throws Exception
{
InputStream beansXFStream = null;
try
{
beansXFStream = getClass().getResourceAsStream(
"/com/cownew/PIS/framework/web/WebConfig.xml");
Document doc = new SAXReader().read(new InputStreamReader(
beansXFStream, StringConst.UTF8));
Node serverURLNode = doc.selectSingleNode("//Config/ServerURL");
serverURL = serverURLNode.getText();
metaDataPath = doc.selectSingleNode(
"//Config/MetaData/MetaDataPath").getText();
entityCacheFile = doc.selectSingleNode(
"//Config/MetaData/EntityCacheFile").getText();
String cacheState = doc.selectSingleNode(
"//Config/MetaData/CacheEnabled").getText();
if (StringUtils.isEmpty(cacheState)
|| cacheState.equalsIgnoreCase("false")
|| cacheState.equalsIgnoreCase("no")
|| cacheState.equalsIgnoreCase("off"))
{
metaCacheEnabled = false;
} else
{
metaCacheEnabled = true;
}
} finally
{
ResourceUtils.close(beansXFStream);
}
}
public String getEntityCacheFile()
{
return entityCacheFile;
}
public boolean isMetaCacheEnabled()
{
return metaCacheEnabled;
}
public String getMetaDataPath()
{
return metaDataPath;
}
public URL getServerURL()
{
try
{
return new URL(serverURL);
} catch (MalformedURLException e)
{
throw ExceptionUtils.toRuntimeException(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -