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

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

public class MessageFormatCacheMapFactory
extends 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

コンストラクタの概要
MessageFormatCacheMapFactory()
           
 
メソッドの概要
static HashMap<String,MessageFormat> getInstance()
          Strutsのバグ(STR-2172)回避用HashMapインスタンスを返す。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

MessageFormatCacheMapFactory

public MessageFormatCacheMapFactory()
メソッドの詳細

getInstance

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

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

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


Copyright © 2012. All Rights Reserved.