📄 xmllogpropertyhandler.java
字号:
/*
* 嶌惉擔: 2004/01/06
*/
package jp.co.intra_mart.framework.system.log;
import java.io.IOException;
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;
/**
* 儕僜乕僗偐傜儘僌僾儘僷僥傿忣曬傪庢摼偡傞僾儘僷僥傿僴儞僪儔偱偡丅
* @author INTRAMART
* @version 1.0
*/
public class XmlLogPropertyHandler implements LogPropertyHandler {
/**
* 僨僼僅儖僩偺XML僼傽僀儖柤
*/
public static final String DEFAULT_BUNDLE_NAME = "log-config";
/**
* XML僼傽僀儖柤偺僷儔儊乕僞柤
*/
public static final String DEFAULT_BUNDLE_NAME_PARAM = "bundle";
/**
* 儘僌儕僜乕僗忣曬偑愝掕偝傟偰偄傞儌僨儖
*/
private LogModel model;
/**
* XMLLogPropertyHandler傪怴婯偵惗惉偟傑偡丅
*/
public XmlLogPropertyHandler() {
this.model = 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;
}
this.model = createLogModel(xmlName);
}
/**
* LogModel傪惗惉偟傑偡丅
* @param xmlName
* @return LogModel
* @throws PropertyHandlerException
*/
private LogModel createLogModel(String xmlName) throws PropertyHandlerException{
try{
LogModelProducer producer = new LogModelProducer();
LogModel result = producer.createLogModel(xmlName);
return result;
}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 );
}catch(LogPropertyException e) {
throw new PropertyHandlerException(e.getMessage() ,e );
}
}
/**
* 儘僌僄乕僕僃儞僩偺僋儔僗柤傪庢摼偟傑偡丅
* 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
* @return 儘僌僄乕僕僃儞僩偺僋儔僗柤乮愝掕偝傟偰偄側偄応崌null乯
* @throws LogPropertyException 儘僌僄乕僕僃儞僩偺僋儔僗柤偺庢摼帪偵椺奜偑敪惗
*/
public String getLogAgentName() throws LogPropertyException {
return model.getLogAgentName();
}
/**
* 儘僌僄乕僕僃儞僩偺僷儔儊乕僞傪庢摼偟傑偡丅
* 壗傕愝掕偝傟偰偄側偄応崌戝偒偝偑0偺攝楍偑曉傝傑偡丅
*
* @return 儘僌僄乕僕僃儞僩偺僷儔儊乕僞偺攝楍
* @throws LogPropertyException 儘僌僄乕僕僃儞僩偺僷儔儊乕僞偺庢摼帪偵椺奜偑敪惗
*/
public LogAgentParam[] getLogAgentParams() throws LogPropertyException {
return model.getLogAgetnParams();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -