List of usage examples for org.springframework.web.method HandlerMethod getBeanType
public Class<?> getBeanType()
From source file:springfox.documentation.spring.web.HandlerMethodReturnTypes.java
public static ResolvedType handlerReturnType(TypeResolver resolver, HandlerMethod handlerMethod) { Class hostClass = useType(handlerMethod.getBeanType()).or(handlerMethod.getMethod().getDeclaringClass()); return new HandlerMethodResolver(resolver).methodReturnType(handlerMethod.getMethod(), hostClass); }
From source file:springfox.documentation.spring.web.ControllerNamingUtils.java
public static String controllerNameAsGroup(HandlerMethod handlerMethod) { Class<?> controllerClass = handlerMethod.getBeanType(); return splitCamelCase(controllerClass.getSimpleName(), "-").replace("/", "").toLowerCase(); }
From source file:springfox.documentation.spring.web.SpringGroupingStrategy.java
@Override public String getResourceDescription(RequestMappingInfo requestMappingInfo, HandlerMethod handlerMethod) { return getDescription(handlerMethod.getBeanType()); }
From source file:springfox.documentation.spring.web.SpringGroupingStrategy.java
private Set<ResourceGroup> groups(HandlerMethod handlerMethod) { Class<?> controllerClazz = handlerMethod.getBeanType(); String controllerAsGroup = splitCamelCase(controllerClazz.getSimpleName(), "-").toLowerCase(); return newHashSet(new ResourceGroup(controllerAsGroup, controllerClazz)); }
From source file:springfox.documentation.swagger.readers.operation.SwaggerOperationTagsReader.java
private Set<String> controllerTags(HandlerMethod handlerMethod) { Class<?> controller = handlerMethod.getBeanType(); Optional<Api> controllerAnnotation = fromNullable(findAnnotation(controller, Api.class)); return controllerAnnotation.transform(tagsFromController()).or(Sets.<String>newHashSet()); }
From source file:io.kahu.hawaii.util.spring.HandlerMethodAdapter.java
@Override public void afterPropertiesSet() throws Exception { Map<String, List<HandlerMethodMappingInfo>> mapping = new HashMap<>(); RequestMappingHandlerMapping handlerMapping = applicationContext .getBean(RequestMappingHandlerMapping.class); for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : handlerMapping.getHandlerMethods().entrySet()) { HandlerMethod handlerMethod = entry.getValue(); String controllerClassName = handlerMethod.getBeanType().getName(); if (!mapping.containsKey(controllerClassName)) { mapping.put(controllerClassName, new ArrayList<HandlerMethodMappingInfo>()); }//from w w w . java 2 s.co m mapping.get(controllerClassName).add(new HandlerMethodMappingInfo(entry.getKey(), entry.getValue())); } this.mapping = mapping; }
From source file:com.microsoft.applicationinsights.web.spring.RequestNameHandlerInterceptorAdapter.java
private String generateRequestName(HttpServletRequest request, Object handler) { // Some handlers, such as built-in ResourceHttpRequestHandler are not of type HandlerMethod. if (!(handler instanceof HandlerMethod)) { return null; }/* w ww . j a va 2 s . c om*/ HandlerMethod handlerMethod = (HandlerMethod) handler; String controller = handlerMethod.getBeanType().getSimpleName(); String action = handlerMethod.getMethod().getName(); String method = request.getMethod(); return String.format("%s %s/%s", method, controller, action); }
From source file:fi.helsinki.opintoni.security.authorization.portfolio.PublicVisibilityResolver.java
public Optional<PublicVisibility> resolve(Object handler) { HandlerMethod handlerMethod = (HandlerMethod) handler; try {// ww w . j av a2 s . c om return Optional.ofNullable( findAnnotation(Class.forName(handlerMethod.getBeanType().getName()), PublicVisibility.class)); } catch (ClassNotFoundException e) { return Optional.empty(); } }
From source file:de.otto.mongodb.profiler.web.CacheInterceptor.java
protected boolean noCache(HandlerMethod handler) { return handler.getMethodAnnotation(NoCache.class) != null || AnnotationUtils.findAnnotation(handler.getBeanType(), NoCache.class) != null; }
From source file:com.zuoxiaolong.blog.common.web.CommonHandlerExceptionResolver.java
private void logException(Object handler, Exception exception, Map<String, String[]> parameterMap) { if (handler != null && HandlerMethod.class.isAssignableFrom(handler.getClass())) { try {//from www.ja v a2 s .c o m HandlerMethod handlerMethod = (HandlerMethod) handler; Class<?> beanType = handlerMethod.getBeanType(); String methodName = handlerMethod.getMethod().getName(); RequestMapping controllerRequestMapping = beanType.getDeclaredAnnotation(RequestMapping.class); String classMapping = ""; if (controllerRequestMapping != null) { classMapping = controllerRequestMapping.value()[0]; } RequestMapping methodRequestMapping = handlerMethod.getMethodAnnotation(RequestMapping.class); String methodMapping = ""; if (methodRequestMapping != null) { methodMapping = methodRequestMapping.value()[0]; } if (!methodMapping.startsWith("/")) { methodMapping = "/" + methodMapping; } Logger logger = LoggerFactory.getLogger(beanType); logger.error("RequestMapping is:"); logger.error(classMapping + methodMapping); logger.error("HandlerMethod is:"); logger.error(beanType.getSimpleName() + "." + methodName + "()"); logger.error("ParameterMap is:"); logger.error(JsonUtils.toJson(parameterMap), exception); } catch (Exception e) { LOGGER.error(handler + " execute failed.", exception); } } else { LOGGER.error(handler + " execute failed.", exception); } }