📄 xmlpropertymanager.java
字号:
/*
* DefaultPropertyManager.java
*
* Created on 2001/11/08, 11:17
*/
package jp.co.intra_mart.framework.system.property;
import java.io.IOException;
import java.util.MissingResourceException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import jp.co.intra_mart.framework.system.property.PropertyHandlerException;
/**
* xml偺僾儘僷僥傿儅僱乕僕儍偱偡丅
* 僾儘僷僥傿忣曬傪娗棟偟傑偡丅
*
* @author INTRAMART
* @version 1.0
*/
public class XmlPropertyManager extends PropertyManager {
/**
* 僾儘僷僥傿儅僱乕僕儍傪巜掕偡傞僉乕
*/
public static final String KEY = "jp.co.intra_mart.framework.system.property.XmlPropertyManager";
/**
* 僨僼僅儖僩偺儕僜乕僗僶儞僪儖柤
*/
public static final String DEFAULT_BUNDLE_NAME = "property-config.xml";
/**
* 僾儘僷僥傿僐儞僼傿僌忣曬
*/
private PropertyConfigModel config;
/**
* 僐儞僗僩儔僋僞偱偡丅
*
* @throws PropertyManagerException 僾儘僷僥傿儅僱乕僕儍偺愝掕偵幐攕
*/
public XmlPropertyManager() throws PropertyManagerException {
super();
String bundleName = System.getProperty(KEY, DEFAULT_BUNDLE_NAME);
if ( bundleName == null ) {
bundleName = DEFAULT_BUNDLE_NAME;
}
this.config = getPropertyConfigModel( bundleName );
}
/**
* 僉乕偱巜掕偝傟偨僾儘僷僥傿僴儞僪儔偺僋儔僗柤傪庢摼偟傑偡丅
*
* @return 僾儘僷僥傿僴儞僪儔偺僋儔僗柤
* @param key 僾儘僷僥傿僴儞僪儔偺僉乕
* @throws PropertyHandlerException 僋儔僗柤偺庢摼偵幐攕
*/
protected String getPropertyHandlerName(String key) throws PropertyHandlerException {
String result;
try {
result = config.getPropertyHandlerName( key );
if ( result == null ) {
throw new PropertyHandlerException();
}
} catch ( Exception e ) {
String message = null;
try {
message = java.util.ResourceBundle.getBundle("jp.co.intra_mart.framework.system.property.i18n").getString("DefaultPropertyManager.NoSuchKey");
} catch (MissingResourceException ex) {
}
throw new PropertyHandlerException(message + " : key = " + key);
}
return result;
}
/**
* 僉乕偱巜掕偝傟偨僾儘僷僥傿僴儞僪儔偺弶婜壔僨乕僞傪庢摼偟傑偡丅
* 弶婜壔僨乕僞偑懚嵼偟側偄応崌丄null偑曉傝傑偡丅
*
* @param key 僾儘僷僥傿僴儞僪儔偺僉乕
* @return 僾儘僷僥傿僴儞僪儔偺弶婜壔僨乕僞
*/
protected PropertyHandlerParam[] getPropertyHandlerParams(String key) {
PropertyHandlerParam[] result;
result = config.getPropertyParams( key );
return result;
}
/**
* 僾儘僷僥傿儌僨儖傪惗惉偟傑偡丅
*
* @param application 傾僾儕働乕僔儑儞ID
* @return 傾僾儕働乕僔儑儞ID偲僉乕偵懳墳偡傞僀儀儞僩儌僨儖
* @throws EventPropertyException丂儌僨儖惗惉帪偺庢摼帪偵椺奜偑敪惗
*/
private PropertyConfigModel getPropertyConfigModel( String bundleName ) throws PropertyManagerException {
try{
PropertyConfigModelProducer producer = new PropertyConfigModelProducer();
PropertyConfigModel model = producer.createPropertyConfigModel( bundleName );
return model;
}catch (ParserConfigurationException e){
throw new PropertyManagerException(e.getMessage(), e);
}catch (SAXException e) {
throw new PropertyManagerException(e.getMessage(), e);
}catch (IOException e) {
throw new PropertyManagerException(e.getMessage(), e);
}catch (IllegalArgumentException e) {
throw new PropertyManagerException(e.getMessage(), e);
}catch (Exception e) {
throw new PropertyManagerException(e.getMessage(), e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -