|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.lang.reflect.Method;
|
20 | 20 | import java.util.ArrayList;
|
| 21 | +import java.util.Arrays; |
21 | 22 | import java.util.Collection;
|
22 | 23 | import java.util.Collections;
|
23 | 24 | import java.util.Comparator;
|
|
26 | 27 | import java.util.Map;
|
27 | 28 | import java.util.Set;
|
28 | 29 | import java.util.concurrent.ConcurrentHashMap;
|
| 30 | +import java.util.function.Function; |
| 31 | +import java.util.stream.Collectors; |
29 | 32 |
|
30 | 33 | import org.apache.commons.logging.Log;
|
31 | 34 | import org.apache.commons.logging.LogFactory;
|
@@ -309,12 +312,27 @@ protected final void detectHandlerMethods(final Object handler) {
|
309 | 312 | Map<Method, T> methods = MethodIntrospector.selectMethods(userType,
|
310 | 313 | (MethodIntrospector.MetadataLookup<T>) method -> getMappingForMethod(method, userType));
|
311 | 314 | if (logger.isDebugEnabled()) {
|
312 |
| - logger.debug(methods.size() + " message handler methods found on " + userType + ": " + methods); |
| 315 | + logger.debug(formatMappings(userType, methods)); |
313 | 316 | }
|
314 | 317 | methods.forEach((key, value) -> registerHandlerMethod(handler, key, value));
|
315 | 318 | }
|
316 | 319 | }
|
317 | 320 |
|
| 321 | + private String formatMappings(Class<?> userType, Map<Method, T> methods) { |
| 322 | + String formattedType = Arrays.stream(ClassUtils.getPackageName(userType).split("\\.")) |
| 323 | + .map(p -> p.substring(0, 1)) |
| 324 | + .collect(Collectors.joining(".", "", "." + userType.getSimpleName())); |
| 325 | + Function<Method, String> methodFormatter = method -> Arrays.stream(method.getParameterTypes()) |
| 326 | + .map(Class::getSimpleName) |
| 327 | + .collect(Collectors.joining(",", "(", ")")); |
| 328 | + return methods.entrySet().stream() |
| 329 | + .map(e -> { |
| 330 | + Method method = e.getKey(); |
| 331 | + return e.getValue() + ": " + method.getName() + methodFormatter.apply(method); |
| 332 | + }) |
| 333 | + .collect(Collectors.joining("\n\t", "\n\t" + formattedType + ":" + "\n\t", "")); |
| 334 | + } |
| 335 | + |
318 | 336 | /**
|
319 | 337 | * Provide the mapping for a handler method.
|
320 | 338 | * @param method the method to provide a mapping for
|
@@ -344,9 +362,6 @@ protected void registerHandlerMethod(Object handler, Method method, T mapping) {
|
344 | 362 | }
|
345 | 363 |
|
346 | 364 | this.handlerMethods.put(mapping, newHandlerMethod);
|
347 |
| - if (logger.isTraceEnabled()) { |
348 |
| - logger.trace("Mapped \"" + mapping + "\" onto " + newHandlerMethod); |
349 |
| - } |
350 | 365 |
|
351 | 366 | for (String pattern : getDirectLookupDestinations(mapping)) {
|
352 | 367 | this.destinationLookup.add(pattern, mapping);
|
|
0 commit comments