jp.terasoluna.fw.web.struts
クラス MessageFormatCacheMapFactory

java.lang.Object
  上位を拡張 jp.terasoluna.fw.web.struts.MessageFormatCacheMapFactory

public class MessageFormatCacheMapFactory
extends java.lang.Object

Strutsのバグ(STR-2172)回避用HashMap(MessageFormatキャッシュ)のファクトリクラス。

StrutsのMessageResourcesは、キャッシュからgetしたMessageFormatを同期化せずに複数スレッドでアクセス可能にしている。
このバグを回避するための拡張HashMapを生成する。

参考)
少なくともSun JDKの実装を使用している限りは、日付時刻系のサブフォーマット({0,date}等)を使用しない限り、 MessageFormatの仕様には反するものの、同一インスタンスのformatメソッドを複数スレッドで同時に実行しても、 全く問題ない。(これが、StrutsのMessageResourcesのバグSTR-2172がWon't Fixとなり、修正されなかった理由。)
このクラスではバグの回避方法を調整可能としている。system.propertiesに以下の設定を行う。

system.properties設定例
同一MessageFormatを複数スレッドで使用しないよう、常にcloneする(MessageFormatの仕様に準拠) messageResources.messageFormatClone = enable
日付時刻系のサブフォーマットが使用されたときのみ、同一MessageFormatを複数スレッドで使用しないよう、cloneする (デフォルト)
(SunのMessageFormatおよびそこから使用されるFormatクラスの実装に合わせ最適化)
messageResources.messageFormatClone = dateFormatOnly
バグ回避を行わず、Strutsの実装のまま動作する messageResources.messageFormatClone = disable
設定自体を省略した場合や、上記以外の設定値が設定された場合は dateFormatOnly として扱われる。

関連項目:
MessageFormatCloneReturnMap, MessageFormatCloneReturnIfUseDateFormatMap, PropertyMessageResourcesEx, DBMessageResources, SpringMessageResources

フィールドの概要
private static java.lang.String DATE_FORMAT_ONLY
          messageFormatClone設定値:dateFormatOnly
private static java.lang.String DISABLE
          messageFormatClone設定値:disable
private static java.lang.String ENABLE
          messageFormatClone設定値:enable
private static org.apache.commons.logging.Log log
          ログインスタンス
private static java.lang.String MESSAGE_FORMAT_CLONE_KEY
          messageFormatClone設定値のプロパティキー
 
コンストラクタの概要
MessageFormatCacheMapFactory()
           
 
メソッドの概要
static java.util.HashMap<java.lang.String,java.text.MessageFormat> getInstance()
          Strutsのバグ(STR-2172)回避用HashMapインスタンスを返す。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

log

private static org.apache.commons.logging.Log log
ログインスタンス


MESSAGE_FORMAT_CLONE_KEY

private static final java.lang.String MESSAGE_FORMAT_CLONE_KEY
messageFormatClone設定値のプロパティキー

関連項目:
定数フィールド値

ENABLE

private static final java.lang.String ENABLE
messageFormatClone設定値:enable

関連項目:
定数フィールド値

DISABLE

private static final java.lang.String DISABLE
messageFormatClone設定値:disable

関連項目:
定数フィールド値

DATE_FORMAT_ONLY

private static final java.lang.String DATE_FORMAT_ONLY
messageFormatClone設定値:dateFormatOnly

関連項目:
定数フィールド値
コンストラクタの詳細

MessageFormatCacheMapFactory

public MessageFormatCacheMapFactory()
メソッドの詳細

getInstance

public static java.util.HashMap<java.lang.String,java.text.MessageFormat> getInstance()
Strutsのバグ(STR-2172)回避用HashMapインスタンスを返す。

設定により、バグ回避が無効化されている場合は、nullを返す。

戻り値:
Strutsのバグ(STR-2172)回避用HashMapインスタンス