当前位置: 首页>>代码示例>>Java>>正文


Java SynthesizingMethodParameter类代码示例

本文整理汇总了Java中org.springframework.core.annotation.SynthesizingMethodParameter的典型用法代码示例。如果您正苦于以下问题:Java SynthesizingMethodParameter类的具体用法?Java SynthesizingMethodParameter怎么用?Java SynthesizingMethodParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SynthesizingMethodParameter类属于org.springframework.core.annotation包,在下文中一共展示了SynthesizingMethodParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyContributors

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
private UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object... args) {
    CompositeUriComponentsContributor contributor = defaultUriComponentsContributor;
    int paramCount = method.getParameterTypes().length;
    int argCount = args.length;
    if (paramCount != argCount) {
        throw new IllegalArgumentException("方法参数量为" + paramCount + " 与真实参数量不匹配,真实参数量为" + argCount);
    }
    final Map<String, Object> uriVars = new HashMap<>(8);
    for (int i = 0; i < paramCount; i++) {
        MethodParameter param = new SynthesizingMethodParameter(method, i);
        param.initParameterNameDiscovery(parameterNameDiscoverer);
        contributor.contributeMethodArgument(param, args[i], builder, uriVars);
    }
    // We may not have all URI var values, expand only what we have
    return builder.build().expand(name -> uriVars.containsKey(name) ? uriVars.get(name) : UriComponents.UriTemplateVariables.SKIP_VALUE);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:17,代码来源:WxApiMethodInfo.java

示例2: setup

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setup() throws Exception {
	@SuppressWarnings("resource")
	GenericApplicationContext cxt = new GenericApplicationContext();
	cxt.refresh();
	this.resolver = new HeaderMethodArgumentResolver(new DefaultConversionService(), cxt.getBeanFactory());

	Method method = getClass().getDeclaredMethod("handleMessage",
			String.class, String.class, String.class, String.class, String.class);
	this.paramRequired = new SynthesizingMethodParameter(method, 0);
	this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 1);
	this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	this.paramNotAnnotated = new SynthesizingMethodParameter(method, 3);
	this.paramNativeHeader = new SynthesizingMethodParameter(method, 4);

	this.paramRequired.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
	GenericTypeResolver.resolveParameterType(this.paramRequired, HeaderMethodArgumentResolver.class);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:HeaderMethodArgumentResolverTests.java

示例3: resolveHandlerArguments

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
/**
 * Resolves the arguments for the given method. Delegates to {@link #resolveCommonArgument}.
 */
private Object[] resolveHandlerArguments(Method handlerMethod, Object handler,
		NativeWebRequest webRequest, Exception thrownException) throws Exception {

	Class<?>[] paramTypes = handlerMethod.getParameterTypes();
	Object[] args = new Object[paramTypes.length];
	Class<?> handlerType = handler.getClass();
	for (int i = 0; i < args.length; i++) {
		MethodParameter methodParam = new SynthesizingMethodParameter(handlerMethod, i);
		GenericTypeResolver.resolveParameterType(methodParam, handlerType);
		Class<?> paramType = methodParam.getParameterType();
		Object argValue = resolveCommonArgument(methodParam, webRequest, thrownException);
		if (argValue != WebArgumentResolver.UNRESOLVED) {
			args[i] = argValue;
		}
		else {
			throw new IllegalStateException("Unsupported argument [" + paramType.getName() +
					"] for @ExceptionHandler method: " + handlerMethod);
		}
	}
	return args;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:AnnotationMethodHandlerExceptionResolver.java

示例4: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.resolver = new MatrixVariableMapMethodArgumentResolver();

	Method method = getClass().getMethod("handle", String.class,
			Map.class, MultiValueMap.class, MultiValueMap.class, Map.class);

	this.paramString = new SynthesizingMethodParameter(method, 0);
	this.paramMap = new SynthesizingMethodParameter(method, 1);
	this.paramMultivalueMap = new SynthesizingMethodParameter(method, 2);
	this.paramMapForPathVar = new SynthesizingMethodParameter(method, 3);
	this.paramMapWithName = new SynthesizingMethodParameter(method, 4);

	this.mavContainer = new ModelAndViewContainer();
	this.request = new MockHttpServletRequest();
	this.webRequest = new ServletWebRequest(request, new MockHttpServletResponse());

	Map<String, MultiValueMap<String, String>> params = new LinkedHashMap<String, MultiValueMap<String, String>>();
	this.request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, params);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:MatrixVariablesMapMethodArgumentResolverTests.java

示例5: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());

	Method method = getClass().getMethod("params", String.class, String[].class, String.class, String.class, Map.class);
	paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
	paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
	paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	paramContextPath = new SynthesizingMethodParameter(method, 3);
	paramNamedValueMap = new SynthesizingMethodParameter(method, 4);

	servletRequest = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:RequestHeaderMethodArgumentResolverTests.java

示例6: resolveDependency

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
static Object resolveDependency(Parameter parameter, Class<?> containingClass, ApplicationContext applicationContext) {
    boolean required = findMergedAnnotation(parameter, Autowired.class).map(Autowired::required).orElse(true);
    MethodParameter methodParameter = SynthesizingMethodParameter.forParameter(parameter);
    DependencyDescriptor descriptor = new DependencyDescriptor(methodParameter, required);
    descriptor.setContainingClass(containingClass);
    return applicationContext.getAutowireCapableBeanFactory().resolveDependency(descriptor, null);
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:8,代码来源:AutoTestExtension.java

示例7: setup

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setup() throws Exception {
	MockitoAnnotations.initMocks(this);

	SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
	messagingTemplate.setMessageConverter(new StringMessageConverter());
	this.handler = new SendToMethodReturnValueHandler(messagingTemplate, true);
	this.handlerAnnotationNotRequired = new SendToMethodReturnValueHandler(messagingTemplate, false);

	SimpMessagingTemplate jsonMessagingTemplate = new SimpMessagingTemplate(this.messageChannel);
	jsonMessagingTemplate.setMessageConverter(new MappingJackson2MessageConverter());
	this.jsonHandler = new SendToMethodReturnValueHandler(jsonMessagingTemplate, true);

	Method method = this.getClass().getDeclaredMethod("handleNoAnnotations");
	this.noAnnotationsReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToDefaultDestination");
	this.sendToDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendTo");
	this.sendToReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToWithPlaceholders");
	this.sendToWithPlaceholdersReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToUser");
	this.sendToUserReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToUserSingleSession");
	this.sendToUserSingleSessionReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToUserDefaultDestination");
	this.sendToUserDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToUserDefaultDestinationSingleSession");
	this.sendToUserSingleSessionDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);

	method = this.getClass().getDeclaredMethod("handleAndSendToJsonView");
	this.jsonViewReturnType = new SynthesizingMethodParameter(method, -1);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:41,代码来源:SendToMethodReturnValueHandlerTests.java

示例8: setup

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setup() throws Exception {
	this.resolver = new PayloadArgumentResolver(new StringMessageConverter(), testValidator());
	this.payloadMethod = PayloadArgumentResolverTests.class.getDeclaredMethod("handleMessage",
			String.class, String.class, Locale.class, String.class, String.class, String.class, String.class);

	this.paramAnnotated = new SynthesizingMethodParameter(this.payloadMethod, 0);
	this.paramAnnotatedNotRequired = new SynthesizingMethodParameter(this.payloadMethod, 1);
	this.paramAnnotatedRequired = new SynthesizingMethodParameter(payloadMethod, 2);
	this.paramWithSpelExpression = new SynthesizingMethodParameter(payloadMethod, 3);
	this.paramValidated = new SynthesizingMethodParameter(this.payloadMethod, 4);
	this.paramValidated.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
	this.paramValidatedNotAnnotated = new SynthesizingMethodParameter(this.payloadMethod, 5);
	this.paramNotAnnotated = new SynthesizingMethodParameter(this.payloadMethod, 6);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:PayloadArgumentResolverTests.java

示例9: applyContributors

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
private static UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object... args) {
	CompositeUriComponentsContributor contributor = getConfiguredUriComponentsContributor();
	if (contributor == null) {
		logger.debug("Using default CompositeUriComponentsContributor");
		contributor = defaultUriComponentsContributor;
	}

	int paramCount = method.getParameterTypes().length;
	int argCount = args.length;
	if (paramCount != argCount) {
		throw new IllegalArgumentException("Number of method parameters " + paramCount +
				" does not match number of argument values " + argCount);
	}

	final Map<String, Object> uriVars = new HashMap<String, Object>();
	for (int i = 0; i < paramCount; i++) {
		MethodParameter param = new SynthesizingMethodParameter(method, i);
		param.initParameterNameDiscovery(parameterNameDiscoverer);
		contributor.contributeMethodArgument(param, args[i], builder, uriVars);
	}

	// We may not have all URI var values, expand only what we have
	return builder.build().expand(new UriComponents.UriTemplateVariables() {
		@Override
		public Object getValue(String name) {
			return uriVars.containsKey(name) ? uriVars.get(name) : UriComponents.UriTemplateVariables.SKIP_VALUE;
		}
	});
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:MvcUriComponentsBuilder.java

示例10: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resolver = new ServletCookieValueMethodArgumentResolver(null);

	Method method = getClass().getMethod("params", Cookie.class, String.class);
	cookieParameter = new SynthesizingMethodParameter(method, 0);
	cookieStringParameter = new SynthesizingMethodParameter(method, 1);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:ServletCookieValueMethodArgumentResolverTests.java

示例11: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resolver = new RequestParamMapMethodArgumentResolver();

	Method method = getClass().getMethod("params", Map.class, MultiValueMap.class, Map.class, Map.class);
	paramMap = new SynthesizingMethodParameter(method, 0);
	paramMultiValueMap = new SynthesizingMethodParameter(method, 1);
	paramNamedMap = new SynthesizingMethodParameter(method, 2);
	paramMapWithoutAnnot = new SynthesizingMethodParameter(method, 3);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:RequestParamMapMethodArgumentResolverTests.java

示例12: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resolver = new RequestParamMethodArgumentResolver(null, true);

	ParameterNameDiscoverer paramNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();

	Method method = getClass().getMethod("params", String.class, String[].class,
			Map.class, MultipartFile.class, List.class, MultipartFile[].class,
			Part.class, List.class, Part[].class, Map.class,
			String.class, MultipartFile.class, List.class, Part.class,
			MultipartFile.class, String.class, String.class, Optional.class);

	paramNamedDefaultValueString = new SynthesizingMethodParameter(method, 0);
	paramNamedStringArray = new SynthesizingMethodParameter(method, 1);
	paramNamedMap = new SynthesizingMethodParameter(method, 2);
	paramMultipartFile = new SynthesizingMethodParameter(method, 3);
	paramMultipartFileList = new SynthesizingMethodParameter(method, 4);
	paramMultipartFileArray = new SynthesizingMethodParameter(method, 5);
	paramPart = new SynthesizingMethodParameter(method, 6);
	paramPartList  = new SynthesizingMethodParameter(method, 7);
	paramPartArray  = new SynthesizingMethodParameter(method, 8);
	paramMap = new SynthesizingMethodParameter(method, 9);
	paramStringNotAnnot = new SynthesizingMethodParameter(method, 10);
	paramStringNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramMultipartFileNotAnnot = new SynthesizingMethodParameter(method, 11);
	paramMultipartFileNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramMultipartFileListNotAnnot = new SynthesizingMethodParameter(method, 12);
	paramMultipartFileListNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramPartNotAnnot = new SynthesizingMethodParameter(method, 13);
	paramPartNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramRequestPartAnnot = new SynthesizingMethodParameter(method, 14);
	paramRequired = new SynthesizingMethodParameter(method, 15);
	paramNotRequired = new SynthesizingMethodParameter(method, 16);
	paramOptional = new SynthesizingMethodParameter(method, 17);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:RequestParamMethodArgumentResolverTests.java

示例13: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resolver = new TestCookieValueMethodArgumentResolver();

	Method method = getClass().getMethod("params", Cookie.class, String.class, String.class);
	paramNamedCookie = new SynthesizingMethodParameter(method, 0);
	paramNamedDefaultValueString = new SynthesizingMethodParameter(method, 1);
	paramString = new SynthesizingMethodParameter(method, 2);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:CookieValueMethodArgumentResolverTests.java

示例14: setUp

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resolver = new RequestHeaderMapMethodArgumentResolver();

	Method method = getClass().getMethod("params", Map.class, MultiValueMap.class, HttpHeaders.class, Map.class);
	paramMap = new SynthesizingMethodParameter(method, 0);
	paramMultiValueMap = new SynthesizingMethodParameter(method, 1);
	paramHttpHeaders = new SynthesizingMethodParameter(method, 2);
	paramUnsupported = new SynthesizingMethodParameter(method, 3);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:RequestHeaderMapMethodArgumentResolverTests.java

示例15: applyContributors

import org.springframework.core.annotation.SynthesizingMethodParameter; //导入依赖的package包/类
private static UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object... args) {
	CompositeUriComponentsContributor contributor = getConfiguredUriComponentsContributor();
	if (contributor == null) {
		logger.debug("Using default CompositeUriComponentsContributor");
		contributor = defaultUriComponentsContributor;
	}

	int paramCount = method.getParameterTypes().length;
	int argCount = args.length;
	if (paramCount != argCount) {
		throw new IllegalArgumentException("Number of method parameters " + paramCount +
				" does not match number of argument values " + argCount);
	}

	final Map<String, Object> uriVars = new HashMap<String, Object>();
	for (int i = 0; i < paramCount; i++) {
		MethodParameter param = new SynthesizingMethodParameter(method, i);
		param.initParameterNameDiscovery(parameterNameDiscoverer);
		contributor.contributeMethodArgument(param, args[i], builder, uriVars);
	}
	
	// Custom implementation to remove uriVar if the value is null
	removeUriVarsWithNullValue(uriVars);
	
	// We may not have all URI var values, expand only what we have
	return builder.build().expand(new UriComponents.UriTemplateVariables() {
		@Override
		public Object getValue(String name) {
			return uriVars.containsKey(name) ? uriVars.get(name) : UriComponents.UriTemplateVariables.SKIP_VALUE;
		}
	});
}
 
开发者ID:DISID,项目名称:springlets,代码行数:33,代码来源:SpringletsMvcUriComponentsBuilder.java


注:本文中的org.springframework.core.annotation.SynthesizingMethodParameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。