本文整理匯總了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() )
);
}
示例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());
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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