当前位置: 首页>>代码示例>>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;未经允许,请勿转载。