📄 cjscsessionpoolfactory.java
字号:
package com.cjsc.it.auth;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import lotus.domino.Session;
import com.cjsc.it.xml.CfgInfo;
import com.cjsc.it.xml.CfgXMLParser;
import com.cjsc.it.xml.DominoPoolInfo;
public class CjscSessionPoolFactory {
// 连接池的管理器,首先初始化,管理连接池
private HashMap sessionPoolFactory = new HashMap();
private static CjscSessionPoolFactory poolFactory = null;
private CfgInfo cfg = null;
public static synchronized CjscSessionPoolFactory getInstance() {
if (poolFactory == null) {
poolFactory = new CjscSessionPoolFactory();
}
return poolFactory;
}
private CjscSessionPoolFactory() {
// 初始化连接池配置文件中的所有连接
String xml = System.getProperty("user.dir")
+ System.getProperty("file.separator") + "/app/uiauth/domino.xml";
cfg = CfgXMLParser.loadCfgInfo(xml);
HashMap dominoPoolInfos = cfg.getDominoPoolsInfo();
Set key = dominoPoolInfos.keySet();
Iterator it = key.iterator();
while (it.hasNext()) {
String poolName = it.next().toString();
DominoPoolInfo poolInfo = cfg.getDominoPoolInfo(poolName);
if (poolInfo.getHost().equals("10.0.16.1")) {
UIAuth.poolName = poolInfo.getPoolName();
}
if (poolInfo.getHost().equals("10.0.16.5")) {
UIAuth.poolName_bak = poolInfo.getPoolName();
}
CjscSessionPool sessionPool = new CjscSessionPool(poolInfo
.getHost(), poolInfo.getUserName(), poolInfo.getPassword(),
poolInfo.getMaxPoolNum());
sessionPoolFactory.put(poolName, sessionPool);
}
}
public CjscSessionPool getSessionPool(String poolName) {
return (CjscSessionPool) sessionPoolFactory.get(poolName);
}
public synchronized Session getSession(String poolName) throws Exception {
CjscSessionPool pool = getSessionPool(poolName);
return pool.getSession();
}
public synchronized void releaseSession(String poolName, Session session) {
CjscSessionPool pool = getSessionPool(poolName);
pool.releaseSession(session, poolName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -