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


Java LocalVariableTableParameterNameDiscoverer.getParameterNames方法代码示例

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


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

示例1: getVariables

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
/**
 * 获取方法的参数
 *
 * @param context
 * @return
 */
public static List<Param> getVariables(ExtensionContext context) {
    List<Param> list = new ArrayList<Param>();
    Parameter[] Paramters = context.getTestMethod().get().getParameters();
    LocalVariableTableParameterNameDiscoverer u =
            new LocalVariableTableParameterNameDiscoverer();
    String[] params = u.getParameterNames(context.getTestMethod().get());
    for (int i = 0; i < Paramters.length; i++) {
        Param p = new Param();
        p.setName(params[i].trim());
        p.setType(Paramters[i].getType().getSimpleName());
        list.add(p);
    }

    return list;
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:22,代码来源:DataDeal.java

示例2: getMethodParameters

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
protected List<MethodParameterInfo> getMethodParameters(Method method) {
    ArrayList<MethodParameterInfo> params = new ArrayList<>();

    Class<?>[] parameterTypes = method.getParameterTypes();

    LocalVariableTableParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    String[] parameterNames = parameterNameDiscoverer.getParameterNames(method);

    if (parameterTypes != null) {
        for (int i = 0; i < parameterTypes.length; i++) {
            String parameterName = parameterNames != null ? parameterNames[i] : "arg" + i;
            MethodParameterInfo parameterInfo = new MethodParameterInfo(parameterTypes[i].getName(), parameterName, null);
            params.add(parameterInfo);
        }
    }
    return params;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:AbstractBeansMetadata.java

示例3: getSignatures

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
public static String[] getSignatures() {
    List<String> signatures = new ArrayList<String>();
    Method[] methods = ModelAttributeScriptHelper.class.getMethods();
    LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
    for (Method method : methods) {
        if (method.getDeclaringClass().equals(ModelAttributeScriptHelper.class) && Modifier.isPublic(method.getModifiers())
                && !Modifier.isStatic(method.getModifiers())) {
            StringBuilder sig = new StringBuilder(method.getName());
            sig.append("(");
            String[] names = discoverer.getParameterNames(method);
            for (String name : names) {
                sig.append(name);
                sig.append(",");

            }
            if (names.length > 0) {
                sig.replace(sig.length() - 1, sig.length(), ")");
            } else {
                sig.append(")");
            }
            signatures.add(sig.toString());
        }
    }
    Collections.sort(signatures);
    return signatures.toArray(new String[signatures.size()]);
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:27,代码来源:ModelAttributeScriptHelper.java

示例4: around

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
@Around(value = "", anno = Controller.class)
public Object around(Invocation invocation, ProxyChain proxyChain) {
    Method method = invocation.getMethod();

    BeanContext beanContext = BeanContextManager.get();
    HttpServletRequest request = (HttpServletRequest) beanContext.getBean("HttpServletRequest");
    beanContext.setBean("model", new Model(request), BeanScope.request);

    LocalVariableTableParameterNameDiscoverer u =
            new LocalVariableTableParameterNameDiscoverer();

    Class<?>[] parameterTypes = method.getParameterTypes();
    String[] paramName = u.getParameterNames(method);
    Object[] params = new Object[paramName.length];
    for (int i = 0; i < paramName.length; i++) {
        if (String.class.isAssignableFrom(parameterTypes[i])) {
            params[i] = request.getParameter(paramName[i]);
        } else if (Integer.class.isAssignableFrom(parameterTypes[i]) || int.class.isAssignableFrom(parameterTypes[i])) {
            params[i] = Integer.parseInt(request.getParameter(paramName[i]));
        } else if (Double.class.isAssignableFrom(parameterTypes[i]) || double.class.isAssignableFrom(parameterTypes[i])) {
            params[i] = Double.parseDouble(request.getParameter(paramName[i]));
        } else if (Boolean.class.isAssignableFrom(parameterTypes[i]) || boolean.class.isAssignableFrom(parameterTypes[i])) {
            params[i] = Boolean.parseBoolean(request.getParameter(paramName[i]));
        }
    }

    for (int i = 0; i < parameterTypes.length; i++) {
        System.out.println(parameterTypes[i]);
        if (params[i] == null) {
            params[i] = beanContext.getBean(parameterTypes[i]);
        }
    }

    invocation.setArgs(params);
    return proxyChain.doProxyChain(invocation);
}
 
开发者ID:omsfuk,项目名称:Samurai,代码行数:37,代码来源:ParameterAspect.java

示例5: parseKey

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
/**
 * <p>
 * 获取缓存的key key 定义在注解上,支持SPEL表达式
 * </p>
 *
 * @param args
 * @return key 调用方设置的key
 * @author fulei.yang
 * @date 2016/11/03
 * @version 0.0.1
 */
private String parseKey(String key, Method method, Object[] args) {
    // 获取被拦截方法参数名列表(使用Spring支持类库)
    LocalVariableTableParameterNameDiscoverer localVariableTableParameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    String[] paraNameArr = localVariableTableParameterNameDiscoverer.getParameterNames(method);
    // 使用SPEL进行key的解析
    ExpressionParser parser = new SpelExpressionParser();
    // SPEL上下文
    StandardEvaluationContext context = new StandardEvaluationContext();
    // 把方法参数放入SPEL上下文中
    for (int i = 0; i < paraNameArr.length; i++) {
        context.setVariable(paraNameArr[i], args[i]);
    }
    return parser.parseExpression(key).getValue(context, String.class);
}
 
开发者ID:wangmeng1314,项目名称:Code-warehouse,代码行数:26,代码来源:CacheValuesOperation.java

示例6: getMethodParamNames

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
/**
 * 获取参数名列表
 * 
 * @param method
 * @return
 */
public static String[] getMethodParamNames(Method method) {
	// 获取被拦截方法参数名列表(使用Spring支持类库)
	LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
	String[] paraNameArr = u.getParameterNames(method);
	return paraNameArr;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:13,代码来源:AopUtil.java

示例7: getConstructorNames

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
public static String[] getConstructorNames(Constructor<?> targetConstructor){
	LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
	return discoverer.getParameterNames(targetConstructor);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:5,代码来源:SpringUtils.java

示例8: getApiParamMetaByASM

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
/**
 * 通过ASM方式获得方法参数信息
 * @param apiMethod
 * @return
 */
private static ApiParamMeta[] getApiParamMetaByASM(Method apiMethod) {
	LocalVariableTableParameterNameDiscoverer parameterNameDiscoverer = 
			new LocalVariableTableParameterNameDiscoverer();
	String[] names = parameterNameDiscoverer.getParameterNames(apiMethod);
	
	if (names != null) {
		ApiParamMeta[] apiParamMetas = new ApiParamMeta[names.length];
		for (int i = 0; i < names.length; i++) {
			apiParamMetas[i] = new ApiParamMeta(names[i]);
		}
		return apiParamMetas;
	}
	return null;
}
 
开发者ID:linkeer8802,项目名称:api-resolver,代码行数:20,代码来源:ApiMetaResolver.java

示例9: getParamNames

import org.springframework.core.LocalVariableTableParameterNameDiscoverer; //导入方法依赖的package包/类
/**
 * 获取方法的参数名
 * @param method 方法
 * @return 方法名称数组
 */
public static String[] getParamNames(Method method) {
    LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
    return u.getParameterNames(method);
}
 
开发者ID:DreamYa0,项目名称:zeratul,代码行数:10,代码来源:ReflectionUtils.java


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