Browse Source

Polishing

pull/23119/head
Juergen Hoeller 6 years ago
parent
commit
707c720441
  1. 24
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java
  2. 13
      spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java

24
spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java

@ -165,8 +165,8 @@ public abstract class AbstractMethodMessageHandler<T> @@ -165,8 +165,8 @@ public abstract class AbstractMethodMessageHandler<T>
}
public String getBeanName() {
return this.beanName != null ? this.beanName :
getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this);
return (this.beanName != null ? this.beanName :
getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this));
}
/**
@ -269,7 +269,7 @@ public abstract class AbstractMethodMessageHandler<T> @@ -269,7 +269,7 @@ public abstract class AbstractMethodMessageHandler<T>
* Detect if the given handler has any methods that can handle messages and if
* so register it with the extracted mapping information.
* <p><strong>Note:</strong> This method is protected and can be invoked by
* sub-classes, but this should be done on startup only as documented in
* subclasses, but this should be done on startup only as documented in
* {@link #registerHandlerMethod}.
* @param handler the handler to check, either an instance of a Spring bean name
*/
@ -321,7 +321,7 @@ public abstract class AbstractMethodMessageHandler<T> @@ -321,7 +321,7 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Register a handler method and its unique mapping.
* <p><strong>Note:</strong> This method is protected and can be invoked by
* sub-classes. Keep in mind however that the registration is not protected
* subclasses. Keep in mind however that the registration is not protected
* for concurrent use, and is expected to be done on startup.
* @param handler the bean name of the handler or the handler instance
* @param method the method to register
@ -369,7 +369,7 @@ public abstract class AbstractMethodMessageHandler<T> @@ -369,7 +369,7 @@ public abstract class AbstractMethodMessageHandler<T>
* Return String-based destinations for the given mapping, if any, that can
* be used to find matches with a direct lookup (i.e. non-patterns).
* <p><strong>Note:</strong> This is completely optional. The mapping
* metadata for a sub-class may support neither direct lookups, nor String
* metadata for a subclass may support neither direct lookups, nor String
* based destinations.
*/
protected abstract Set<String> getDirectLookupMappings(T mapping);
@ -395,7 +395,7 @@ public abstract class AbstractMethodMessageHandler<T> @@ -395,7 +395,7 @@ public abstract class AbstractMethodMessageHandler<T>
List<Match<T>> matches = new ArrayList<>();
RouteMatcher.Route destination = getDestination(message);
List<T> mappingsByUrl = destination != null ? this.destinationLookup.get(destination.value()) : null;
List<T> mappingsByUrl = (destination != null ? this.destinationLookup.get(destination.value()) : null);
if (mappingsByUrl != null) {
addMatchesToCollection(mappingsByUrl, message, matches);
}
@ -419,10 +419,9 @@ public abstract class AbstractMethodMessageHandler<T> @@ -419,10 +419,9 @@ public abstract class AbstractMethodMessageHandler<T>
if (comparator.compare(bestMatch, secondBestMatch) == 0) {
HandlerMethod m1 = bestMatch.handlerMethod;
HandlerMethod m2 = secondBestMatch.handlerMethod;
throw new IllegalStateException(
"Ambiguous handler methods mapped for destination '" +
destination.value() + "': {" +
m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}");
throw new IllegalStateException("Ambiguous handler methods mapped for destination '" +
(destination != null ? destination.value() : "") + "': {" +
m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}");
}
}
return bestMatch;
@ -494,13 +493,11 @@ public abstract class AbstractMethodMessageHandler<T> @@ -494,13 +493,11 @@ public abstract class AbstractMethodMessageHandler<T>
private final HandlerMethod handlerMethod;
Match(T mapping, HandlerMethod handlerMethod) {
this.mapping = mapping;
this.handlerMethod = handlerMethod;
}
public T getMapping() {
return this.mapping;
}
@ -509,7 +506,6 @@ public abstract class AbstractMethodMessageHandler<T> @@ -509,7 +506,6 @@ public abstract class AbstractMethodMessageHandler<T>
return this.handlerMethod;
}
@Override
public String toString() {
return this.mapping.toString();
@ -521,12 +517,10 @@ public abstract class AbstractMethodMessageHandler<T> @@ -521,12 +517,10 @@ public abstract class AbstractMethodMessageHandler<T>
private final Comparator<T> comparator;
MatchComparator(Comparator<T> comparator) {
this.comparator = comparator;
}
@Override
public int compare(Match<T> match1, Match<T> match2) {
return this.comparator.compare(match1.mapping, match2.mapping);

13
spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java

@ -40,10 +40,11 @@ import org.springframework.web.servlet.function.ServerRequest; @@ -40,10 +40,11 @@ import org.springframework.web.servlet.function.ServerRequest;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
/**
* {@code HandlerMapping} implementation that supports {@link RouterFunction}s.
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
*
* <p>If no {@link RouterFunction} is provided at
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect
* all router functions in the application context, and consult them in
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
* will detect all router functions in the application context, and consult them in
* {@linkplain org.springframework.core.annotation.Order order}.
*
* @author Arjen Poutsma
@ -62,8 +63,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini @@ -62,8 +63,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
/**
* Create an empty {@code RouterFunctionMapping}.
* <p>If this constructor is used, this mapping will detect all {@link RouterFunction} instances
* available in the application context.
* <p>If this constructor is used, this mapping will detect all
* {@link RouterFunction} instances available in the application context.
*/
public RouterFunctionMapping() {
}
@ -127,7 +128,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini @@ -127,7 +128,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
* Detect a all {@linkplain RouterFunction router functions} in the
* current application context.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
private void initRouterFunction() {
ApplicationContext applicationContext = obtainApplicationContext();
Map<String, RouterFunction> beans =

Loading…
Cancel
Save