Java Code Examples for org.springframework.web.method.HandlerMethod#createWithResolvedBean()

The following examples show how to use org.springframework.web.method.HandlerMethod#createWithResolvedBean() . 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: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Look up a handler method for the given request.
 * @param exchange the current exchange
 */
@Override
public Mono<HandlerMethod> getHandlerInternal(ServerWebExchange exchange) {
	this.mappingRegistry.acquireReadLock();
	try {
		HandlerMethod handlerMethod;
		try {
			handlerMethod = lookupHandlerMethod(exchange);
		}
		catch (Exception ex) {
			return Mono.error(ex);
		}
		if (handlerMethod != null) {
			handlerMethod = handlerMethod.createWithResolvedBean();
		}
		return Mono.justOrEmpty(handlerMethod);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}
 
Example 2
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Look up a handler method for the given request.
 */
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
	// 截取用于匹配的 URL 有效路径
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	request.setAttribute(LOOKUP_PATH, lookupPath);
	this.mappingRegistry.acquireReadLock();
	try {
		// 根据路径去寻找 Handler
		HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
		return (handlerMethod != null ? handlerMethod.createWithResolvedBean() : null);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}
 
Example 3
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Look up a handler method for the given request.
 * @param exchange the current exchange
 */
@Override
public Mono<HandlerMethod> getHandlerInternal(ServerWebExchange exchange) {
	this.mappingRegistry.acquireReadLock();
	try {
		HandlerMethod handlerMethod;
		try {
			handlerMethod = lookupHandlerMethod(exchange);
		}
		catch (Exception ex) {
			return Mono.error(ex);
		}
		if (handlerMethod != null) {
			handlerMethod = handlerMethod.createWithResolvedBean();
		}
		return Mono.justOrEmpty(handlerMethod);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}
 
Example 4
Source File: AbstractHandlerMethodMapping.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Look up a handler method for the given request.
 */
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	if (logger.isDebugEnabled()) {
		logger.debug("Looking up handler method for path " + lookupPath);
	}
	this.mappingRegistry.acquireReadLock();
	try {
		HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
		if (logger.isDebugEnabled()) {
			if (handlerMethod != null) {
				logger.debug("Returning handler method [" + handlerMethod + "]");
			}
			else {
				logger.debug("Did not find handler method for [" + lookupPath + "]");
			}
		}
		return (handlerMethod != null ? handlerMethod.createWithResolvedBean() : null);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}
 
Example 5
Source File: AbstractHandlerMethodMapping.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Look up a handler method for the given request.
 */
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	if (logger.isDebugEnabled()) {
		logger.debug("Looking up handler method for path " + lookupPath);
	}
	this.mappingRegistry.acquireReadLock();
	try {
		HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
		if (logger.isDebugEnabled()) {
			if (handlerMethod != null) {
				logger.debug("Returning handler method [" + handlerMethod + "]");
			}
			else {
				logger.debug("Did not find handler method for [" + lookupPath + "]");
			}
		}
		return (handlerMethod != null ? handlerMethod.createWithResolvedBean() : null);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}
 
Example 6
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 查找给定请求的处理程序方法。
 */
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
	// 如果请求 url 为,http://localhost:8080/web/hello.json, 则 lookupPath=web/hello.json
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	this.mappingRegistry.acquireReadLock();
	try {
		// 遍历 Controller 上的所有方法,获取 url 匹配的方法
		HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
		return (handlerMethod != null ? handlerMethod.createWithResolvedBean() : null);
	}
	finally {
		this.mappingRegistry.releaseReadLock();
	}
}