Java Code Examples for org.springframework.beans.BeanUtils#findPropertyForMethod()
The following examples show how to use
org.springframework.beans.BeanUtils#findPropertyForMethod() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataMBeanInfoAssembler.java From spring-analysis-note with MIT License | 6 votes |
/** * Retrieves the description for the supplied {@code Method} from the * metadata. Uses the method name is no description is present in the metadata. */ @Override protected String getOperationDescription(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { ManagedAttribute ma = obtainAttributeSource().getManagedAttribute(method); if (ma != null && StringUtils.hasText(ma.getDescription())) { return ma.getDescription(); } ManagedMetric metric = obtainAttributeSource().getManagedMetric(method); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return method.getName(); } else { ManagedOperation mo = obtainAttributeSource().getManagedOperation(method); if (mo != null && StringUtils.hasText(mo.getDescription())) { return mo.getDescription(); } return method.getName(); } }
Example 2
Source File: MetadataMBeanInfoAssembler.java From java-technology-stack with MIT License | 6 votes |
/** * Retrieves the description for the supplied {@code Method} from the * metadata. Uses the method name is no description is present in the metadata. */ @Override protected String getOperationDescription(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { ManagedAttribute ma = obtainAttributeSource().getManagedAttribute(method); if (ma != null && StringUtils.hasText(ma.getDescription())) { return ma.getDescription(); } ManagedMetric metric = obtainAttributeSource().getManagedMetric(method); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return method.getName(); } else { ManagedOperation mo = obtainAttributeSource().getManagedOperation(method); if (mo != null && StringUtils.hasText(mo.getDescription())) { return mo.getDescription(); } return method.getName(); } }
Example 3
Source File: MetadataMBeanInfoAssembler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Retrieves the description for the supplied {@code Method} from the * metadata. Uses the method name is no description is present in the metadata. */ @Override protected String getOperationDescription(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { ManagedAttribute ma = this.attributeSource.getManagedAttribute(method); if (ma != null && StringUtils.hasText(ma.getDescription())) { return ma.getDescription(); } ManagedMetric metric = this.attributeSource.getManagedMetric(method); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return method.getName(); } else { ManagedOperation mo = this.attributeSource.getManagedOperation(method); if (mo != null && StringUtils.hasText(mo.getDescription())) { return mo.getDescription(); } return method.getName(); } }
Example 4
Source File: MetadataMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Retrieves the description for the supplied {@code Method} from the * metadata. Uses the method name is no description is present in the metadata. */ @Override protected String getOperationDescription(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { ManagedAttribute ma = this.attributeSource.getManagedAttribute(method); if (ma != null && StringUtils.hasText(ma.getDescription())) { return ma.getDescription(); } ManagedMetric metric = this.attributeSource.getManagedMetric(method); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return method.getName(); } else { ManagedOperation mo = this.attributeSource.getManagedOperation(method); if (mo != null && StringUtils.hasText(mo.getDescription())) { return mo.getDescription(); } return method.getName(); } }
Example 5
Source File: MetadataMBeanInfoAssembler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Votes on the inclusion of an operation. * @param method the operation method * @param beanKey the key associated with the MBean in the beans map * @return whether the method has the appropriate metadata */ @Override protected boolean includeOperation(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { if (hasManagedAttribute(method)) { return true; } } return hasManagedOperation(method); }
Example 6
Source File: MetadataMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Votes on the inclusion of an operation. * @param method the operation method * @param beanKey the key associated with the MBean in the beans map * @return whether the method has the appropriate metadata */ @Override protected boolean includeOperation(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { if (hasManagedAttribute(method)) { return true; } } return hasManagedOperation(method); }
Example 7
Source File: AnnotationMBeanInfoAssembler.java From cuba with Apache License 2.0 | 5 votes |
/** * Retrieves the description for the supplied {@code Method} from the * metadata. Uses the method name is no description is present in the metadata. */ @Override @Nonnull protected String getOperationDescription(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); Method resolvedMethod = findJmxMethod(method, beanKey); if (resolvedMethod == null) { throw new RuntimeException(String.format("Unable to find JMX method %s in %s", method, beanKey)); } if (pd != null) { ManagedAttribute ma = this.attributeSource.getManagedAttribute(resolvedMethod); if (ma != null && StringUtils.hasText(ma.getDescription())) { return ma.getDescription(); } ManagedMetric metric = this.attributeSource.getManagedMetric(resolvedMethod); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } } ManagedOperation mo = this.attributeSource.getManagedOperation(resolvedMethod); if (mo != null && StringUtils.hasText(mo.getDescription())) { return mo.getDescription(); } return ""; // no operation description by default }
Example 8
Source File: CssQueryMethodInterceptor.java From mica with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable @Override public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { // 如果是 toString eq 等方法都不准确,故直接返回死值 if (ReflectionUtils.isObjectMethod(method)) { return methodProxy.invokeSuper(object, args); } // 非 bean 方法 PropertyDescriptor propertyDescriptor = BeanUtils.findPropertyForMethod(method, clazz); if (propertyDescriptor == null) { return methodProxy.invokeSuper(object, args); } // 非 read 的方法,只处理 get 方法 is if (!method.equals(propertyDescriptor.getReadMethod())) { return methodProxy.invokeSuper(object, args); } // 兼容 lombok bug 强制首字母小写: https://github.com/rzwitserloot/lombok/issues/1861 String fieldName = StringUtil.firstCharToLower(propertyDescriptor.getDisplayName()); Field field = clazz.getDeclaredField(fieldName); if (field == null) { return methodProxy.invokeSuper(object, args); } CssQuery cssQuery = field.getAnnotation(CssQuery.class); // 没有注解,不代理 if (cssQuery == null) { return methodProxy.invokeSuper(object, args); } Class<?> returnType = method.getReturnType(); boolean isColl = Collection.class.isAssignableFrom(returnType); String cssQueryValue = cssQuery.value(); // 是否为 bean 中 bean boolean isInner = cssQuery.inner(); if (isInner) { return proxyInner(cssQueryValue, method, returnType, isColl); } Object proxyValue = proxyValue(cssQueryValue, cssQuery, returnType, isColl); if (String.class.isAssignableFrom(returnType)) { return proxyValue; } // 用于读取 field 上的注解 TypeDescriptor typeDescriptor = new TypeDescriptor(field); return ConvertUtil.convert(proxyValue, typeDescriptor); }
Example 9
Source File: ElasticsearchIndexInitializer.java From staccato with Apache License 2.0 | 4 votes |
private String getBeanName(Method method) { PropertyDescriptor p = BeanUtils.findPropertyForMethod(method); return p.getName(); // Assume the method starts with either get or is. //return Introspector.decapitalize(methodName.substring(methodName.startsWith("is") ? 2 : 3)); }
Example 10
Source File: MetadataMBeanInfoAssembler.java From spring-analysis-note with MIT License | 2 votes |
/** * Votes on the inclusion of an operation. * @param method the operation method * @param beanKey the key associated with the MBean in the beans map * @return whether the method has the appropriate metadata */ @Override protected boolean includeOperation(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); return (pd != null && hasManagedAttribute(method)) || hasManagedOperation(method); }
Example 11
Source File: MetadataMBeanInfoAssembler.java From java-technology-stack with MIT License | 2 votes |
/** * Votes on the inclusion of an operation. * @param method the operation method * @param beanKey the key associated with the MBean in the beans map * @return whether the method has the appropriate metadata */ @Override protected boolean includeOperation(Method method, String beanKey) { PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); return (pd != null && hasManagedAttribute(method)) || hasManagedOperation(method); }