use of org.springframework.web.servlet.mvc.method.RequestMappingInfo in project pinpoint by naver.
the class ApisController method initApiMappings.
@PostConstruct
private void initApiMappings() {
Map<RequestMappingInfo, HandlerMethod> requestMappedHandlers = this.handlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> requestMappedHandlerEntry : requestMappedHandlers.entrySet()) {
RequestMappingInfo requestMappingInfo = requestMappedHandlerEntry.getKey();
HandlerMethod handlerMethod = requestMappedHandlerEntry.getValue();
Class<?> handlerMethodBeanClazz = handlerMethod.getBeanType();
if (handlerMethodBeanClazz == this.getClass()) {
continue;
}
String controllerName = handlerMethodBeanClazz.getSimpleName();
Set<String> mappedRequests = requestMappingInfo.getPatternsCondition().getPatterns();
SortedSet<RequestMappedUri> alreadyMappedRequests = this.apiMappings.get(controllerName);
if (alreadyMappedRequests == null) {
alreadyMappedRequests = new TreeSet<RequestMappedUri>(RequestMappedUri.MAPPED_URI_ORDER);
this.apiMappings.put(controllerName, alreadyMappedRequests);
}
alreadyMappedRequests.addAll(createRequestMappedApis(handlerMethod, mappedRequests));
}
}
use of org.springframework.web.servlet.mvc.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingHandlerMappingTests method assertComposedAnnotationMapping.
private RequestMappingInfo assertComposedAnnotationMapping(String methodName, String path, RequestMethod requestMethod) throws Exception {
Class<?> clazz = ComposedAnnotationController.class;
Method method = clazz.getMethod(methodName);
RequestMappingInfo info = this.handlerMapping.getMappingForMethod(method, clazz);
assertNotNull(info);
Set<String> paths = info.getPatternsCondition().getPatterns();
assertEquals(1, paths.size());
assertEquals(path, paths.iterator().next());
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
assertEquals(1, methods.size());
assertEquals(requestMethod, methods.iterator().next());
return info;
}
use of org.springframework.web.servlet.mvc.method.RequestMappingInfo in project spring-security-oauth by spring-projects.
the class FrameworkEndpointHandlerMapping method getMappingForMethod.
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo defaultMapping = super.getMappingForMethod(method, handlerType);
if (defaultMapping == null) {
return null;
}
Set<String> defaultPatterns = defaultMapping.getPatternsCondition().getPatterns();
String[] patterns = new String[defaultPatterns.size()];
int i = 0;
for (String pattern : defaultPatterns) {
patterns[i] = getPath(pattern);
paths.add(pattern);
i++;
}
PatternsRequestCondition patternsInfo = new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(), useTrailingSlashMatch(), getFileExtensions());
ParamsRequestCondition paramsInfo = defaultMapping.getParamsCondition();
if (!approvalParameter.equals(OAuth2Utils.USER_OAUTH_APPROVAL) && defaultPatterns.contains("/oauth/authorize")) {
String[] params = new String[paramsInfo.getExpressions().size()];
Set<NameValueExpression<String>> expressions = paramsInfo.getExpressions();
i = 0;
for (NameValueExpression<String> expression : expressions) {
String param = expression.toString();
if (OAuth2Utils.USER_OAUTH_APPROVAL.equals(param)) {
params[i] = approvalParameter;
} else {
params[i] = param;
}
i++;
}
paramsInfo = new ParamsRequestCondition(params);
}
RequestMappingInfo mapping = new RequestMappingInfo(patternsInfo, defaultMapping.getMethodsCondition(), paramsInfo, defaultMapping.getHeadersCondition(), defaultMapping.getConsumesCondition(), defaultMapping.getProducesCondition(), defaultMapping.getCustomCondition());
return mapping;
}
use of org.springframework.web.servlet.mvc.method.RequestMappingInfo in project spring-boot-admin by codecentric.
the class PrefixHandlerMapping method withPrefix.
private RequestMappingInfo withPrefix(RequestMappingInfo mapping) {
List<String> newPatterns = getPatterns(mapping);
PatternsRequestCondition patterns = new PatternsRequestCondition(newPatterns.toArray(new String[newPatterns.size()]));
return new RequestMappingInfo(patterns, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition());
}
use of org.springframework.web.servlet.mvc.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingHandlerMapping method match.
@Override
public RequestMatchResult match(HttpServletRequest request, String pattern) {
RequestMappingInfo info = RequestMappingInfo.paths(pattern).options(this.config).build();
RequestMappingInfo matchingInfo = info.getMatchingCondition(request);
if (matchingInfo == null) {
return null;
}
Set<String> patterns = matchingInfo.getPatternsCondition().getPatterns();
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
return new RequestMatchResult(patterns.iterator().next(), lookupPath, getPathMatcher());
}
Aggregations