public abstract class WebApplicationContextUtils extends ObjectSE
ServletContext
EE のルート WebApplicationContext
を取得するための便利なメソッド。これは、カスタム Web ビューまたは MVC アクション内から Spring アプリケーションコンテキストにプログラムでアクセスする場合に役立ちます。多くの Web フレームワーク(Spring の一部、または外部ライブラリとして利用可能)のルートコンテキストにアクセスするより便利な方法があることに注意してください。このヘルパークラスは、ルートコンテキストにアクセスするための最も一般的な方法にすぎません。
ContextLoader
, FrameworkServlet
, DispatcherServlet
, FacesContextUtils
, SpringBeanFacesELResolver
コンストラクターと説明 |
---|
WebApplicationContextUtils() |
修飾子と型 | メソッドと説明 |
---|---|
static WebApplicationContext | findWebApplicationContext(ServletContextEE sc) この Web アプリの一意の WebApplicationContext を見つけます。ルート Web アプリのコンテキスト(推奨)または登録済み ServletContext 属性の中で一意の WebApplicationContext (通常、現在の Web アプリケーションの単一の DispatcherServlet から取得)。 |
static WebApplicationContext | getRequiredWebApplicationContext(ServletContextEE sc) この Web アプリのルート WebApplicationContext を見つけます。通常は ContextLoaderListener を介してロードされます。 |
static WebApplicationContext | getWebApplicationContext(ServletContextEE sc) この Web アプリのルート WebApplicationContext を見つけます。通常は ContextLoaderListener を介してロードされます。 |
static WebApplicationContext | getWebApplicationContext(ServletContextEE sc, StringSE attrName) この Web アプリのカスタム WebApplicationContext を見つけます。 |
static void | initServletPropertySources(MutablePropertySources propertySources, ServletContextEE servletContext) ServletConfig EE パラメーターに常に null を提供する initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig) の便利なバリアント。 |
static void | initServletPropertySources(MutablePropertySources propertySources, ServletContextEE servletContext, ServletConfigEE servletConfig) Servlet ベースの stub property sources を、指定された servletContext および servletConfig オブジェクトが入力された実際のインスタンスに置き換えます。 |
static void | registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContextEE sc) WebApplicationContext で使用される、指定された BeanFactory とともに Web 固有の環境 Bean ( "contextParameters"、"contextAttributes" ) を登録します。 |
static void | registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContextEE servletContext, ServletConfigEE servletConfig) WebApplicationContext で使用される、指定された BeanFactory とともに Web 固有の環境 Bean ( "contextParameters"、"contextAttributes" ) を登録します。 |
static void | registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory) WebApplicationContext で使用される、指定された BeanFactory に Web 固有のスコープ ("request" ,"session" ,"globalSession" ) を登録します。 |
static void | registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContextEE sc) WebApplicationContext で使用される、指定された BeanFactory に Web 固有のスコープ (「リクエスト」、「セッション」、"globalSession"、「アプリケーション」) を登録します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public static WebApplicationContext getRequiredWebApplicationContext(ServletContextEE sc) throws IllegalStateExceptionSE
WebApplicationContext
を見つけます。通常は ContextLoaderListener
を介してロードされます。ルートコンテキストの起動時に発生した例外を再スローし、コンテキストの起動の失敗とコンテキストがないことを区別します。
sc
- ServletContext は、次の Web アプリケーションコンテキストを検索します IllegalStateExceptionSE
- ルート WebApplicationContext が見つからなかった場合 WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
public static WebApplicationContext getWebApplicationContext(ServletContextEE sc)
WebApplicationContext
を見つけます。通常は ContextLoaderListener
を介してロードされます。ルートコンテキストの起動時に発生した例外を再スローし、コンテキストの起動の失敗とコンテキストがないことを区別します。
sc
- ServletContext は、次の Web アプリケーションコンテキストを検索します null
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
public static WebApplicationContext getWebApplicationContext(ServletContextEE sc, StringSE attrName)
WebApplicationContext
を見つけます。sc
- ServletContext は、次の Web アプリケーションコンテキストを検索します attrName
- 検索する ServletContext 属性の名前 null
public static WebApplicationContext findWebApplicationContext(ServletContextEE sc)
WebApplicationContext
を見つけます。ルート Web アプリのコンテキスト(推奨)または登録済み ServletContext
属性の中で一意の WebApplicationContext
(通常、現在の Web アプリケーションの単一の DispatcherServlet
から取得)。DispatcherServlet
のコンテキストの公開は、デフォルトでは true
である publishContext
プロパティを介して制御できますが、Web アプリで複数の DispatcherServlet
を登録しても、単一のコンテキストのみを公開するように選択的に切り替えることができます。
sc
- ServletContext は、次の Web アプリケーションコンテキストを検索します null
getWebApplicationContext(ServletContext)
, ServletContext.getAttributeNames()
EEpublic static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory)
beanFactory
- 設定する BeanFactorypublic static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContextEE sc)
beanFactory
- 設定する BeanFactorysc
- 実行している ServletContextpublic static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContextEE sc)
bf
- 設定する BeanFactorysc
- 実行している ServletContextpublic static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContextEE servletContext, ServletConfigEE servletConfig)
bf
- 設定する BeanFactoryservletContext
- 実行している ServletContextservletConfig
- 含まれているポートレットの ServletConfigpublic static void initServletPropertySources(MutablePropertySources propertySources, ServletContextEE servletContext)
ServletConfig
EE パラメーターに常に null
を提供する initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig)
の便利なバリアント。public static void initServletPropertySources(MutablePropertySources propertySources, ServletContextEE servletContext, ServletConfigEE servletConfig)
Servlet
ベースの stub property sources
を、指定された servletContext
および servletConfig
オブジェクトが入力された実際のインスタンスに置き換えます。このメソッドは、何度も呼び出される可能性があるという点でべき等ですが、スタブプロパティソースと対応する実際のプロパティソースの置換は 1 回だけ実行されます。
propertySources
- 初期化する MutablePropertySources
(null
であってはなりません)servletContext
- 現在の ServletContext
EE (null
または servlet context property source
がすでに初期化されている場合は無視されます)servletConfig
- 現在の ServletConfig
EE (null
または servlet config property source
がすでに初期化されている場合は無視されます)PropertySource.StubPropertySource
, ConfigurableEnvironment.getPropertySources()