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

java.lang.Object
  上位を拡張 java.util.AbstractMap<K,V>
      上位を拡張 java.util.HashMap<String,MessageFormat>
          上位を拡張 jp.terasoluna.fw.web.struts.MessageFormatCloneReturnIfUseDateFormatMap
すべての実装されたインタフェース:
Serializable, Cloneable, Map<String,MessageFormat>

public class MessageFormatCloneReturnIfUseDateFormatMap
extends HashMap<String,MessageFormat>

Strutsのバグ(STR-2172)回避用HashMap(MessageFormatキャッシュ)。

StrutsのMessageResourcesは、キャッシュからgetしたMessageFormatを同期化せずに複数スレッドでアクセス可能にしている。
このバグを回避するため、キャッシュから同一インスタンスを返さず、cloneインスタンスを返すよう拡張している。
ただし、全てのMessageFormatを無条件にcloneするのではなく、 明らかにスレッドアンセーフ問題が発生する、DateFormatをサブフォーマットに持つMessageFormatのみ、 get時にcloneする。

このクラスは、StrutsのMessageResourcesのバグ回避専用クラスである。
putメソッド(null値の設定なし)とgetメソッドのみ使用されることを前提としている。
その他のメソッドを使用した場合の、Mapとしての動作は保証しない。
また、putの戻り値では、前回のputの引数で渡されたインスタンスではなく、等価なcloneインスタンスを返す場合がある。 (get時にcloneインスタンスを返す条件を満たすものがこれに該当する。)

関連項目:
MessageFormatCacheMapFactory, 直列化された形式

コンストラクタの概要
MessageFormatCloneReturnIfUseDateFormatMap()
           
 
メソッドの概要
 MessageFormat get(Object key)
          キャッシュされたMessageFormatインスタンスを、必要に応じてcloneして返す。
 MessageFormat put(String key, MessageFormat value)
          MessageFormatインスタンスをキャッシュする。
 
クラス java.util.HashMap から継承されたメソッド
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
クラス java.util.AbstractMap から継承されたメソッド
equals, hashCode, toString
 
クラス java.lang.Object から継承されたメソッド
finalize, getClass, notify, notifyAll, wait, wait, wait
 
インタフェース java.util.Map から継承されたメソッド
equals, hashCode
 

コンストラクタの詳細

MessageFormatCloneReturnIfUseDateFormatMap

public MessageFormatCloneReturnIfUseDateFormatMap()
メソッドの詳細

put

public MessageFormat put(String key,
                         MessageFormat value)
MessageFormatインスタンスをキャッシュする。

定義:
インタフェース Map<String,MessageFormat> 内の put
オーバーライド:
クラス HashMap<String,MessageFormat> 内の put
パラメータ:
key - MessageFormatキャッシュ時のキー
value - キャッシュするMessageFormatインスタンス
戻り値:
メソッド実行前にキャッシュされていたMessageFormatインスタンス

get

public MessageFormat get(Object key)
キャッシュされたMessageFormatインスタンスを、必要に応じてcloneして返す。

定義:
インタフェース Map<String,MessageFormat> 内の get
オーバーライド:
クラス HashMap<String,MessageFormat> 内の get
パラメータ:
key - MessageFormatキャッシュ時のキー
戻り値:
MessageFormatインスタンス


Copyright © 2012. All Rights Reserved.