當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodParameter.getMethod方法代碼示例

本文整理匯總了Java中org.springframework.core.MethodParameter.getMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodParameter.getMethod方法的具體用法?Java MethodParameter.getMethod怎麽用?Java MethodParameter.getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.core.MethodParameter的用法示例。


在下文中一共展示了MethodParameter.getMethod方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveArgument

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	ModelMap model = mavContainer.getModel();
	if (model.size() > 0) {
		int lastIndex = model.size()-1;
		String lastKey = new ArrayList<String>(model.keySet()).get(lastIndex);
		if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
			return model.get(lastKey);
		}
	}

	throw new IllegalStateException(
			"An Errors/BindingResult argument is expected to be declared immediately after the model attribute, " +
			"the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:ErrorsMethodArgumentResolver.java

示例2: resolveArgument

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * Delegate to the {@link WebArgumentResolver} instance.
 * @exception IllegalStateException if the resolved value is not assignable
 * to the method parameter.
 */
@Override
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	Class<?> paramType = parameter.getParameterType();
	Object result = this.adaptee.resolveArgument(parameter, webRequest);
	if (result == WebArgumentResolver.UNRESOLVED || !ClassUtils.isAssignableValue(paramType, result)) {
		throw new IllegalStateException(
				"Standard argument type [" + paramType.getName() + "] in method " + parameter.getMethod() +
				"resolved to incompatible value of type [" + (result != null ? result.getClass() : null) +
				"]. Consider declaring the argument type in a less specific fashion.");
	}
	return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:AbstractWebArgumentResolverAdapter.java

示例3: handleReturnValue

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void handleReturnValue(
		Object returnValue, MethodParameter returnType,
		ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
		throws Exception {

	if (returnValue == null) {
		return;
	}
	else if (returnValue instanceof Map){
		mavContainer.addAllAttributes((Map) returnValue);
	}
	else {
		// should not happen
		throw new UnsupportedOperationException("Unexpected return type: " +
				returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:MapMethodProcessor.java

示例4: handleReturnValue

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public void handleReturnValue(
		Object returnValue, MethodParameter returnType,
		ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
		throws Exception {

	if (returnValue == null) {
		return;
	}
	else if (returnValue instanceof Model) {
		mavContainer.addAllAttributes(((Model) returnValue).asMap());
	}
	else {
		// should not happen
		throw new UnsupportedOperationException("Unexpected return type: " +
				returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:ModelMethodProcessor.java

示例5: isAutowireCandidate

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * Determine whether the provided bean definition is an autowire candidate.
 * <p>To be considered a candidate the bean's <em>autowire-candidate</em>
 * attribute must not have been set to 'false'. Also, if an annotation on
 * the field or parameter to be autowired is recognized by this bean factory
 * as a <em>qualifier</em>, the bean must 'match' against the annotation as
 * well as any attributes it may contain. The bean definition must contain
 * the same qualifier or match by meta attributes. A "value" attribute will
 * fallback to match against the bean name or an alias if a qualifier or
 * attribute does not match.
 * @see Qualifier
 */
@Override
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
	boolean match = super.isAutowireCandidate(bdHolder, descriptor);
	if (match && descriptor != null) {
		match = checkQualifiers(bdHolder, descriptor.getAnnotations());
		if (match) {
			MethodParameter methodParam = descriptor.getMethodParameter();
			if (methodParam != null) {
				Method method = methodParam.getMethod();
				if (method == null || void.class.equals(method.getReturnType())) {
					match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations());
				}
			}
		}
	}
	return match;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:QualifierAnnotationAutowireCandidateResolver.java

示例6: handleMissingValue

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletException {
	throw new UnsupportedOperationException("@Value is never required: " + parameter.getMethod());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:ExpressionValueMethodArgumentResolver.java

示例7: getNameForReturnValue

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * Derive the model attribute name for the given return value using
 * one of the following:
 * <ol>
 * 	<li>The method {@code ModelAttribute} annotation value
 * 	<li>The declared return type if it is other than {@code Object}
 * 	<li>The actual return value type
 * </ol>
 * @param returnValue the value returned from a method invocation
 * @param returnType the return type of the method
 * @return the model name, never {@code null} nor empty
 */
public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) {
	ModelAttribute annot = returnType.getMethodAnnotation(ModelAttribute.class);
	if (annot != null && StringUtils.hasText(annot.value())) {
		return annot.value();
	}
	else {
		Method method = returnType.getMethod();
		Class<?> resolvedType = GenericTypeResolver.resolveReturnType(method, returnType.getContainingClass());
		return Conventions.getVariableNameForReturnType(method, resolvedType, returnValue);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:ModelFactory.java


注:本文中的org.springframework.core.MethodParameter.getMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。