📄 xmlsessionpropertyhandler.java
字号:
/*
* 嶌惉擔: 2003/12/17
*/
package jp.co.intra_mart.framework.base.session;
import java.io.IOException;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import jp.co.intra_mart.framework.system.property.PropertyHandlerException;
import jp.co.intra_mart.framework.system.property.PropertyParam;
/**
* 僙僢僔儑儞偵娭楢偡傞XML偺僾儘僷僥傿僴儞僪儔偱偡丅
* @author INTRAMART
* @version 1.0
*/
public class XmlSessionPropertyHandler implements SessionPropertyHandler {
/**
* 僨僼僅儖僩偺xml僼傽僀儖柤
*/
public static final String DEFAULT_BUNDLE_NAME = "session-config";
/**
* xml僼傽僀儖柤偺僷儔儊乕僞柤
*/
public static final String DEFAULT_BUNDLE_NAME_PARAM = "bundle";
/**
* 僙僢僔儑儞偺儕僜乕僗忣曬傪愝掕偝傟偰偄傞SessionModel;
*/
private SessionModel sessionModel;
public XmlSessionPropertyHandler(){
sessionModel= null;
}
/**
* 僾儘僷僥傿僴儞僪儔傪弶婜壔偟傑偡丅
*
* @param params 弶婜僷儔儊乕僞
* @throws PropertyHandlerException 僾儘僷僥傿僴儞僪儔偺弶婜壔帪偵椺奜偑敪惗
*/
public void init(PropertyParam[] params) throws PropertyHandlerException {
String xmlName = null;
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (params[i].getName().equals(DEFAULT_BUNDLE_NAME_PARAM)) {
xmlName = params[i].getValue();
}
}
}
if (xmlName == null) {
xmlName = DEFAULT_BUNDLE_NAME;
}
SessionModelProducer producer = new SessionModelProducer();
try {
this.sessionModel = producer.createSessionModel(xmlName);
} catch (ParserConfigurationException e) {
throw new PropertyHandlerException(e.getMessage(),e);
} catch (SAXException e) {
throw new PropertyHandlerException(e.getMessage(),e);
} catch (IOException e) {
throw new PropertyHandlerException(e.getMessage(),e);
} catch (IllegalArgumentException e) {
throw new PropertyHandlerException(e.getMessage(),e);
}
}
/**
* 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤傪庢摼偟傑偡丅
* 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
*
* @throws SessionPropertyException 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤偺庢摼帪偵椺奜偑敪惗
* @return 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤乮愝掕偝傟偰偄側偄応崌null乯
* @deprecated 僙僢僔儑儞偲偟偰偼HttpSession傪捈愙棙梡偡傞傛偆偵偟偰偔偩偝偄丅
*/
public String getSessionFactoryName() throws SessionPropertyException {
return this.sessionModel.getFactoryName();
}
/**
* 僙僢僔儑儞ID偺僷儔儊乕僞柤傪庢摼偟傑偡丅
* 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
*
* @return 僙僢僔儑儞ID偺僷儔儊乕僞柤乮愝掕偝傟偰偄側偄応崌null乯
* @throws SessionPropertyException 僙僢僔儑儞僷儔儊乕僞庢摼帪偵椺奜偑敪惗
* @deprecated HttpSession傪捈愙巊梡偡傞応崌丄偙偺儊僜僢僪偼晄梫偵側傝傑偡丅
*/
public String getSessionParameter() throws SessionPropertyException{
return this.sessionModel.getSessionParam();
}
/**
* 僙僢僔儑儞僆僽僕僃僋僩偺僉乕傪庢摼偟傑偡丅
* 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
*
*
* @return 僙僢僔儑儞僆僽僕僃僋僩偺僉乕乮愝掕偝傟偰偄側偄応崌null乯
* @throws SessionPropertyException 僙僢僔儑儞僆僽僕僃僋僩僉乕庢摼帪偵椺奜偑敪惗
* @deprecated HttpSession傪捈愙庢摼偡傞傛偆偵偟偰偔偩偝偄丅
*/
public String getSessionObjectKey() throws SessionPropertyException {
return this.sessionModel.getSessionObjectKey();
}
/**
* 僙僢僔儑儞偵搊榐偝傟偰偄傞儘僌僀儞儐乕僓ID偺僉乕傪庢摼偟傑偡丅
*
* @return 儘僌僀儞儐乕僓ID偺僉乕
* @throws SessionPropertyException 懏惈柤偺庢摼帪偵椺奜偑敪惗
*/
public String getLoginUserIDKey() throws SessionPropertyException {
String key;
key = this.sessionModel.getUserIdParam();
if(key == null){
String message = null;
try{
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetLoginGroup");
} catch (MissingResourceException ex){
}
throw new SessionPropertyException(message);
}
return key;
}
/**
* 僙僢僔儑儞偵搊榐偝傟偰偄傞儘僌僀儞僌儖乕僾ID偺僉乕傪庢摼偟傑偡丅
*
* @return 儘僌僀儞僌儖乕僾ID偺僉乕
* @throws SessionPropertyException 懏惈柤偺庢摼帪偵椺奜偑敪惗
*/
public String getLoginGroupIDKey() throws SessionPropertyException {
String key;
key = this.sessionModel.getGroupIdParam();
if(key == null) {
String message = null;
try {
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetLoginGroup");
} catch (MissingResourceException ex) {
}
throw new SessionPropertyException(message);
}
return key;
}
/**
* 僙僢僔儑儞僄儔乕儁乕僕偺僷僗傪庢摼偟傑偡丅
*
* @return 僙僢僔儑儞僄儔乕儁乕僕偺僷僗
* @throws SessionPropertyException 僙僢僔儑儞僄儔乕儁乕僕偺僷僗偺庢摼帪偵椺奜偑敪惗
*/
public String getSessionErrorPagePath() throws SessionPropertyException {
String errorPage = null;
errorPage = this.sessionModel.getErrorPage();
if(errorPage == null){
String message = null;
try {
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetSessionErrorPagePath");
} catch (MissingResourceException ex) {
}
throw new SessionPropertyException(message);
}
return errorPage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -