public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSource implements BeanClassLoaderAware
MessageSource 実装。このクラスは、MessageFormatSE が提供する JDK の標準メッセージ解析と組み合わせて、基礎となる JDK の ResourceBundleSE 実装に依存しています。 この MessageSource は、アクセスされた ResourceBundle インスタンスと、各メッセージの生成された MessageFormats の両方をキャッシュします。また、AbstractMessageSource 基本クラスでサポートされているように、MessageFormat なしの引数なしメッセージのレンダリングも実装します。この MessageSource によって提供されるキャッシュは、java.util.ResourceBundle クラスの組み込みキャッシュよりも大幅に高速です。
ベース名は ResourceBundleSE の規則に従います。基本的に、完全修飾クラスパスの場所です。パッケージ修飾子(org.mypackage など)が含まれていない場合は、クラスパスルートから解決されます。JDK の標準 ResourceBundle は、ドットをパッケージ区切り文字として扱うことに注意してください。これは、"test.theme" が事実上「テスト / テーマ」と同等であることを意味します。
AbstractResourceBasedMessageSource.setBasenames(java.lang.String...), ReloadableResourceBundleMessageSource, ResourceBundleSE, MessageFormatSElogger| コンストラクターと説明 |
|---|
ResourceBundleMessageSource() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected ResourceBundleSE | doGetBundle(StringSE basename, LocaleSE locale) 指定されたベース名とロケールのリソースバンドルを取得します。 |
protected ClassLoaderSE | getBundleClassLoader() リソースバンドルをロードする ClassLoader を返します。 |
protected MessageFormatSE | getMessageFormat(ResourceBundleSE bundle, StringSE code, LocaleSE locale) 指定されたバンドルとコードの MessageFormat を返し、すでに生成された MessageFormats をキャッシュから取得します。 |
protected ResourceBundleSE | getResourceBundle(StringSE basename, LocaleSE locale) 指定されたベース名とコードに対して ResourceBundle を返し、すでに生成された MessageFormats をキャッシュから取得します。 |
protected StringSE | getStringOrNull(ResourceBundleSE bundle, StringSE key) 指定されたキーの文字列値を効率的に取得します。見つからない場合は null を返します。 |
protected ResourceBundleSE | loadBundle(ReaderSE reader) 指定されたリーダーからプロパティベースのリソースバンドルをロードします。 |
protected MessageFormatSE | resolveCode(StringSE code, LocaleSE locale) キャッシュされた MessageFormat インスタンスをメッセージコードごとに使用して、登録されたリソースバンドルのキーとして指定されたメッセージコードを解決します。 |
protected StringSE | resolveCodeWithoutArguments(StringSE code, LocaleSE locale) 登録されたリソースバンドルのキーとして指定されたメッセージコードを解決し、バンドルで見つかった値をそのまま(MessageFormat 解析なしで)返します。 |
void | setBeanClassLoader(ClassLoaderSE classLoader)Bean class loaderSE を Bean インスタンスに提供するコールバック。 |
void | setBundleClassLoader(ClassLoaderSE classLoader) リソースバンドルを読み込む ClassLoader を設定します。 |
StringSE | toString() この MessageSource の構成を表示します。 |
addBasenames, getBasenameSet, getCacheMillis, getDefaultEncoding, isFallbackToSystemLocale, setBasename, setBasenames, setCacheMillis, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocalegetCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessagecreateMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, setAlwaysUseMessageFormatcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEpublic void setBundleClassLoader(ClassLoaderSE classLoader)
デフォルトは BeanFactory の bean ClassLoader を含むか、BeanFactory 内で実行されていない場合は ClassUtils.getDefaultClassLoader() によって決定されるデフォルト ClassLoader です。
@Nullable protected ClassLoaderSE getBundleClassLoader()
デフォルトは、BeanFactory の Bean ClassLoader を含んでいます。
public void setBeanClassLoader(ClassLoaderSE classLoader)
BeanClassLoaderAwareclass loaderSE を Bean インスタンスに提供するコールバック。 通常の Bean プロパティの設定後、ただし InitializingBean's InitializingBean.afterPropertiesSet() メソッドやカスタム init-method などの初期化コールバックの前に呼び出されます。
BeanClassLoaderAware の setBeanClassLoader classLoader - 所有クラスローダー protected StringSE resolveCodeWithoutArguments(StringSE code, LocaleSE locale)
AbstractMessageSource の resolveCodeWithoutArguments code - 解決するメッセージのコード locale - コードを解決するロケール (サブクラスは国際化をサポートすることが推奨されます)null AbstractMessageSource.resolveCode(java.lang.String, java.util.Locale), MessageFormatSE@Nullable protected MessageFormatSE resolveCode(StringSE code, LocaleSE locale)
AbstractMessageSource の resolveCode code - 解決するメッセージのコード locale - コードを解決するロケール (サブクラスは国際化をサポートすることが推奨されます)null AbstractMessageSource.resolveCodeWithoutArguments(String, java.util.Locale)@Nullable protected ResourceBundleSE getResourceBundle(StringSE basename, LocaleSE locale)
basename - ResourceBundle のベース名 locale - ResourceBundle を見つけるためのロケール null protected ResourceBundleSE doGetBundle(StringSE basename, LocaleSE locale) throws MissingResourceExceptionSE
basename - 検索するベース名 locale - 検索するロケール MissingResourceExceptionSE - 一致するバンドルが見つからなかった場合 ResourceBundle.getBundle(String, Locale, ClassLoader)SE, getBundleClassLoader()protected ResourceBundleSE loadBundle(ReaderSE reader) throws IOExceptionSE
デフォルトの実装は PropertyResourceBundleSE を返します。
reader - ターゲットリソースのリーダー IOExceptionSE - I/O 障害の場合 PropertyResourceBundle.PropertyResourceBundle(Reader)SE@Nullable protected MessageFormatSE getMessageFormat(ResourceBundleSE bundle, StringSE code, LocaleSE locale) throws MissingResourceExceptionSE
bundle - ResourceBundle に取り組む code - 取得するメッセージコード locale - MessageFormat の構築に使用するロケール null MissingResourceExceptionSE - ResourceBundle によってスローされた場合 @Nullable protected StringSE getStringOrNull(ResourceBundleSE bundle, StringSE key)
null を返します。4.2 の時点で、デフォルトの実装は containsKey をチェックしてから getString を呼び出します(キーが見つからない場合は MissingResourceException をキャッチする必要があります)。
サブクラスでオーバーライドできます。
bundle - ResourceBundle で検索を実行します key - 見上げる鍵 null ResourceBundle.getString(String)SE, ResourceBundle.containsKey(String)SEpublic StringSE toString()
ObjectSE の toStringSE