Class ResourceExceptionCodeDescriptor
- java.lang.Object
-
- net.cofcool.chaos.server.core.i18n.ResourceExceptionCodeDescriptor
-
- All Implemented Interfaces:
ExceptionCodeDescriptor,org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware
public class ResourceExceptionCodeDescriptor extends Object implements ExceptionCodeDescriptor, org.springframework.context.MessageSourceAware
ExceptionCodeDescriptor 的实现, 通过MessageSource获取异常描述信息. 资源文件格式为:SERVER_OK=00:serverOk
默认使用 : 分割描述码和描述信息, 可通过ResourceExceptionCodeDescriptor(String)定义该分隔符. 国际化拦截器可参考 localeChangeInterceptor
注意: 当描述信息不存在且调用MessageSource.getMessage(String, Object[], Locale)未抛出NoSuchMessageException异常, 则默认配置并不会生效, 是否抛出异常由AbstractMessageSource.setUseCodeAsDefaultMessage(boolean)控制- See Also:
LocaleChangeInterceptor,LocaleResolver
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.cofcool.chaos.server.common.core.ExceptionCodeDescriptor
ExceptionCodeDescriptor.CodeMessage
-
-
Field Summary
-
Fields inherited from interface net.cofcool.chaos.server.common.core.ExceptionCodeDescriptor
AUTH_ERROR, CAPTCHA_ERROR, DATA_ERROR, DATA_EXISTS, DENIAL_AUTH, DENIAL_DEVICE, DENIAL_OPERATING, LOWEST_LEVEL_API, NO_ACCESS, NO_LOGIN, OPERATION_ERR, PARAM_ERROR, PARAM_NULL, SERVER_ERR, SERVER_OK, USER_NOT_EXITS, USER_PASSWORD_ERROR, USERNAME_ERROR
-
-
Constructor Summary
Constructors Constructor Description ResourceExceptionCodeDescriptor()创建实例, key-value 分隔符默认为:ResourceExceptionCodeDescriptor(String separator)创建实例
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcode(String type)Stringdescription(String type)voidsetMessageSource(org.springframework.context.MessageSource messageSource)
-
-
-
Constructor Detail
-
ResourceExceptionCodeDescriptor
public ResourceExceptionCodeDescriptor()
创建实例, key-value 分隔符默认为:
-
ResourceExceptionCodeDescriptor
public ResourceExceptionCodeDescriptor(String separator)
创建实例- Parameters:
separator- key-value 分隔符
-
-
Method Detail
-
code
public String code(String type)
- Specified by:
codein interfaceExceptionCodeDescriptor
-
description
public String description(String type)
- Specified by:
descriptionin interfaceExceptionCodeDescriptor
-
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource)
- Specified by:
setMessageSourcein interfaceorg.springframework.context.MessageSourceAware
-
-