public class ServletWebServerApplicationContext extends GenericWebApplicationContext implements ConfigurableWebServerApplicationContext
ServletWebServerFactory
Bean からブートストラップするために使用できる WebApplicationContext
。 このコンテキストは、ApplicationContext
内で単一の ServletWebServerFactory
Bean を検索することにより、WebServer
を作成、初期化、実行します。ServletWebServerFactory
は、標準の Spring の概念(依存性注入、ライフサイクルコールバック、プロパティプレースホルダー変数など)を自由に使用できます。
さらに、コンテキストで定義された Servlet
EE または Filter
EE Bean は、Web サーバーに自動的に登録されます。単一のサーブレット Bean の場合、"/" マッピングが使用されます。複数のサーブレット Bean が見つかった場合は、小文字の Bean 名がマッピングプレフィックスとして使用されます。'dispatcherServlet' という名前のサーブレットは常に '/' にマップされます。フィルター Bean はすべての URL('/*')にマップされます。
より高度な構成の場合、コンテキストは代わりに ServletContextInitializer
インターフェース(ほとんどの場合 ServletRegistrationBean
や FilterRegistrationBean
)を実装する Bean を定義できます。二重登録を防ぐために、ServletContextInitializer
Bean を使用すると、自動サーブレットおよびフィルター Bean 登録が無効になります。
このコンテキストは直接使用できますが、ほとんどの開発者は AnnotationConfigServletWebServerApplicationContext
または XmlServletWebServerApplicationContext
バリアントの使用を検討する必要があります。
AnnotationConfigServletWebServerApplicationContext
, XmlServletWebServerApplicationContext
, ServletWebServerFactory
修飾子と型 | クラスと説明 |
---|---|
static class | ServletWebServerApplicationContext.ExistingWebApplicationScopes ユーザー定義のスコープを保存および復元するユーティリティクラス。 |
DefaultResourceLoader.ClassPathContextResource
修飾子と型 | フィールドと説明 |
---|---|
static StringSE | DISPATCHER_SERVLET_NAME DispatcherServlet Bean 名の定数値。 |
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, MESSAGE_SOURCE_BEAN_NAME
APPLICATION_STARTUP_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
FACTORY_BEAN_PREFIX
CLASSPATH_ALL_URL_PREFIX
CLASSPATH_URL_PREFIX
APPLICATION_CONTEXT_ID_PREFIX, SERVLET_CONFIG_BEAN_NAME
CONTEXT_ATTRIBUTES_BEAN_NAME, CONTEXT_PARAMETERS_BEAN_NAME, ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME
コンストラクターと説明 |
---|
ServletWebServerApplicationContext() 新しい ServletWebServerApplicationContext を作成します。 |
ServletWebServerApplicationContext(DefaultListableBeanFactory beanFactory) 指定された DefaultListableBeanFactory で新しい ServletWebServerApplicationContext を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected void | doClose() |
protected Resource | getResourceByPath(StringSE path) |
StringSE | getServerNamespace() Web サーバーアプリケーションコンテキストの名前空間を返します。名前空間が設定されていない場合は null を返します。 |
ServletConfigEE | getServletConfig() |
protected CollectionSE<ServletContextInitializer> | getServletContextInitializerBeans() 組み込み Web サーバーで使用する必要がある ServletContextInitializer を返します。 |
WebServer | getWebServer() コンテキストによって作成された WebServer を返します。サーバーがまだ作成されていない場合は null を返します。 |
protected ServletWebServerFactory | getWebServerFactory() 埋め込み WebServer の作成に使用する必要がある ServletWebServerFactory を返します。 |
protected void | onRefresh() |
protected void | postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) ServletContextAwareProcessor を登録します。 |
protected void | prepareWebApplicationContext(ServletContextEE servletContext) 指定された完全にロードされた ServletContext EE を使用して WebApplicationContext を準備します。 |
void | refresh() |
void | setServerNamespace(StringSE serverNamespace) コンテキストのサーバー名前空間を設定します。 |
void | setServletConfig(ServletConfigEE servletConfig) |
createEnvironment, getApplicationName, getConfigLocations, getNamespace, getResourcePatternResolver, getServletContext, getTheme, initPropertySources, setConfigLocation, setConfigLocations, setNamespace, setServletContext
cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setApplicationStartup, setClassLoader, setParent, setResourceLoader
addApplicationListener, addBeanFactoryPostProcessor, assertBeanFactoryActive, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationStartup, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setDisplayName, setEnvironment, setId, start, stop, toString
addProtocolResolver, clearResourceCaches, getProtocolResolvers, getResourceCache
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
addApplicationListener, addBeanFactoryPostProcessor, addProtocolResolver, close, getApplicationStartup, getBeanFactory, getEnvironment, isActive, registerShutdownHook, setApplicationStartup, setClassLoader, setEnvironment, setId, setParent
getServerNamespace, hasServerNamespace
getApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate
containsBeanDefinition, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation
containsLocalBean, getParentBeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch
getMessage, getMessage, getMessage
publishEvent, publishEvent
getResources
getClassLoader, getResource
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames
getAliases
public static final StringSE DISPATCHER_SERVLET_NAME
ServletRegistrationBean
または別の Bean 名を使用できます。public ServletWebServerApplicationContext()
ServletWebServerApplicationContext
を作成します。public ServletWebServerApplicationContext(DefaultListableBeanFactory beanFactory)
DefaultListableBeanFactory
で新しい ServletWebServerApplicationContext
を作成します。beanFactory
- このコンテキストに使用する DefaultListableBeanFactory インスタンス protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
GenericWebApplicationContext
の postProcessBeanFactory
ServletContextAwareProcessor
public final void refresh() throws BeansException, IllegalStateExceptionSE
ConfigurableApplicationContext
の refresh
AbstractApplicationContext
の refresh
BeansException
IllegalStateExceptionSE
protected void onRefresh()
GenericWebApplicationContext
の onRefresh
protected void doClose()
AbstractApplicationContext
の doClose
protected ServletWebServerFactory getWebServerFactory()
WebServer
の作成に使用する必要がある ServletWebServerFactory
を返します。デフォルトでは、このメソッドはコンテキスト自体で適切な Bean を検索します。ServletWebServerFactory
(非 null
)protected CollectionSE<ServletContextInitializer> getServletContextInitializerBeans()
ServletContextInitializer
を返します。デフォルトでは、このメソッドは最初に ServletContextInitializer
、Servlet
EE、Filter
EE および特定の EventListener
SE Bean を見つけようとします。protected void prepareWebApplicationContext(ServletContextEE servletContext)
ServletContext
EE を使用して WebApplicationContext
を準備します。このメソッドは通常 ServletContextInitializer.onStartup(ServletContext)
から呼び出され、通常 ContextLoaderListener
によって提供される機能に似ています。servletContext
- 運用サーブレットコンテキスト protected Resource getResourceByPath(StringSE path)
GenericWebApplicationContext
の getResourceByPath
public StringSE getServerNamespace()
WebServerApplicationContext
null
を返します。同じアプリケーションで複数の Web サーバーが実行されている場合の明確化に使用されます(たとえば、異なるポートで実行されている管理コンテキスト)。WebServerApplicationContext
の getServerNamespace
public void setServerNamespace(StringSE serverNamespace)
ConfigurableWebServerApplicationContext
ConfigurableWebServerApplicationContext
の setServerNamespace
serverNamespace
- サーバーの名前空間 WebServerApplicationContext.getServerNamespace()
public void setServletConfig(ServletConfigEE servletConfig)
ConfigurableWebApplicationContext
の setServletConfig
GenericWebApplicationContext
の setServletConfig
public ServletConfigEE getServletConfig()
ConfigurableWebApplicationContext
の getServletConfig
GenericWebApplicationContext
の getServletConfig
public WebServer getWebServer()
WebServer
を返します。サーバーがまだ作成されていない場合は null
を返します。WebServerApplicationContext
の getWebServer