当前位置: 首页>>代码示例>>Java>>正文


Java RequestMappingInfo类代码示例

本文整理汇总了Java中org.springframework.web.servlet.mvc.method.RequestMappingInfo的典型用法代码示例。如果您正苦于以下问题:Java RequestMappingInfo类的具体用法?Java RequestMappingInfo怎么用?Java RequestMappingInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestMappingInfo类属于org.springframework.web.servlet.mvc.method包,在下文中一共展示了RequestMappingInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onApplicationEvent

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Override
public void onApplicationEvent ( ContextRefreshedEvent event ) {
	final RequestMappingHandlerMapping requestMappingHandlerMapping =
		applicationContext.getBean( RequestMappingHandlerMapping.class );
	final Map< RequestMappingInfo, HandlerMethod > handlerMethods =
		requestMappingHandlerMapping.getHandlerMethods();

	this.handlerMethods = handlerMethods;

	handlerMethods.keySet().forEach( mappingInfo -> {
		Map< Set< String >, Set< RequestMethod > > mapping = Collections.singletonMap(
			mappingInfo.getPatternsCondition().getPatterns() ,
			this.getMethods( mappingInfo.getMethodsCondition().getMethods() )
		);
		requestMappingInfos.add( mapping );
	} );

	requestMappingUris.addAll(
		handlerMethods.keySet()
					  .parallelStream()
					  .map( mappingInfo -> mappingInfo.getPatternsCondition().getPatterns() )
					  .collect( Collectors.toList() )
	);

}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:26,代码来源:BasicBeanConfig.java

示例2: of

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
public static List<OriginalRequestMappingInfo> of(RequestMappingHandlerMapping handlerMapping) {
    List<OriginalRequestMappingInfo> result = new ArrayList<OriginalRequestMappingInfo>();

    for (Entry<RequestMappingInfo, HandlerMethod> entry : handlerMapping.getHandlerMethods().entrySet()) {
        RequestMappingInfo requestMappingInfo = entry.getKey();

        OriginalRequestMappingInfo o = new OriginalRequestMappingInfo();
        o.setSite(Site.of(requestMappingInfo.getPatternsCondition().getPatterns().iterator().next()));
        o.setMethods(requestMappingInfo.getMethodsCondition().getMethods());
        o.setPatterns(requestMappingInfo.getPatternsCondition().getPatterns());

        Set<String> params = new HashSet<>();
        for (NameValueExpression<String> nameValueExpression : requestMappingInfo.getParamsCondition().getExpressions()) {
            params.add(nameValueExpression.toString());
        }
        o.setParams(params);

        result.add(o);
    }

    return result.stream().sorted().collect(Collectors.toList());
}
 
开发者ID:sinsengumi,项目名称:spring-boot-application-infrastructure,代码行数:23,代码来源:RouterController.java

示例3: createRequestMappingInfo

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
/**
 * Create a {@link RequestMappingInfo} from the supplied
 * {@link RequestMapping @RequestMapping} annotation, which is either
 * a directly declared annotation, a meta-annotation, or the synthesized
 * result of merging annotation attributes within an annotation hierarchy.
 */
protected RequestMappingInfo createRequestMappingInfo(
		RequestMapping requestMapping, RequestCondition<?> customCondition) {

	return RequestMappingInfo
			.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
			.methods(requestMapping.method())
			.params(requestMapping.params())
			.headers(requestMapping.headers())
			.consumes(requestMapping.consumes())
			.produces(requestMapping.produces())
			.mappingName(requestMapping.name())
			.customCondition(customCondition)
			.options(this.config)
			.build();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:RequestMappingHandlerMapping.java

示例4: getMappingForMethod

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
				new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
				new RequestMethodsRequestCondition(annotation.method()),
				new ParamsRequestCondition(annotation.params()),
				new HeadersRequestCondition(annotation.headers()),
				new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
				new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:CrossOriginTests.java

示例5: useRegisteredSuffixPatternMatchInitialization

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Test
public void useRegisteredSuffixPatternMatchInitialization() {
	Map<String, MediaType> fileExtensions = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
	PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions);
	ContentNegotiationManager manager = new ContentNegotiationManager(strategy);

	final Set<String> extensions = new HashSet<String>();

	RequestMappingHandlerMapping hm = new RequestMappingHandlerMapping() {
		@Override
		protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
			extensions.addAll(getFileExtensions());
			return super.getMappingForMethod(method, handlerType);
		}
	};

	wac.registerSingleton("testController", ComposedAnnotationController.class);
	wac.refresh();

	hm.setContentNegotiationManager(manager);
	hm.setUseRegisteredSuffixPatternMatch(true);
	hm.setApplicationContext(wac);
	hm.afterPropertiesSet();

	assertEquals(Collections.singleton("json"), extensions);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:RequestMappingHandlerMappingTests.java

示例6: createRequestMappingInfo

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation,
		RequestCondition<?> customCondition,Object handler) {
	//XXX: not used  RequestMapping
	if(annotation == null){
		return createRequestMappingInfo(customCondition, handler);
	}
	String[] value = annotation.value();
	String[] patterns = resolveEmbeddedValuesInPatterns(value);
	
	//XXX:thining 
	//XXX:增加 RequestMapping value is null 时 默认使用方法名称(包括驼峰式和小写式)
	if(patterns == null ||(patterns != null && patterns.length == 0)){
		
		patterns = getPathMaping(handler);
	}
	
	return new RequestMappingInfo(
			new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(),
					this.useSuffixPatternMatch(), this.useTrailingSlashMatch(), this.getFileExtensions()),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers(), this.getContentNegotiationManager()),
			customCondition);
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:27,代码来源:ClassMethodNameHandlerMapping.java

示例7: loadMappedRequestFromRequestMappingInfoSet

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
private void loadMappedRequestFromRequestMappingInfoSet(Set<RequestMappingInfo> requestMappingInfoSet) {
    for (RequestMappingInfo requestMappingInfo : requestMappingInfoSet) {
        String patternUrl = this.stringifyPatternsCondition(requestMappingInfo.getPatternsCondition());
        if (patternUrl.contains("{")
                || patternUrl.contains("}")
                || !patternUrl.startsWith(DEFAULT_ADMIN_URL)
                || patternUrl.equals(DEFAULT_ADMIN_URL)) {
            continue;
        }
        String name = patternUrl.replace(DEFAULT_ADMIN_URL + "/", "");
        name = name.replace("/", "-");
        MappedRequestInfo mappedRequestInfo = new MappedRequestInfo(name, patternUrl);
        if (mappedRequests.contains(mappedRequestInfo) || mappedRequestInfo.getName().equals("welcome")) {
            continue;
        }
        mappedRequests.add(mappedRequestInfo);
    }
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:19,代码来源:AddAdminUrlsInterceptor.java

示例8: registerHandlerMethod

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
/**
 * Override to only populate the first handler given for a mapping.
 *
 * {@inheritDoc}
 */
@Override
protected void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping) {
    HandlerMethod newHandlerMethod = super.createHandlerMethod(handler, method);

    this.handlerMethods.put(mapping, newHandlerMethod);
    if (logger.isInfoEnabled()) {
        logger.info("Mapped \"" + mapping + "\" onto " + newHandlerMethod);
    }

    if (!this.handlerMethods.containsKey(mapping)) {
        Set<String> patterns = super.getMappingPathPatterns(mapping);
        for (String pattern : patterns) {
            if (!super.getPathMatcher().isPattern(pattern)) {
                this.urlMap.add(pattern, mapping);
            }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:UifRequestMappingHandlerMapping.java

示例9: setResourcePatternByRequestMappingInfo

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
private void setResourcePatternByRequestMappingInfo(Class<?> codeClass, DefaultIPermission<?> perm, Entry<RequestMappingInfo, HandlerMethod> entry){
	/*if(perm.getResourcesPattern()!=null){
		List<UrlResourceInfo> infos = urlResourceInfoParser.parseToUrlResourceInfos(perm.getResourcesPattern());
		//如果自定义了,忽略自动解释
		if(!infos.isEmpty()){
			String urls = this.urlResourceInfoParser.parseToString(infos);
			perm.setResourcesPattern(urls);
		}
		return ;
	}*/
	List<UrlResourceInfo> infos = urlResourceInfoParser.parseToUrlResourceInfos(perm.getResourcesPattern());
	
	Set<String> urlPattterns = entry.getKey().getPatternsCondition().getPatterns();
	
	if(urlPattterns.size()==1){
		String url = urlPattterns.stream().findFirst().orElse("");
		Optional<RequestMethod> method = getFirstMethod(entry.getKey());
		infos.add(new UrlResourceInfo(url, method.isPresent()?method.get().name():null));
		
	}else{
		//超过一个url映射的,不判断方法
		urlPattterns.stream().forEach(url->infos.add(new UrlResourceInfo(url)));
	}
	String urls = this.urlResourceInfoParser.parseToString(infos);
	perm.setResourcesPattern(urls);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:27,代码来源:PermissionHandlerMappingListener.java

示例10: combine

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Override
public RequestMappingInfo combine(Method method, Class<?> handlerType, RequestMappingInfo info) {
	if(info==null){
		return info;
	}
	Optional<AnnotationAttributes> webApiOpt = findWebApiAttrs(method, handlerType);
	if(!webApiOpt.isPresent()){
		return info;
	}
	AnnotationAttributes webApi = webApiOpt.get();
	String prefixPath = webApi.getString("prefixPath");
	if(StringUtils.isBlank(prefixPath)){
		return info;
	}
	prefixPath = SpringUtils.resolvePlaceholders(applicationContext, prefixPath);
	if(StringUtils.isBlank(prefixPath)){
		return info;
	}
	RequestMappingInfo combinerInfo = RequestMappingCombiner.createRequestMappingInfo(prefixPath, method, handlerType)
															.combine(info);
	return combinerInfo;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:23,代码来源:WebApiRequestMappingCombiner.java

示例11: onHandlerMethodsInitialized

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onHandlerMethodsInitialized(Map<RequestMappingInfo, HandlerMethod> handlerMethods) {
	for(HandlerMethod hm : handlerMethods.values()){
		Optional<AnnotationAttributes> attrsOpt = findInterceptorAttrs(hm);
		if(attrsOpt.isPresent()){
			AnnotationAttributes attrs = attrsOpt.get();
			Class<? extends MvcInterceptor>[] interClasses = (Class<? extends MvcInterceptor>[])attrs.get("value");
			List<? extends MvcInterceptor> interceptors = Stream.of(interClasses)
																.flatMap(cls->{
																	List<? extends MvcInterceptor> inters = SpringUtils.getBeans(applicationContext, cls);
																	if(LangUtils.isEmpty(inters)){
																		throw new BaseException("MvcInterceptor not found for : " + cls);
																	}
																	return inters.stream();
																})
																.collect(Collectors.toList());
			if(!interceptors.isEmpty()){
				HandlerMethodInterceptorMeta meta = new HandlerMethodInterceptorMeta(hm, interceptors);
				interceptorMetaCaces.put(hm.getMethod(), meta);
			}
		}
	}
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:25,代码来源:MvcInterceptorManager.java

示例12: doLogging

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Override
protected void doLogging(Map<RequestMappingInfo, HandlerMethod> requestMappingInfoAndHandlerMethodMap){
    Map<String, String> urlAndClientCacheMap = HandlerMappingUtil.buildUrlAndAnnotationStringMap(
                    requestMappingInfoAndHandlerMethodMap,
                    ClientCache.class,
                    ClientCacheToStringBuilder.INSTANCE);

    if (isNullOrEmpty(urlAndClientCacheMap)){
        LOGGER.info("urlAndClientCacheMap is null or empty");
        return;
    }

    //---------------------------------------------------------------
    LOGGER.info(
                    "url And ClientCache,size:[{}], info:{}",
                    urlAndClientCacheMap.size(),
                    JsonUtil.format(sortMapByKeyAsc(urlAndClientCacheMap)));
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:19,代码来源:ContextRefreshedClientCacheInfoEventListener.java

示例13: getRequestMappingHandlerMappingInfoMapForLog

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
/**
 * 获得 request mapping handler mapping info map for LOGGER.
 *
 * @param webApplicationContext
 *            the web application context
 * @return the request mapping handler mapping info map for log
 */
public static final Map<String, Object> getRequestMappingHandlerMappingInfoMapForLog(WebApplicationContext webApplicationContext){
    RequestMappingHandlerMapping requestMappingHandlerMapping = webApplicationContext.getBean(RequestMappingHandlerMapping.class);

    Map<String, Object> mappingInfoMap = newLinkedHashMap();

    mappingInfoMap.put("useRegisteredSuffixPatternMatch()", requestMappingHandlerMapping.useRegisteredSuffixPatternMatch());
    mappingInfoMap.put("useSuffixPatternMatch()", requestMappingHandlerMapping.useSuffixPatternMatch());
    mappingInfoMap.put("useTrailingSlashMatch()", requestMappingHandlerMapping.useTrailingSlashMatch());
    mappingInfoMap.put("getDefaultHandler()", requestMappingHandlerMapping.getDefaultHandler());
    mappingInfoMap.put("getFileExtensions()", requestMappingHandlerMapping.getFileExtensions());
    mappingInfoMap.put("getOrder()", requestMappingHandlerMapping.getOrder());
    mappingInfoMap.put("getPathMatcher()", requestMappingHandlerMapping.getPathMatcher());
    mappingInfoMap.put("getUrlPathHelper()", requestMappingHandlerMapping.getUrlPathHelper());

    //---------------------------------------------------------------
    Map<String, RequestMappingInfo> methodAndRequestMappingInfoMapMap = buildMethodAndRequestMappingInfoMap(
                    requestMappingHandlerMapping);
    mappingInfoMap.put("methodAndRequestMappingInfoMapMap", methodAndRequestMappingInfoMapMap);
    return mappingInfoMap;
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:28,代码来源:HandlerMappingUtil.java

示例14: buildMethodAndRequestMappingInfoMap

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
/**
 * key 是handle 方法,value 是 RequestMappingInfo 信息.
 *
 * @param requestMappingHandlerMapping
 *            the request mapping handler mapping
 * @return the map< string, request mapping info>
 * @see org.springframework.web.servlet.mvc.method.RequestMappingInfo
 * @see org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#createRequestMappingInfo(RequestMapping,
 *      RequestCondition)
 * @since 1.5.4
 */
private static Map<String, RequestMappingInfo> buildMethodAndRequestMappingInfoMap(
                RequestMappingHandlerMapping requestMappingHandlerMapping){
    Map<String, RequestMappingInfo> methodAndRequestMappingInfoMap = newLinkedHashMap();

    //---------------------------------------------------------------
    Map<RequestMappingInfo, HandlerMethod> handlerMethods = requestMappingHandlerMapping.getHandlerMethods();
    for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : handlerMethods.entrySet()){
        RequestMappingInfo requestMappingInfo = entry.getKey();
        HandlerMethod handlerMethod = entry.getValue();

        methodAndRequestMappingInfoMap.put(handlerMethod.toString(), requestMappingInfo);
    }

    if (LOGGER.isInfoEnabled()){
        Collection<RequestMappingInfo> requestMappingInfoCollection = methodAndRequestMappingInfoMap.values();
        String format = JsonUtil.format(getPropertyValueList(requestMappingInfoCollection, "patternsCondition.patterns"));
        LOGGER.info("all requestMapping value:{}", format);
    }
    return methodAndRequestMappingInfoMap;
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:32,代码来源:HandlerMappingUtil.java

示例15: onApplicationEvent

import org.springframework.web.servlet.mvc.method.RequestMappingInfo; //导入依赖的package包/类
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent){
    if (!LOGGER.isInfoEnabled()){
        return;
    }

    ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
    Map<RequestMappingInfo, HandlerMethod> requestMappingInfoAndHandlerMethodMap = buildHandlerMethods(applicationContext);

    if (isNullOrEmpty(requestMappingInfoAndHandlerMethodMap)){
        LOGGER.info("requestMappingInfo And HandlerMethod Map is null or empty!!");
        return;
    }
    //---------------------------------------------------------------
    doLogging(requestMappingInfoAndHandlerMethodMap);
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:17,代码来源:AbstractContextRefreshedHandlerMethodLogginEventListener.java


注:本文中的org.springframework.web.servlet.mvc.method.RequestMappingInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。