类 DispatcherHandler
- java.lang.Object
- org.springframework.web.reactive.DispatcherHandler
- 所有已实现的接口:
Aware
,ApplicationContextAware
,WebHandler
public class DispatcherHandler extends Object implements WebHandler, ApplicationContextAware
Central dispatcher for HTTP request handlers/controllers. Dispatches to registered handlers for processing a request, providing convenient mapping facilities.DispatcherHandler
discovers the delegate components it needs from Spring configuration. It detects the following in the application context:HandlerMapping
-- map requests to handler objectsHandlerAdapter
-- for using any handler interfaceHandlerResultHandler
-- process handler return values
DispatcherHandler
is also designed to be a Spring bean itself and implementsApplicationContextAware
for access to the context it runs in. IfDispatcherHandler
is declared with the bean name "webHandler" it is discovered byWebHttpHandlerBuilder.applicationContext
which creates a processing chain together withWebFilter
,WebExceptionHandler
and others.A
DispatcherHandler
bean declaration is included in@EnableWebFlux
configuration.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller
- 另请参阅:
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
构造器概要
构造器 构造器 说明 DispatcherHandler()
Create a newDispatcherHandler
which needs to be configured with anApplicationContext
throughsetApplicationContext(org.springframework.context.ApplicationContext)
.DispatcherHandler(ApplicationContext applicationContext)
Create a newDispatcherHandler
for the givenApplicationContext
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<HandlerMapping>
getHandlerMappings()
reactor.core.publisher.Mono<Void>
handle(ServerWebExchange exchange)
Handle the web server exchange.protected void
initStrategies(ApplicationContext context)
void
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
构造器详细资料
DispatcherHandler
public DispatcherHandler()
Create a newDispatcherHandler
which needs to be configured with anApplicationContext
throughsetApplicationContext(org.springframework.context.ApplicationContext)
.
DispatcherHandler
public DispatcherHandler(ApplicationContext applicationContext)
Create a newDispatcherHandler
for the givenApplicationContext
.- 参数:
applicationContext
- the application context to find the handler beans in
方法详细资料
getHandlerMappings
@Nullable public final List<HandlerMapping> getHandlerMappings()
Return allHandlerMapping
beans detected by type in theinjected context
and alsosorted
.Note: This method may return
null
if invoked prior tosetApplicationContext(ApplicationContext)
.- 返回:
- immutable list with the configured mappings or
null
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAware
Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 指定者:
setApplicationContext
在接口中ApplicationContextAware
- 参数:
applicationContext
- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
initStrategies
protected void initStrategies(ApplicationContext context)
handle
public reactor.core.publisher.Mono<Void> handle(ServerWebExchange exchange)
从接口复制的说明:WebHandler
Handle the web server exchange.- 指定者:
handle
在接口中WebHandler
- 参数:
exchange
- the current server exchange- 返回:
Mono<Void>
to indicate when request handling is complete