类 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.DispatcherHandlerdiscovers 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
DispatcherHandleris also designed to be a Spring bean itself and implementsApplicationContextAwarefor access to the context it runs in. IfDispatcherHandleris declared with the bean name "webHandler" it is discovered byWebHttpHandlerBuilder.applicationContextwhich creates a processing chain together withWebFilter,WebExceptionHandlerand others.A
DispatcherHandlerbean declaration is included in@EnableWebFluxconfiguration.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller
- 另请参阅:
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
构造器概要
构造器 构造器 说明 DispatcherHandler()Create a newDispatcherHandlerwhich needs to be configured with anApplicationContextthroughsetApplicationContext(org.springframework.context.ApplicationContext).DispatcherHandler(ApplicationContext applicationContext)Create a newDispatcherHandlerfor the givenApplicationContext.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<HandlerMapping>getHandlerMappings()reactor.core.publisher.Mono<Void>handle(ServerWebExchange exchange)Handle the web server exchange.protected voidinitStrategies(ApplicationContext context)voidsetApplicationContext(ApplicationContext applicationContext)Set the ApplicationContext that this object runs in.
构造器详细资料
DispatcherHandler
public DispatcherHandler()
Create a newDispatcherHandlerwhich needs to be configured with anApplicationContextthroughsetApplicationContext(org.springframework.context.ApplicationContext).
DispatcherHandler
public DispatcherHandler(ApplicationContext applicationContext)
Create a newDispatcherHandlerfor the givenApplicationContext.- 参数:
applicationContext- the application context to find the handler beans in
方法详细资料
getHandlerMappings
@Nullable public final List<HandlerMapping> getHandlerMappings()
Return allHandlerMappingbeans detected by type in theinjected contextand alsosorted.Note: This method may return
nullif invoked prior tosetApplicationContext(ApplicationContext).- 返回:
- immutable list with the configured mappings or
null
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAwareSet 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)
从接口复制的说明:WebHandlerHandle the web server exchange.- 指定者:
handle在接口中WebHandler- 参数:
exchange- the current server exchange- 返回:
Mono<Void>to indicate when request handling is complete