當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。