Polishing

This commit is contained in:
Juergen Hoeller
2018-08-11 01:30:32 +02:00
parent 951b39cc7a
commit 67d0c69a95
2 changed files with 53 additions and 36 deletions

View File

@@ -56,7 +56,7 @@ import org.springframework.web.servlet.HandlerMapping;
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 3.1
* @param <T> The mapping for a {@link HandlerMethod} containing the conditions
* @param <T> the mapping for a {@link HandlerMethod} containing the conditions
* needed to match the handler method to incoming request.
*/
public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean {
@@ -182,6 +182,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/**
* Detects handler methods at initialization.
* @see #initHandlerMethods
*/
@Override
public void afterPropertiesSet() {
@@ -190,9 +191,9 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/**
* Scan beans in the ApplicationContext, detect and register handler methods.
* @see #isHandler(Class)
* @see #getMappingForMethod(Method, Class)
* @see #handlerMethodsInitialized(Map)
* @see #isHandler
* @see #detectHandlerMethods
* @see #handlerMethodsInitialized
*/
protected void initHandlerMethods() {
if (logger.isDebugEnabled()) {
@@ -223,15 +224,16 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
}
/**
* Look for handler methods in a handler.
* @param handler the bean name of a handler or a handler instance
* Look for handler methods in the specified handler bean.
* @param handler either a bean name or an actual handler instance
* @see #getMappingForMethod
*/
protected void detectHandlerMethods(final Object handler) {
protected void detectHandlerMethods(Object handler) {
Class<?> handlerType = (handler instanceof String ?
obtainApplicationContext().getType((String) handler) : handler.getClass());
if (handlerType != null) {
final Class<?> userType = ClassUtils.getUserClass(handlerType);
Class<?> userType = ClassUtils.getUserClass(handlerType);
Map<Method, T> methods = MethodIntrospector.selectMethods(userType,
(MethodIntrospector.MetadataLookup<T>) method -> {
try {
@@ -474,7 +476,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/**
* A registry that maintains all mappings to handler methods, exposing methods
* to perform lookups and providing concurrent access.
*
* <p>Package-private for testing purposes.
*/
class MappingRegistry {
@@ -542,11 +543,11 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
try {
HandlerMethod handlerMethod = createHandlerMethod(handler, method);
assertUniqueMethodMapping(handlerMethod, mapping);
this.mappingLookup.put(mapping, handlerMethod);
if (logger.isInfoEnabled()) {
logger.info("Mapped \"" + mapping + "\" onto " + handlerMethod);
}
this.mappingLookup.put(mapping, handlerMethod);
List<String> directUrls = getDirectUrls(mapping);
for (String url : directUrls) {
@@ -754,6 +755,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
private static class EmptyHandler {
@SuppressWarnings("unused")
public void handle() {
throw new UnsupportedOperationException("Not implemented");
}