Java 类org.springframework.core.ParameterNameDiscoverer 实例源码

项目:lams    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * 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;
}
项目:spring4-understanding    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * 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;
}
项目:my-spring-cache-redis    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * 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;
}
项目:spring    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * 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;
}
项目:class-guard    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * 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;
}
项目:lams    文件:HandlerMethodInvoker.java   
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;
}
项目:lams    文件:LazyParamAwareEvaluationContext.java   
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;
}
项目:lams    文件:AbstractAspectJAdvice.java   
/**
 * 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;
}
项目:spring4-understanding    文件:AbstractAspectJAdvice.java   
/**
 * 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;
}
项目:spring4-understanding    文件:MethodBasedEvaluationContext.java   
public MethodBasedEvaluationContext(Object rootObject, Method method, Object[] args,
        ParameterNameDiscoverer paramDiscoverer) {

    super(rootObject);
    this.method = method;
    this.args = args;
    this.paramDiscoverer = paramDiscoverer;
}
项目:spring4-understanding    文件:HandlerMethodInvoker.java   
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;
}
项目:spring4-understanding    文件:RequestParamMethodArgumentResolverTests.java   
@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());
}
项目:my-spring-cache-redis    文件:LazyParamAwareEvaluationContext.java   
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;
}
项目:spring    文件:MethodBasedEvaluationContext.java   
public MethodBasedEvaluationContext(Object rootObject, Method method, Object[] args,
        ParameterNameDiscoverer paramDiscoverer) {

    super(rootObject);
    this.method = method;
    this.args = args;
    this.paramDiscoverer = paramDiscoverer;
}
项目:spring    文件:AbstractAspectJAdvice.java   
/**
 * 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;
}
项目:nanorest    文件:InterfaceParserUtil.java   
@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;
}
项目:spring_mem_plugin    文件:GetCacheAop.java   
/**
 * 取得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;
}
项目:spring_mem_plugin    文件:GetCacheAop.java   
/**
 * 取得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;
}
项目:class-guard    文件:AbstractAspectJAdvice.java   
/**
 * 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;
}
项目:class-guard    文件:LazyParamAwareEvaluationContext.java   
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;
}
项目:class-guard    文件:HandlerMethodInvoker.java   
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;
}
项目:class-guard    文件:RequestParamMethodArgumentResolverTests.java   
@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());
}
项目:wamp2spring    文件:InvocableHandlerMethod.java   
public void setParameterNameDiscoverer(
        ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:spring4-understanding    文件:CacheEvaluationContext.java   
CacheEvaluationContext(Object rootObject, Method method, Object[] args,
        ParameterNameDiscoverer paramDiscoverer) {

    super(rootObject, method, args, paramDiscoverer);
    this.unavailableVariables = new ArrayList<String>();
}
项目:leopard    文件:XParamUtil.java   
public static String[] getParameterNames(MethodParameter parameter) {
    Method method = parameter.getMethod();
    // ParameterNameDiscoverer parameterNameDiscoverer = null;
    ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    return parameterNameDiscoverer.getParameterNames(method);
}
项目:netty-http-3.x    文件:RemoteRouter.java   
@Override
public void afterPropertiesSet() throws Exception {
    ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();

    for (Entry<String, Object> entry : namespacedServices.entrySet()) {
        Class<?> clazz = entry.getValue().getClass();

        try {
            clazz = ((Advised) entry.getValue()).getTargetSource().getTarget().getClass();
        } catch (Exception ignored) {
        }

        Namespace namespace = clazz.getAnnotation(Namespace.class);
        logger.debug("clazz={}, namespace={}", clazz.getName(), namespace);

        if (namespace == null || "".equals(namespace.value())) {
            logger.debug("namespace is null or empty. clazz={}", clazz.getName());
            continue;
        }

        String prefix = namespace.value();
        boolean exposeAll = namespace.exposeAll();

        for (Method method : clazz.getDeclaredMethods()) {
            logger.debug("clazz={}, method={}", clazz.getName(), method.getName());

            if (!Modifier.isPublic(method.getModifiers())) {
                logger.debug("method is not public. clazz={}, method={}", clazz.getName(), method.getName());
                continue;
            }

            Expose expose = method.getAnnotation(Expose.class);

            if (!exposeAll && expose == null) {
                logger.debug("exposeAll is false and @Expose is not found. clazz={}, method={}", clazz.getName(), method.getName());
                continue;
            }

            String path = Context.PATH_DELIMITER + prefix + Context.PATH_DELIMITER + (expose == null || StringUtils.isBlank(expose.value()) ? method.getName() : expose.value());

            Class<?>[] parameterTypes = method.getParameterTypes();
            Type[] genericParameterTypes = method.getGenericParameterTypes();
            Annotation[][] parameterAnnotations = method.getParameterAnnotations();
            String[] parameterNames = parameterNameDiscoverer.getParameterNames(method);

            Map<String, Parameter> parameters = Maps.newLinkedHashMap();

            for (int i = 0; i < parameterTypes.length; i++) {
                parameters.put(parameterNames[i], new Parameter(genericParameterTypes[i], parameterTypes[i], parameterNames[i], parameterNames[i], true, parameterAnnotations[i], null, null));
            }

            MethodAction methodAction = new MethodAction(entry.getValue(), method, HttpMethod.POST, path, parameters);
            interceptorManager.addInterceptors(methodAction);

            logger.debug("[remote] {} => {}", new Object[]{path, methodAction.bean().getClass().getSimpleName() + "#" + methodAction.method().getName()});

            List<Action> actions = routes.get(path);

            if (actions == null) {
                actions = Lists.newArrayList();
            }

            actions.add(methodAction);
            routes.put(path, actions);
        }
    }
}
项目:spring    文件:CacheEvaluationContext.java   
CacheEvaluationContext(Object rootObject, Method method, Object[] args,
        ParameterNameDiscoverer paramDiscoverer) {

    super(rootObject, method, args, paramDiscoverer);
    this.unavailableVariables = new ArrayList<String>();
}
项目:jbase    文件:SpelKeyGenerator.java   
/**
 * @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;

}
项目:evernote-rest-webapp    文件:Application.java   
/**
 * To maximize the caching feature in name discoverer, inject as a bean instead of creating every time.
 */
@Bean
public ParameterNameDiscoverer parameterNameDiscoverer() {
    return new DefaultParameterNameDiscoverer();
}
项目:springmvc-wadlgen    文件:WadlGenerator.java   
private static List<String> getParameterNames(Method method) {
    ParameterNameDiscoverer paramNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    String[] parameterNames = paramNameDiscoverer.getParameterNames(method);
    return toList(parameterNames);
}
项目:haogrgr-test    文件:ParameterNameTest.java   
public static void main(String[] args) throws Exception {
    ParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer();

    Method declaredMethod = HttpUtils.class.getDeclaredMethod("getClient", HttpHost.class);

    String[] names = discoverer.getParameterNames(declaredMethod);

    System.out.println(names[0]);
}
项目:lams    文件:LocalValidatorFactoryBean.java   
/**
 * Set the ParameterNameDiscoverer to use for resolving method and constructor
 * parameter names if needed for message interpolation.
 * <p>Default is a {@link org.springframework.core.DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:lams    文件:InvocableHandlerMethod.java   
/**
 * Set the ParameterNameDiscoverer for resolving parameter names when needed
 * (e.g. default request attribute name).
 * <p>Default is a {@link org.springframework.core.DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:lams    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * Set the ParameterNameDiscoverer to use for resolving method parameter
 * names if needed (e.g. for parameter names of MBean operation methods).
 * <p>Default is a {@link DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:lams    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * Return the ParameterNameDiscoverer to use for resolving method parameter
 * names if needed (may be {@code null} in order to skip parameter detection).
 */
protected ParameterNameDiscoverer getParameterNameDiscoverer() {
    return this.parameterNameDiscoverer;
}
项目:lams    文件:AbstractAutowireCapableBeanFactory.java   
/**
 * Set the ParameterNameDiscoverer to use for resolving method parameter
 * names if needed (e.g. for constructor names).
 * <p>Default is a {@link DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:lams    文件:AbstractAutowireCapableBeanFactory.java   
/**
 * Return the ParameterNameDiscoverer to use for resolving method parameter
 * names if needed.
 */
protected ParameterNameDiscoverer getParameterNameDiscoverer() {
    return this.parameterNameDiscoverer;
}
项目:lams    文件:DependencyDescriptor.java   
/**
 * Initialize parameter name discovery for the underlying method parameter, if any.
 * <p>This method does not actually try to retrieve the parameter name at
 * this point; it just allows discovery to happen when the application calls
 * {@link #getDependencyName()} (if ever).
 */
public void initParameterNameDiscovery(ParameterNameDiscoverer parameterNameDiscoverer) {
    if (this.methodParameter != null) {
        this.methodParameter.initParameterNameDiscovery(parameterNameDiscoverer);
    }
}
项目:spring4-understanding    文件:InvocableHandlerMethod.java   
/**
 * Set the ParameterNameDiscoverer for resolving parameter names when needed
 * (e.g. default request attribute name).
 * <p>Default is a {@link org.springframework.core.DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}
项目:spring4-understanding    文件:AnnotationMethodHandlerAdapter.java   
/**
 * Set the ParameterNameDiscoverer to use for resolving method parameter
 * names if needed (e.g. for default attribute names).
 * <p>Default is a {@link org.springframework.core.DefaultParameterNameDiscoverer}.
 */
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
    this.parameterNameDiscoverer = parameterNameDiscoverer;
}