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


Java ParameterNameDiscoverer类代码示例

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


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

示例1: getOperationParameters

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * Create parameter info for the given method.
 * <p>The default implementation returns an empty array of {@code MBeanParameterInfo}.
 * @param method the {@code Method} to get the parameter information for
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code MBeanParameterInfo} array
 */
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
	ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
	String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);
	if (paramNames == null) {
		return new MBeanParameterInfo[0];
	}

	MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
	Class<?>[] typeParameters = method.getParameterTypes();
	for(int i = 0; i < info.length; i++) {
		info[i] = new MBeanParameterInfo(paramNames[i], typeParameters[i].getName(), paramNames[i]);
	}

	return info;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractReflectiveMBeanInfoAssembler.java

示例2: getOperationParameters

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * Create parameter info for the given method.
 * <p>The default implementation returns an empty array of {@code MBeanParameterInfo}.
 * @param method the {@code Method} to get the parameter information for
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code MBeanParameterInfo} array
 */
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
	ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
	String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);
	if (paramNames == null) {
		return new MBeanParameterInfo[0];
	}

	MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
	Class<?>[] typeParameters = method.getParameterTypes();
	for (int i = 0; i < info.length; i++) {
		info[i] = new MBeanParameterInfo(paramNames[i], typeParameters[i].getName(), paramNames[i]);
	}

	return info;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AbstractReflectiveMBeanInfoAssembler.java

示例3: HandlerMethodInvoker

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer,
		SessionAttributeStore sessionAttributeStore, ParameterNameDiscoverer parameterNameDiscoverer,
		WebArgumentResolver[] customArgumentResolvers, HttpMessageConverter<?>[] messageConverters) {

	this.methodResolver = methodResolver;
	this.bindingInitializer = bindingInitializer;
	this.sessionAttributeStore = sessionAttributeStore;
	this.parameterNameDiscoverer = parameterNameDiscoverer;
	this.customArgumentResolvers = customArgumentResolvers;
	this.messageConverters = messageConverters;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:HandlerMethodInvoker.java

示例4: LazyParamAwareEvaluationContext

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
LazyParamAwareEvaluationContext(Object rootObject, ParameterNameDiscoverer paramDiscoverer, Method method,
		Object[] args, Class<?> targetClass, Map<MethodCacheKey, Method> methodCache) {
	super(rootObject);

	this.paramDiscoverer = paramDiscoverer;
	this.method = method;
	this.args = args;
	this.targetClass = targetClass;
	this.methodCache = methodCache;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:LazyParamAwareEvaluationContext.java

示例5: createParameterNameDiscoverer

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * Create a ParameterNameDiscoverer to be used for argument binding.
 * <p>The default implementation creates a {@link DefaultParameterNameDiscoverer}
 * and adds a specifically configured {@link AspectJAdviceParameterNameDiscoverer}.
 */
protected ParameterNameDiscoverer createParameterNameDiscoverer() {
	// We need to discover them, or if that fails, guess,
	// and if we can't guess with 100% accuracy, fail.
	DefaultParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer();
	AspectJAdviceParameterNameDiscoverer adviceParameterNameDiscoverer =
			new AspectJAdviceParameterNameDiscoverer(this.pointcut.getExpression());
	adviceParameterNameDiscoverer.setReturningName(this.returningName);
	adviceParameterNameDiscoverer.setThrowingName(this.throwingName);
	// Last in chain, so if we're called and we fail, that's bad...
	adviceParameterNameDiscoverer.setRaiseExceptions(true);
	discoverer.addDiscoverer(adviceParameterNameDiscoverer);
	return discoverer;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:AbstractAspectJAdvice.java

示例6: MethodBasedEvaluationContext

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
public MethodBasedEvaluationContext(Object rootObject, Method method, Object[] args,
		ParameterNameDiscoverer paramDiscoverer) {

	super(rootObject);
	this.method = method;
	this.args = args;
	this.paramDiscoverer = paramDiscoverer;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:MethodBasedEvaluationContext.java

示例7: setUp

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的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

示例8: buildKey

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * @param invocation
 * @return
 * @throws NoSuchMethodException
 */
public Object buildKey(String key, ProceedingJoinPoint invocation) throws NoSuchMethodException {

    if (key.indexOf("#") == -1) {// 如果不是表达式,直接返回字符串
        return key;
    }

    String keySpEL = "";
    String pre = "";
    String str[] = key.split("\\#");
    if (str.length > 1) {
        pre = str[0];
        for (int i = 1; i < str.length; i++) {
            keySpEL = keySpEL + "#" + str[i];
        }
    } else keySpEL = key;


    MethodSignature signature = (MethodSignature) invocation.getSignature();
    Method method = signature.getMethod();
    Class<?>[] parameterTypes = method.getParameterTypes();
    ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    String[] parameterNames = parameterNameDiscoverer.getParameterNames(invocation.getTarget().getClass().getDeclaredMethod(method.getName(), parameterTypes));
    StandardEvaluationContext context = new StandardEvaluationContext();

    for (int i = 0; i < parameterNames.length; i++) {
        context.setVariable(parameterNames[i], invocation.getArgs()[i]);
    }

    Expression expression = expCache.get(keySpEL);
    if (null == expression) {
        expression = parser.parseExpression(keySpEL);
        expCache.put(keySpEL, expression);
    }

    Object value = expression.getValue(context, Object.class);

    if (!StringUtils.isEmpty(pre)) return pre + value;
    else return value;

}
 
开发者ID:jayqqaa12,项目名称:jbase,代码行数:46,代码来源:SpelKeyGenerator.java

示例9: lookupParameterNames

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
@Override
public String[] lookupParameterNames(
		AccessibleObject methodOrConstructor) {
	String[] names = null;
	ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
	if (methodOrConstructor instanceof Method) {
		names = parameterNameDiscoverer.getParameterNames((Method) methodOrConstructor);
	}
	else {
		names = parameterNameDiscoverer.getParameterNames((Constructor<?>)methodOrConstructor);
	}
	if (names==null) {
		Annotation[][] parameterAnnotations = ((Method) methodOrConstructor).getParameterAnnotations();

		names = new String[parameterAnnotations.length];
		for (int index = 0; index < parameterAnnotations.length; index++) {
			Annotation[] annotations = parameterAnnotations[index];
			boolean found = false;
			for (Annotation annotation : annotations) {
				if (annotation instanceof Named ) {
					Named named = (Named) annotation;
					names[index]=named.value();
					found=true;
				}
			}
			if (!found) {
				names[index]="arg_"+index;
			}
		}
	}


	return names;
}
 
开发者ID:Cybernostics,项目名称:nanorest,代码行数:35,代码来源:InterfaceParserUtil.java

示例10: getCacheKey

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * 取得cache 键值
 * 
 * @param pjp
 * @param method
 * @return 返回string
 */
private String getCacheKey(ProceedingJoinPoint pjp, Method method) {
	if (method.isAnnotationPresent(GetCacheVaule.class)) {
		// 如果有该注解
		String key = method.getAnnotation(GetCacheVaule.class).key();// 得到要缓存的键值

		Object[] values = pjp.getArgs();// 得到顺序的参数值
		ParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
		String[] names = discoverer.getParameterNames(method);
		Map<String, Integer> map = new ConcurrentHashMap<String, Integer>();
		for (int i = 0; i < names.length; i++) {
			map.put(names[i], i);// 将名字和对应的序号放入hashmap
		}
		// 得到真正的key 、value值
		try {
			Integer int_value = map.get(key);// hash中没有对应的值,表示getcachekey和名字不符合
			if (int_value == null) {
				log.warn("your cachekey is not equals" + key
						+ "please check this then change them");					
			} else {
				String cache_key_real = (String) values[int_value];// 要缓存键值的真正cahe值
				return cache_key_real;
			}
		} catch (Exception e) {
			log.warn("your filed " + key + " must be String.class");
		}

	}
	return null;
}
 
开发者ID:Yaccc,项目名称:spring_mem_plugin,代码行数:37,代码来源:GetCacheAop.java

示例11: createParameterNameDiscoverer

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
/**
 * Create a ParameterNameDiscoverer to be used for argument binding.
 * <p>The default implementation creates a {@link PrioritizedParameterNameDiscoverer}
 * containing a {@link LocalVariableTableParameterNameDiscoverer} and an
 * {@link AspectJAdviceParameterNameDiscoverer}.
 */
protected ParameterNameDiscoverer createParameterNameDiscoverer() {
	// We need to discover them, or if that fails, guess,
	// and if we can't guess with 100% accuracy, fail.
	PrioritizedParameterNameDiscoverer discoverer = new PrioritizedParameterNameDiscoverer();
	discoverer.addDiscoverer(new LocalVariableTableParameterNameDiscoverer());
	AspectJAdviceParameterNameDiscoverer adviceParameterNameDiscoverer =
			new AspectJAdviceParameterNameDiscoverer(this.pointcut.getExpression());
	adviceParameterNameDiscoverer.setReturningName(this.returningName);
	adviceParameterNameDiscoverer.setThrowingName(this.throwingName);
	// Last in chain, so if we're called and we fail, that's bad...
	adviceParameterNameDiscoverer.setRaiseExceptions(true);
	discoverer.addDiscoverer(adviceParameterNameDiscoverer);
	return discoverer;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:AbstractAspectJAdvice.java

示例12: LazyParamAwareEvaluationContext

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
LazyParamAwareEvaluationContext(Object rootObject, ParameterNameDiscoverer paramDiscoverer, Method method,
		Object[] args, Class<?> targetClass, Map<String, Method> methodCache) {
	super(rootObject);

	this.paramDiscoverer = paramDiscoverer;
	this.method = method;
	this.args = args;
	this.targetClass = targetClass;
	this.methodCache = methodCache;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:LazyParamAwareEvaluationContext.java

示例13: HandlerMethodInvoker

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer,
		SessionAttributeStore sessionAttributeStore, ParameterNameDiscoverer parameterNameDiscoverer,
		WebArgumentResolver[] customArgumentResolvers, HttpMessageConverter[] messageConverters) {

	this.methodResolver = methodResolver;
	this.bindingInitializer = bindingInitializer;
	this.sessionAttributeStore = sessionAttributeStore;
	this.parameterNameDiscoverer = parameterNameDiscoverer;
	this.customArgumentResolvers = customArgumentResolvers;
	this.messageConverters = messageConverters;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:HandlerMethodInvoker.java

示例14: setUp

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的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, Map.class, String.class,
			MultipartFile.class, List.class, Part.class, MultipartFile.class,
			String.class, String.class);

	paramNamedDefaultValueString = new MethodParameter(method, 0);
	paramNamedStringArray = new MethodParameter(method, 1);
	paramNamedMap = new MethodParameter(method, 2);
	paramMultiPartFile = new MethodParameter(method, 3);
	paramMap = new MethodParameter(method, 4);
	paramStringNotAnnot = new MethodParameter(method, 5);
	paramStringNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramMultipartFileNotAnnot = new MethodParameter(method, 6);
	paramMultipartFileNotAnnot.initParameterNameDiscovery(paramNameDiscoverer);
	paramMultipartFileList = new MethodParameter(method, 7);
	paramMultipartFileList.initParameterNameDiscovery(paramNameDiscoverer);
	paramServlet30Part = new MethodParameter(method, 8);
	paramServlet30Part.initParameterNameDiscovery(paramNameDiscoverer);
	paramRequestPartAnnot = new MethodParameter(method, 9);
	paramRequired = new MethodParameter(method, 10);
	paramNotRequired = new MethodParameter(method, 11);

	request = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:32,代码来源:RequestParamMethodArgumentResolverTests.java

示例15: setParameterNameDiscoverer

import org.springframework.core.ParameterNameDiscoverer; //导入依赖的package包/类
public void setParameterNameDiscoverer(
		ParameterNameDiscoverer parameterNameDiscoverer) {
	this.parameterNameDiscoverer = parameterNameDiscoverer;
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:5,代码来源:InvocableHandlerMethod.java


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