/** * Any partial matches for "methods"? */ public boolean hasMethodsMismatch() { for (PartialMatch match : this.partialMatches) { if (match.hasMethodsMatch()) { return false; } } return true; }
/** * Provide a Comparator to sort RequestMappingInfos matched to a request. */ @Override protected Comparator<RequestMappingInfo> getMappingComparator(final HttpServletRequest request) { return (info1, info2) -> info1.compareTo(info2, request); }
/** * This implementation expects the handler to be an {@link HandlerMethod}. * @param handler the handler instance to check * @return whether or not this adapter can adapt the given handler */ @Override public final boolean supports(Object handler) { return (handler instanceof HandlerMethod && supportsInternal((HandlerMethod) handler)); }
@Override public void afterPropertiesSet() { this.config = new RequestMappingInfo.BuilderConfiguration(); this.config.setUrlPathHelper(getUrlPathHelper()); this.config.setPathMatcher(getPathMatcher()); this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); this.config.setContentNegotiationManager(getContentNegotiationManager()); super.afterPropertiesSet(); }
private void handleMatch(MockHttpServletRequest request, String pattern, String lookupPath) { RequestMappingInfo info = RequestMappingInfo.paths(pattern).build(); this.handlerMapping.handleMatch(info, lookupPath, request); }
protected RequestMappingInfoHandlerMapping() { setHandlerMethodMappingNamingStrategy(new RequestMappingInfoHandlerMethodMappingNamingStrategy()); }
@Override public String toString() { return this.info.toString(); } }
/** * Check if the given RequestMappingInfo matches the current request and * return a (potentially new) instance with conditions that match the * current request -- for example with a subset of URL patterns. * @return an info in case of a match; or {@code null} otherwise. */ @Override protected RequestMappingInfo getMatchingMapping(RequestMappingInfo info, HttpServletRequest request) { return info.getMatchingCondition(request); }
/** * Any partial matches for "methods" and "consumes"? */ public boolean hasConsumesMismatch() { for (PartialMatch match : this.partialMatches) { if (match.hasConsumesMatch()) { return false; } } return true; }
/** * Any partial matches for "methods", "consumes", and "produces"? */ public boolean hasProducesMismatch() { for (PartialMatch match : this.partialMatches) { if (match.hasProducesMatch()) { return false; } } return true; }
/** * This implementation expects the handler to be an {@link HandlerMethod}. */ @Override public final long getLastModified(HttpServletRequest request, Object handler) { return getLastModifiedInternal(request, (HandlerMethod) handler); }
/** * Any partial matches for "methods", "consumes", "produces", and "params"? */ public boolean hasParamsMismatch() { for (PartialMatch match : this.partialMatches) { if (match.hasParamsMatch()) { return false; } } return true; }
/** * Create a new {@code RequestMappingInfo.Builder} with the given paths. * @param paths the paths to use * @since 4.2 */ public static Builder paths(String... paths) { return new DefaultBuilder(paths); }
@Test(expected = HttpMediaTypeNotAcceptableException.class) // SPR-9603 public void getHandlerRequestMethodMatchFalsePositive() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/users"); request.addHeader("Accept", "application/xml"); this.handlerMapping.registerHandler(new UserController()); this.handlerMapping.getHandler(request); }
public void registerHandler(Object handler) { super.detectHandlerMethods(handler); }
@Test public void handleMatchBestMatchingPatternAttributeNoPatternsDefined() { RequestMappingInfo key = RequestMappingInfo.paths().build(); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/1/2"); this.handlerMapping.handleMatch(key, "/1/2", request); assertEquals("/1/2", request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)); }
public boolean hasConsumesMatch() { return (hasMethodsMatch() && this.consumesMatch); }
public boolean hasProducesMatch() { return (hasConsumesMatch() && this.producesMatch); }
public boolean hasParamsMatch() { return (hasProducesMatch() && this.paramsMatch); }
@Test public void handleMatchBestMatchingPatternAttribute() { RequestMappingInfo key = RequestMappingInfo.paths("/{path1}/2", "/**").build(); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/1/2"); this.handlerMapping.handleMatch(key, "/1/2", request); assertEquals("/{path1}/2", request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)); }