public class FacesRequestAttributes extends ObjectSE implements RequestAttributes
FacesContext
EE 用の RequestAttributes
アダプター。JSF 環境でデフォルトとして使用され、現在の FacesContext をラップします。 注 :ServletRequestAttributes
とは対照的に、このバリアントは、リクエストスコープでもセッションスコープでも、スコープ属性の破棄コールバックをサポートしていません。このような暗黙の破棄コールバックに依存している場合は、web.xml
で Spring RequestContextListener
を定義することを検討してください。
Spring 4.0 以降、JSF 2.0 以上が必要です。
FacesContext.getExternalContext()
EE, ExternalContext.getRequestMap()
EE, ExternalContext.getSessionMap()
EE, RequestContextHolder.currentRequestAttributes()
REFERENCE_REQUEST, REFERENCE_SESSION, SCOPE_REQUEST, SCOPE_SESSION
コンストラクターと説明 |
---|
FacesRequestAttributes(FacesContextEE facesContext) 指定された FacesContext の新しい FacesRequestAttributes アダプターを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
ObjectSE | getAttribute(StringSE name, int scope) 指定された名前のスコープ付き属性の値を返します(ある場合)。 |
protected MapSE<StringSE, ObjectSE> | getAttributeMap(int scope) 指定されたスコープの JSF 属性マップを返します。 |
StringSE[] | getAttributeNames(int scope) スコープ内のすべての属性の名前を取得します。 |
protected ExternalContextEE | getExternalContext() このアダプターが動作する JSF ExternalContext を返します。 |
protected FacesContextEE | getFacesContext() このアダプターが動作する JSF FacesContext を返します。 |
StringSE | getSessionId() 現在の基本的なセッションの ID を返します。 |
ObjectSE | getSessionMutex() 基盤となるセッションで利用可能な最良のミューテックス、つまり、基盤となるセッションで同期するオブジェクトを公開します。 |
void | registerDestructionCallback(StringSE name, RunnableSE callback, int scope) 指定されたスコープ内の指定された属性の破棄時に実行されるコールバックを登録します。 |
void | removeAttribute(StringSE name, int scope) 指定された名前のスコープ属性が存在する場合は削除します。 |
ObjectSE | resolveReference(StringSE key) 指定されたキーのコンテキスト参照を解決します(ある場合)。 |
void | setAttribute(StringSE name, ObjectSE value, int scope) 指定された名前のスコープ属性の値を設定し、既存の値(存在する場合)を置き換えます。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public FacesRequestAttributes(FacesContextEE facesContext)
facesContext
- 現在の FacesContextFacesContext.getCurrentInstance()
EEprotected final FacesContextEE getFacesContext()
protected final ExternalContextEE getExternalContext()
protected MapSE<StringSE,ObjectSE> getAttributeMap(int scope)
scope
- リクエストまたはセッションスコープを示す定数 RequestAttributes.SCOPE_REQUEST
, RequestAttributes.SCOPE_SESSION
public ObjectSE getAttribute(StringSE name, int scope)
RequestAttributes
RequestAttributes
の getAttribute
name
- 属性の名前 scope
- スコープ識別子 null
public void setAttribute(StringSE name, ObjectSE value, int scope)
RequestAttributes
RequestAttributes
の setAttribute
name
- 属性の名前 value
- 属性の値 scope
- スコープ識別子 public void removeAttribute(StringSE name, int scope)
RequestAttributes
実装では、指定された属性に登録されている破棄コールバックも削除する必要があることに注意してください。ただし、この場合、登録された破棄コールバックを実行する必要はありません。オブジェクトが呼び出し側によって破棄されるためです(該当する場合)。
RequestAttributes
の removeAttribute
name
- 属性の名前 scope
- スコープ識別子 public StringSE[] getAttributeNames(int scope)
RequestAttributes
RequestAttributes
の getAttributeNames
scope
- スコープ識別子 public void registerDestructionCallback(StringSE name, RunnableSE callback, int scope)
RequestAttributes
実装は、適切なときに、つまり、それぞれリクエストの補完時またはセッションの終了時にコールバックを実行するために最善を尽くす必要があります。そのようなコールバックが基本的なランタイム環境でサポートされていない場合は、コールバックを無視して、対応する警告をログに記録する必要があります。
「破棄」は通常、スコープ全体の破棄に対応し、アプリケーションによって明示的に削除された個々の属性には対応しないことに注意してください。このファサードの RequestAttributes.removeAttribute(String, int)
メソッドを介して属性が削除された場合、削除されたオブジェクトが再利用されるか手動で破棄されると想定して、登録されている破棄コールバックも無効にする必要があります。
注意 : コールバックオブジェクトは、セッションスコープに登録されている場合、通常は直列化可能である必要があります。そうしないと、コールバック(またはセッション全体)が Web アプリの再起動に耐えられない可能性があります。
RequestAttributes
の registerDestructionCallback
name
- コールバックを登録する属性の名前 callback
- 実行される破棄コールバック scope
- スコープ識別子 public ObjectSE resolveReference(StringSE key)
RequestAttributes
最低でも: キー「リクエスト」の HttpServletRequest リファレンス、およびキー「セッション」の HttpSession リファレンス。
RequestAttributes
の resolveReference
key
- コンテキストキー null
public StringSE getSessionId()
RequestAttributes
RequestAttributes
の getSessionId
null
)public ObjectSE getSessionMutex()
RequestAttributes
RequestAttributes
の getSessionMutex
null
)