Java Code Examples for org.springframework.web.bind.annotation.RequestMapping#path()
The following examples show how to use
org.springframework.web.bind.annotation.RequestMapping#path() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MvcUriComponentsBuilder.java From spring-analysis-note with MIT License | 5 votes |
private static String getClassMapping(Class<?> controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping mapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (mapping == null) { return "/"; } String[] paths = mapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + controllerType.getName()); } return paths[0]; }
Example 2
Source File: MvcUriComponentsBuilder.java From spring-analysis-note with MIT License | 5 votes |
private static String getMethodMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + method.toGenericString()); } return paths[0]; }
Example 3
Source File: MvcUriComponentsBuilder.java From java-technology-stack with MIT License | 5 votes |
private static String getClassMapping(Class<?> controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping mapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (mapping == null) { return "/"; } String[] paths = mapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + controllerType.getName()); } return paths[0]; }
Example 4
Source File: MvcUriComponentsBuilder.java From java-technology-stack with MIT License | 5 votes |
private static String getMethodMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + method.toGenericString()); } return paths[0]; }
Example 5
Source File: MvcUriComponentsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
private static String getTypeRequestMapping(Class<?> controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (requestMapping == null) { return "/"; } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on controller " + controllerType.getName() + ", using first one"); } return paths[0]; }
Example 6
Source File: MvcUriComponentsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
private static String getMethodRequestMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on method " + method.toGenericString() + ", using first one"); } return paths[0]; }
Example 7
Source File: ApiListingJsonScanner.java From Resource with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting String[] paths(Class<?> controller) { RequestMapping annotation = AnnotationUtils.findAnnotation(controller, RequestMapping.class); if (annotation != null) { return annotation.path(); } return new String[] {}; }
Example 8
Source File: MvcUriComponentsBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static String getTypeRequestMapping(Class<?> controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (requestMapping == null) { return "/"; } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on controller " + controllerType.getName() + ", using first one"); } return paths[0]; }
Example 9
Source File: MvcUriComponentsBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static String getMethodRequestMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on method " + method.toGenericString() + ", using first one"); } return paths[0]; }
Example 10
Source File: SpringletsMvcUriComponentsBuilder.java From springlets with Apache License 2.0 | 5 votes |
private static String getTypeRequestMapping(Class<?> controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (requestMapping == null) { return "/"; } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on controller {}, using first one", controllerType.getName()); } return paths[0]; }
Example 11
Source File: SpringletsMvcUriComponentsBuilder.java From springlets with Apache License 2.0 | 5 votes |
private static String getMethodRequestMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isWarnEnabled()) { logger.warn("Multiple paths on method {}, using first one", method.toGenericString()); } return paths[0]; }
Example 12
Source File: ControllerConstructorInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { String basePath = ""; RequestMapping basePathRequestMapping = objInst.getClass().getAnnotation(RequestMapping.class); if (basePathRequestMapping != null) { if (basePathRequestMapping.value().length > 0) { basePath = basePathRequestMapping.value()[0]; } else if (basePathRequestMapping.path().length > 0) { basePath = basePathRequestMapping.path()[0]; } } EnhanceRequireObjectCache enhanceRequireObjectCache = new EnhanceRequireObjectCache(); enhanceRequireObjectCache.setPathMappingCache(new PathMappingCache(basePath)); objInst.setSkyWalkingDynamicField(enhanceRequireObjectCache); }
Example 13
Source File: ControllerConstructorInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { String basePath = ""; RequestMapping basePathRequestMapping = objInst.getClass().getAnnotation(RequestMapping.class); if (basePathRequestMapping != null) { if (basePathRequestMapping.value().length > 0) { basePath = basePathRequestMapping.value()[0]; } else if (basePathRequestMapping.path().length > 0) { basePath = basePathRequestMapping.path()[0]; } } EnhanceRequireObjectCache enhanceRequireObjectCache = new EnhanceRequireObjectCache(); enhanceRequireObjectCache.setPathMappingCache(new PathMappingCache(basePath)); objInst.setSkyWalkingDynamicField(enhanceRequireObjectCache); }
Example 14
Source File: SpringApplicationParser.java From typescript-generator with MIT License | 4 votes |
@Override public JaxrsApplicationParser.Result tryParse(SourceType<?> sourceType) { if (!(sourceType.type instanceof Class<?>)) { return null; } final Class<?> cls = (Class<?>) sourceType.type; // application final SpringBootApplication app = AnnotationUtils.findAnnotation(cls, SpringBootApplication.class); if (app != null) { if (settings.scanSpringApplication) { TypeScriptGenerator.getLogger().verbose("Scanning Spring application: " + cls.getName()); final ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(settings.classLoader); final SpringApplicationHelper springApplicationHelper = new SpringApplicationHelper(settings.classLoader, cls); final List<Class<?>> restControllers = springApplicationHelper.findRestControllers(); return new JaxrsApplicationParser.Result(restControllers.stream() .map(controller -> new SourceType<Type>(controller, cls, "<scanned>")) .collect(Collectors.toList()) ); } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } } else { return null; } } // controller final Component component = AnnotationUtils.findAnnotation(cls, Component.class); if (component != null) { TypeScriptGenerator.getLogger().verbose("Parsing Spring component: " + cls.getName()); final JaxrsApplicationParser.Result result = new JaxrsApplicationParser.Result(); final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(cls, RequestMapping.class); final String path = requestMapping != null && requestMapping.path() != null && requestMapping.path().length != 0 ? requestMapping.path()[0] : null; final JaxrsApplicationParser.ResourceContext context = new JaxrsApplicationParser.ResourceContext(cls, path); parseController(result, context, cls); return result; } return null; }