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


Java RequestMappingHandlerMapping.getHandlerMethods方法代码示例

本文整理汇总了Java中org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandlerMethods方法的典型用法代码示例。如果您正苦于以下问题:Java RequestMappingHandlerMapping.getHandlerMethods方法的具体用法?Java RequestMappingHandlerMapping.getHandlerMethods怎么用?Java RequestMappingHandlerMapping.getHandlerMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping的用法示例。


在下文中一共展示了RequestMappingHandlerMapping.getHandlerMethods方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onApplicationEvent

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的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: buildMethodAndRequestMappingInfoMap

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的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

示例3: create

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
public static HomeModuleExtension create(RequestMappingHandlerMapping mapping) {
	HomeModuleExtension ext = new HomeModuleExtension();

	Map<RequestMappingInfo, HandlerMethod> handlerMethods = mapping.getHandlerMethods();
	for (RequestMappingInfo info : handlerMethods.keySet()) {
		Set<String> patterns = info.getPatternsCondition().getPatterns();
		for (String pattern : patterns) {
			ext.addPath(pattern);
		}
	}

	return ext;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:14,代码来源:SpringMvcHomeModuleExtensionFactory.java

示例4: buildHandlerMethods

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
/**
 * Builds the handler methods.
 *
 * @param applicationContext
 *            the application context
 * @return 如果取不到 <code>RequestMappingHandlerMapping</code>,返回 {@link Collections#emptyMap()}<br>
 * @throws BeansException
 *             the beans exception
 */
private static Map<RequestMappingInfo, HandlerMethod> buildHandlerMethods(ApplicationContext applicationContext){
    RequestMappingHandlerMapping requestMappingHandlerMapping = applicationContext.getBean(RequestMappingHandlerMapping.class);//通过上下文对象获取RequestMappingHandlerMapping实例对象  

    if (null == requestMappingHandlerMapping){
        return emptyMap();
    }

    return requestMappingHandlerMapping.getHandlerMethods();
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:19,代码来源:AbstractContextRefreshedHandlerMethodLogginEventListener.java

示例5: getEndpoints

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
/**
 * Returns all RequestMappingInfo instances from type and
 * method-level @RequestMapping annotations in @Controller classes.
 *
 * @param requestMappingHandlerMapping
 *            The RequestMappingInfo collection of Spring
 * @return A set of RequestMappingInfo
 */
@PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName())")
public Set<RequestMappingInfo> getEndpoints(RequestMappingHandlerMapping requestMappingHandlerMapping) {

	if (requestMappingHandlerMapping.getHandlerMethods() != null) {
		return requestMappingHandlerMapping.getHandlerMethods().keySet();
	}

	return null;
}
 
开发者ID:terrestris,项目名称:shogun2,代码行数:18,代码来源:EndpointDocService.java

示例6: generate

import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
/**
 * Generates a WadlApplication from Spring MVC request mappings.
 * 
 * Supported Spring MVC annotations:
 * 
 * <code>RequestMapping</code>
 *   Mapped to a WADL <code>application/resources/resource</code> element 
 * 
 *   Parameters:
 *    - value: mapped to <code>resource/@path<code>
 *    - method: mapped to <code>resource/method/@name<code>
 *    - produces: mapped to <code>resource/response/representation/@mediaType<code>
 *    - consumes: mapped to <code>resource/request/representation/@mediaType<code>
 * 
 * <code>PathVariable</code>
 *   Mapped to a WADL <code>application/resources/resource/method/request/param</code>
 *   element with <code>@style="template" @required="true"</code>
 *   
 *   Parameters:
 *    - value: mapped to <code>param/@name<code> 
 * 
 * <code>RequestParam</code>
 *   Mapped to a WADL <code>application/resources/resource/method/request/param</code>
 *   element with <code>@style="query"</code>
 *   
 *   Parameters:
 *    - value: mapped to <code>param/@name<code> 
 *    - required: mapped to <code>param/@required<code>
 *    - defaultValue: mapped to <code>param/@default<code>
 * 
 * @param handlerMapping the Spring MVC request mappings
 * @param request the HTTP request to retrieve the WADL
 * @param applicationName name of the application
 * @param ignoreControllers list of controller classes to ignore
 * @param wadlTypeMapper custom WADL type mapper to use
 * 
 * @return a WadlApplication describing the application's API
 */
public static WadlApplication generate(RequestMappingHandlerMapping handlerMapping,
		HttpServletRequest request, String applicationName, List<Class<?>> ignoreControllers,
		WadlTypeMapper wadlTypeMapper) {

	WadlApplication result = new WadlApplication();

	WadlDoc doc = createWadlDoc(applicationName);
	result.getDoc().add(doc);

	WadlResources wadlResources = new WadlResources();

	String baseUrl = getBaseUrl(request);
	wadlResources.setBase(baseUrl);

	Map<RequestMappingInfo, HandlerMethod> handletMethods = handlerMapping.getHandlerMethods();
	for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : handletMethods.entrySet()) {
		RequestMappingInfo mappingInfo = entry.getKey();
		HandlerMethod handlerMethod = entry.getValue();
		
		Class<?> controllerClass = handlerMethod.getBeanType();
		if (ignoreControllers.contains(controllerClass)) {
			if (log.isDebugEnabled()) {
				log.debug("Ignoring controller class: " + controllerClass);
			}
			
			continue;  // skip
		}

		WadlResource wadlResource = mapToWadlResource(mappingInfo, handlerMethod, wadlTypeMapper);
		wadlResources.getResource().add(wadlResource);
	}

	result.getResources().add(wadlResources);

	return result;
}
 
开发者ID:loia,项目名称:springmvc-wadlgen,代码行数:75,代码来源:WadlGenerator.java


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