📄 xmlservicepropertyhandler.java
字号:
synchronized (this.models) {
ServiceConfigModel model = _getServiceConfigModel(application, locale);
return model;
}
}
/**
*
* @param application
* @param locale
* @return
*/
private ServiceConfigModel _getServiceConfigModel(String application,
Locale locale) throws ServicePropertyException {
ServiceConfigModel result = null;
HashMap appMaps = (HashMap) models.get(locale);
if (appMaps == null) {
appMaps = new HashMap();
models.put(locale, appMaps);
}
if(!isDynamic()) {
result = (ServiceConfigModel) appMaps.get(application);
}
if (result == null) {
// 僼傽僀儖偑偁傞
if (checkServiceFile(application, locale)) {
result = createSerivceConfigModel(application, locale);
//懡尵岅懳墳
if (locale == null || !locale.equals(END_LOCALE)) {
locale = getParentLocale(locale);
ServiceConfigModel parent = _getServiceConfigModel(
application, locale);
result.setParent(parent);
}
appMaps.put(application, result);
} else {
// 僼傽僀儖偑側偄
if (locale == null || !locale.equals(END_LOCALE)) {
locale = getParentLocale(locale);
result = _getServiceConfigModel(application, locale);
} else {
return null;
}
}
}
return result;
}
private boolean checkServiceFile(String application, Locale locale) {
String filename = getPropertyPackage(application) + getXMLPrefix()
+ "-" + getApplicationID(application);
return XMLDocumentProducer.isFileExist(filename, locale);
}
/**
* 傾僾儕働乕僔儑儞ID偱巜掕偝傟偨儕僜乕僗儌僨儖傪惗惉偟傑偡丅
*
* @param application 傾僾儕働乕僔儑儞ID
* @param locale 儘働乕儖
* @return 傾僾儕働乕僔儑儞ID偵奩摉偡傞儕僜乕僗儌僨儖
* @throws ServicePropertyException 儕僜乕僗僶儞僪儖偺庢摼帪偵椺奜偑敪惗
*/
private ServiceConfigModel createSerivceConfigModel(String application,
Locale locale) throws ServicePropertyException {
ServiceConfigModel model = null;
String fn = getPropertyPackage(application)
+ getXMLPrefix() + "-"
+ getApplicationID(application);
String fileName = XMLDocumentProducer.getFileName(fn, locale);
ServiceConfigModelProducer producer = new ServiceConfigModelProducer();
try {
model = producer.createServiceConfigModel(fileName);
} catch (ParserConfigurationException e) {
throw new ServicePropertyException(e.getMessage(), e);
} catch (SAXException e) {
throw new ServicePropertyException(e.getMessage(), e);
} catch (IOException e) {
throw new ServicePropertyException(e.getMessage(), e);
} catch (IllegalArgumentException e) {
throw new ServicePropertyException(e.getMessage(), e);
}
return model;
}
/**
* 僾儘僷僥傿僴儞僪儔傪弶婜壔偟傑偡丅
*
* @param params 弶婜僷儔儊乕僞
* @throws PropertyHandlerException 僾儘僷僥傿僴儞僪儔偺弶婜壔帪偵椺奜偑敪惗
*/
public void init(PropertyParam[] params) throws PropertyHandlerException {
String bundleName = null;
String dynamic = null;
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (params[i].getName().equals(DEFAULT_BUNDLE_NAME_PARAM)) {
bundleName = params[i].getValue();
} else if (params[i].getName().equals(PARAM_DYNAMIC)) {
// 嵞愝掕壜擻僼儔僌偺応崌
dynamic = params[i].getValue();
}
}
}
if (bundleName == null) {
bundleName = DEFAULT_BUNDLE_NAME;
}
// 僾儗僼傿僢僋僗偺愝掕
setXMLPrefix(bundleName);
// 嵞愝掕壜擻僼儔僌偺愝掕
Boolean dummyDynamic = new Boolean(dynamic);
setDynamic(dummyDynamic.booleanValue());
}
/**
* 嵞愝掕壜擻乛晄壜擻傪愝掕偟傑偡丅
*
* @param dynamic true 嵞愝掕壜擻丄false 嵞愝掕晄壜
*
* @uml.property name="dynamic"
*/
private void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
/**
* 僾儘僷僥傿偺摦揑撉傒崬傒偑壜擻偐偳偆偐挷傋傑偡丅 偙偺僋儔僗偱偼偙偺儊僜僢僪偼忢偵false傪曉偟傑偡丅
*
* @return 忢偵false
* @throws ServicePropertyException 僠僃僢僋帪偵椺奜偑敪惗
*/
public boolean isDynamic() throws ServicePropertyException {
return this.dynamic;
}
/**
* 僋儔僀傾儞僩偺僄儞僐乕僪傪庢摼偟傑偡丅
*
* @return 僋儔僀傾儞僩偺僄儞僐乕僨傿儞僌
* @throws ServicePropertyException 僋儔僀傾儞僩偺僄儞僐乕僪偺庢摼帪偵椺奜偑敪惗
*/
public String getClientEncoding() throws ServicePropertyException {
CommonServiceModel model = getCommonServiceModel();
String encoding = model.getClientEncoding();
return encoding;
}
/**
* 僋儔僀傾儞僩偺僄儞僐乕僪傪庢摼偟傑偡丅
*
* @return 僋儔僀傾儞僩偺僄儞僐乕僨傿儞僌
* @throws ServicePropertyException 僋儔僀傾儞僩偺僄儞僐乕僪偺庢摼帪偵椺奜偑敪惗
*/
public Locale getClientLocale() throws ServicePropertyException {
CommonServiceModel model = getCommonServiceModel();
String localeString = model.getClientLocale();
Locale locale = null;
if (localeString != null) {
locale = getRealLocale(localeString);
}
return locale;
}
/**
*
* @param localeString
* @return
*/
private static Locale getRealLocale(String localeString) {
StringTokenizer tokenizer = new StringTokenizer(localeString, "-_");
if (tokenizer.countTokens() == 2) {
String language = tokenizer.nextToken();
String country = tokenizer.nextToken();
return new Locale(language, country);
} else if (tokenizer.countTokens() == 3) {
String language = tokenizer.nextToken();
String country = tokenizer.nextToken();
String variant = tokenizer.nextToken();
return new Locale(language, country, variant);
} else {
String message = null;
try {
message = ResourceBundle.getBundle(
"jp.co.intra_mart.framework.base.web.tag.i18n")
.getString("MessageTag.LocaleStringIncorrect");
} catch (MissingResourceException e) {
}
throw new IllegalArgumentException(message + " : \"" + localeString
+ "\"");
}
}
/**
* 擖椡椺奜帪偺儁乕僕偺僷僗傪庢摼偟傑偡丅 奩摉偡傞儁乕僕偺僷僗偑庢摼偱偒側偄応崌丄
* {@link #getInputErrorPagePath(String, String)}偱庢摼偝傟傞儁乕僕傪曉偟傑偡丅 偙偺儊僜僢僪偼
* {@link #getInputErrorPagePath(String, String, String, Locale) getInputErrorPagePath(application, service, key, (java.util.Locale)null)}
* 傪屇傫偩偲偒偲摨偠寢壥偵側傝傑偡丅
*
* @param application 傾僾儕働乕僔儑儞ID
* @param service 僒乕價僗ID
* @param key 慗堏愭偺僉乕
* @return 慗堏愭偺儁乕僕偺僷僗
* @throws ServicePropertyException 慗堏愭偺儁乕僕偺僷僗偺庢摼帪偵椺奜偑敪惗
* @deprecated 偙偺儊僜僢僪偱偼側偔
* {@link #getInputErrorPagePath(String, String, String, Locale)}
* 傪巊梡偟偰偔偩偝偄丅
*/
public String getInputErrorPagePath(String application, String service,
String key) throws ServicePropertyException {
String result = null;
ServiceConfigModel serviceConfig = getServiceConfigModel(application);
if (serviceConfig != null) {
result = serviceConfig.getInputErrorPagePath(service, key);
}
if (result == null) {
try {
result = getInputErrorPagePath(application, service);
} catch (ServicePropertyException e) {
}
}
if (result == null) {
String idMessage = " : application = " + application
+ " : service = " + service + " : key = " + key;
String message = ServiceResourceMessage
.getResourceString("ResourceBundleServicePropertyHandlerUtil.FailedToGetInputErrorPagePath");
throw new ServicePropertyException(message + idMessage);
}
return result;
}
/**
* 擖椡椺奜帪偺儁乕僕偺僷僗傪庢摼偟傑偡丅 奩摉偡傞儁乕僕偺僷僗偑庢摼偱偒側偄応崌丄
* {@link #getInputErrorPagePath(String, String)}偱庢摼偝傟傞儁乕僕傪曉偟傑偡丅
*
* @param application 傾僾儕働乕僔儑儞ID
* @param service 僒乕價僗ID
* @param key 慗堏愭偺僉乕
* @param locale 儘働乕儖
* @return 慗堏愭偺儁乕僕偺僷僗
* @throws ServicePropertyException 慗堏愭偺儁乕僕偺僷僗偺庢摼帪偵椺奜偑敪惗
*/
public String getInputErrorPagePath(String application, String service,
String key, Locale locale) throws ServicePropertyException {
String result = null;
ServiceConfigModel serviceConfig = getServiceConfigModel(application,
locale);
if (serviceConfig != null) {
result = serviceConfig.getInputErrorPagePath(service, key);
}
if (result == null) {
try {
result = getInputErrorPagePath(application, service, locale);
} catch (ServicePropertyException e) {
}
}
if (result == null) {
String idMessage = " : application = " + application
+ " : service = " + service + " : key = " + key;
String message = ServiceResourceMessage
.getResourceString("ResourceBundleServicePropertyHandlerUtil.FailedToGetInputErrorPagePath");
throw new ServicePropertyException(message + idMessage);
}
return result;
}
/**
* 擖椡椺奜帪偺儁乕僕偺僷僗傪庢摼偟傑偡丅 奩摉偡傞儁乕僕偺僷僗偑庢摼偱偒側偄応崌丄
* {@link #getInputErrorPagePath(String)}偱庢摼偝傟傞儁乕僕傪曉偟傑偡丅 偙偺儊僜僢僪偼
* {@link #getInputErrorPagePath(String, String, Locale) getInputErrorPagePath(application, service, (java.util.Locale)null)}
* 傪屇傫偩偲偒偲摨偠寢壥偵側傝傑偡丅
*
* @param application 傾僾儕働乕僔儑儞ID
* @param service 僒乕價僗ID
* @return 慗堏愭偺儁乕僕偺僷僗
* @throws ServicePropertyException 慗堏愭偺儁乕僕偺僷僗偺庢摼帪偵椺奜偑敪惗
* @deprecated 偙偺儊僜僢僪偱偼側偔
* {@link #getInputErrorPagePath(String, String, Locale)}
* 傪巊梡偟偰偔偩偝偄丅
*/
public String getInputErrorPagePath(String application, String service)
throws ServicePropertyException {
String result = null;
ServiceConfigModel serviceConfig = getServiceConfigModel(application);
if (serviceConfig != null) {
result = serviceConfig.getInputErrorPagePath(service);
}
if (result == null) {
try {
result = getInputErrorPagePath(application);
} catch (ServicePropertyException e) {
}
}
if (result == null) {
String idMessage = " : application = " + application
+ " : service = " + service;
String message = ServiceResourceMessage
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -