class AnnotationDrivenBeanDefinitionParser extends java.lang.Object implements BeanDefinitionParser
BeanDefinitionParser
that provides the configuration for the
<annotation-driven/>
MVC namespace element.
This class registers the following HandlerMappings
:
RequestMappingHandlerMapping
ordered at 0 for mapping requests to annotated controller methods.
BeanNameUrlHandlerMapping
ordered at 2 to map URL paths to controller bean names.
Note: Additional HandlerMappings may be registered
as a result of using the <view-controller>
or the
<resources>
MVC namespace elements.
This class registers the following HandlerAdapters
:
RequestMappingHandlerAdapter
for processing requests with annotated controller methods.
HttpRequestHandlerAdapter
for processing requests with HttpRequestHandlers
.
SimpleControllerHandlerAdapter
for processing requests with interface-based Controllers
.
This class registers the following HandlerExceptionResolvers
:
ExceptionHandlerExceptionResolver
for handling exceptions through
ExceptionHandler
methods.
ResponseStatusExceptionResolver
for exceptions annotated
with ResponseStatus
.
DefaultHandlerExceptionResolver
for resolving known Spring
exception types
This class registers an AntPathMatcher
and a UrlPathHelper
to be used by:
RequestMappingHandlerMapping
,
HandlerMapping
for ViewControllers
HandlerMapping
for serving resources
path-matching
MVC namespace element.
Both the RequestMappingHandlerAdapter
and the
ExceptionHandlerExceptionResolver
are configured with instances of
the following by default:
ContentNegotiationManager
DefaultFormattingConversionService
LocalValidatorFactoryBean
if a JSR-303 implementation is available on the classpath
HttpMessageConverters
depending on which third-party
libraries are available on the classpath.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AnnotationDrivenBeanDefinitionParser.CompositeUriComponentsContributorFactoryBean
A FactoryBean for a CompositeUriComponentsContributor that obtains the
HandlerMethodArgumentResolver's configured in RequestMappingHandlerAdapter
after it is fully initialized.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTENT_NEGOTIATION_MANAGER_BEAN_NAME |
private static boolean |
gsonPresent |
static java.lang.String |
HANDLER_ADAPTER_BEAN_NAME |
static java.lang.String |
HANDLER_MAPPING_BEAN_NAME |
private static boolean |
jackson2CborPresent |
private static boolean |
jackson2Present |
private static boolean |
jackson2SmilePresent |
private static boolean |
jackson2XmlPresent |
private static boolean |
javaxValidationPresent |
private static boolean |
jaxb2Present |
private static boolean |
romePresent |
Constructor and Description |
---|
AnnotationDrivenBeanDefinitionParser() |
Modifier and Type | Method and Description |
---|---|
protected void |
addRequestBodyAdvice(RootBeanDefinition beanDef) |
protected void |
addResponseBodyAdvice(RootBeanDefinition beanDef) |
private void |
configurePathMatchingProperties(RootBeanDefinition handlerMappingDef,
org.w3c.dom.Element element,
ParserContext context) |
private RootBeanDefinition |
createConverterDefinition(java.lang.Class<?> converterClass,
java.lang.Object source) |
private GenericBeanDefinition |
createObjectMapperFactoryDefinition(java.lang.Object source) |
private ManagedList<java.lang.Object> |
extractBeanSubElements(org.w3c.dom.Element parentElement,
ParserContext context) |
private ManagedList<?> |
getArgumentResolvers(org.w3c.dom.Element element,
ParserContext context) |
private RuntimeBeanReference |
getAsyncExecutor(org.w3c.dom.Element element) |
private java.lang.String |
getAsyncTimeout(org.w3c.dom.Element element) |
private ManagedList<?> |
getCallableInterceptors(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
private RuntimeBeanReference |
getContentNegotiationManager(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
private RuntimeBeanReference |
getConversionService(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
private java.util.Properties |
getDefaultMediaTypes() |
private ManagedList<?> |
getDeferredResultInterceptors(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
private RuntimeBeanReference |
getMessageCodesResolver(org.w3c.dom.Element element) |
private ManagedList<?> |
getMessageConverters(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
private ManagedList<?> |
getReturnValueHandlers(org.w3c.dom.Element element,
ParserContext context) |
private RuntimeBeanReference |
getValidator(org.w3c.dom.Element element,
java.lang.Object source,
ParserContext context) |
BeanDefinition |
parse(org.w3c.dom.Element element,
ParserContext context)
Parse the specified
Element and register the resulting
BeanDefinition(s) with the
BeanDefinitionRegistry
embedded in the supplied ParserContext . |
private ManagedList<java.lang.Object> |
wrapLegacyResolvers(java.util.List<java.lang.Object> list,
ParserContext context) |
public static final java.lang.String HANDLER_MAPPING_BEAN_NAME
public static final java.lang.String HANDLER_ADAPTER_BEAN_NAME
public static final java.lang.String CONTENT_NEGOTIATION_MANAGER_BEAN_NAME
private static final boolean javaxValidationPresent
private static boolean romePresent
private static final boolean jaxb2Present
private static final boolean jackson2Present
private static final boolean jackson2XmlPresent
private static final boolean jackson2SmilePresent
private static final boolean jackson2CborPresent
private static final boolean gsonPresent
@Nullable public BeanDefinition parse(org.w3c.dom.Element element, ParserContext context)
BeanDefinitionParser
Element
and register the resulting
BeanDefinition(s)
with the
BeanDefinitionRegistry
embedded in the supplied ParserContext
.
Implementations must return the primary BeanDefinition
that results
from the parse if they will ever be used in a nested fashion (for example as
an inner tag in a <property/>
tag). Implementations may return
null
if they will not be used in a nested fashion.
parse
in interface BeanDefinitionParser
element
- the element that is to be parsed into one or more BeanDefinitions
context
- the object encapsulating the current state of the parsing process;
provides access to a BeanDefinitionRegistry
BeanDefinition
protected void addRequestBodyAdvice(RootBeanDefinition beanDef)
protected void addResponseBodyAdvice(RootBeanDefinition beanDef)
private RuntimeBeanReference getConversionService(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
@Nullable private RuntimeBeanReference getValidator(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
private RuntimeBeanReference getContentNegotiationManager(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
private void configurePathMatchingProperties(RootBeanDefinition handlerMappingDef, org.w3c.dom.Element element, ParserContext context)
private java.util.Properties getDefaultMediaTypes()
@Nullable private RuntimeBeanReference getMessageCodesResolver(org.w3c.dom.Element element)
@Nullable private java.lang.String getAsyncTimeout(org.w3c.dom.Element element)
@Nullable private RuntimeBeanReference getAsyncExecutor(org.w3c.dom.Element element)
private ManagedList<?> getCallableInterceptors(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
private ManagedList<?> getDeferredResultInterceptors(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
@Nullable private ManagedList<?> getArgumentResolvers(org.w3c.dom.Element element, ParserContext context)
private ManagedList<java.lang.Object> wrapLegacyResolvers(java.util.List<java.lang.Object> list, ParserContext context)
@Nullable private ManagedList<?> getReturnValueHandlers(org.w3c.dom.Element element, ParserContext context)
private ManagedList<?> getMessageConverters(org.w3c.dom.Element element, @Nullable java.lang.Object source, ParserContext context)
private GenericBeanDefinition createObjectMapperFactoryDefinition(@Nullable java.lang.Object source)
private RootBeanDefinition createConverterDefinition(java.lang.Class<?> converterClass, @Nullable java.lang.Object source)
private ManagedList<java.lang.Object> extractBeanSubElements(org.w3c.dom.Element parentElement, ParserContext context)