public class ServletContextAttributeExporter extends ObjectSE implements ServletContextAware
Spring をまったく認識せず、サーブレット API のみを認識するコードで Spring 定義の Bean を使用できるようにできます。クライアントコードは、Spring アプリケーションコンテキストで定義されているにもかかわらず、プレーン ServletContext 属性ルックアップを使用してこれらのオブジェクトにアクセスできます。
あるいは、WebApplicationContextUtils クラスを使用して、WebApplicationContext インターフェース経由で Spring 定義の Bean にアクセスすることを検討してください。これにより、クライアントコードはもちろん Spring API を認識します。
ServletContext.getAttribute(java.lang.String)
EE, WebApplicationContextUtils.getWebApplicationContext(javax.servlet.ServletContext)
コンストラクターと説明 |
---|
ServletContextAttributeExporter() |
修飾子と型 | メソッドと説明 |
---|---|
void | setAttributes(MapSE<StringSE, ObjectSE> attributes) キーと値のペアとして公開する ServletContext 属性を設定します。 |
void | setServletContext(ServletContextEE servletContext) このオブジェクトが実行される ServletContext EE を設定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
protected final Log logger
public void setAttributes(MapSE<StringSE,ObjectSE> attributes)
通常、値に Bean 参照を使用して、Spring 定義の Bean を ServletContext 属性としてエクスポートします。もちろん、エクスポートするプレーンな値を定義することも可能です。
public void setServletContext(ServletContextEE servletContext)
ServletContextAware
ServletContext
EE を設定します。 通常の Bean プロパティの設定後、InitializingBean の afterPropertiesSet
またはカスタム init メソッドのような初期コールバックの前に呼び出されます。ApplicationContextAware の setApplicationContext
の後に呼び出されます。
ServletContextAware
の setServletContext
servletContext
- このオブジェクトによって使用される ServletContext オブジェクト InitializingBean.afterPropertiesSet()
, ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)