/** * Find a JavaBeans {@code PropertyDescriptor} for the given method, * with the method either being the read method or the write method for * that bean property. * @param method the method to find a corresponding PropertyDescriptor for, * introspecting its declaring class * @return the corresponding PropertyDescriptor, or {@code null} if none * @throws BeansException if PropertyDescriptor lookup fails */ @Nullable public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException { return findPropertyForMethod(method, method.getDeclaringClass()); }
/** * Find a JavaBeans {@code PropertyDescriptor} for the given method, * with the method either being the read method or the write method for * that bean property. * @param method the method to find a corresponding PropertyDescriptor for, * introspecting its declaring class * @return the corresponding PropertyDescriptor, or {@code null} if none * @throws BeansException if PropertyDescriptor lookup fails */ @Nullable public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException { return findPropertyForMethod(method, method.getDeclaringClass()); }
/** * 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); }
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Method bridgedMethod = findBridgedMethod(method); if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) { return; } Reference reference = findAnnotation(bridgedMethod, Reference.class); if (reference != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) { if (Modifier.isStatic(method.getModifiers())) { if (logger.isWarnEnabled()) { logger.warn("@Reference annotation is not supported on static methods: " + method); } return; } if (method.getParameterTypes().length == 0) { if (logger.isWarnEnabled()) { logger.warn("@Reference annotation should only be used on methods with parameters: " + method); } } PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass); elements.add(new ReferenceMethodElement(method, pd, reference)); } } });
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Method bridgedMethod = findBridgedMethod(method); if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) { return; } Reference reference = findAnnotation(bridgedMethod, Reference.class); if (reference != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) { if (Modifier.isStatic(method.getModifiers())) { if (logger.isWarnEnabled()) { logger.warn("@Reference annotation is not supported on static methods: " + method); } return; } if (method.getParameterTypes().length == 0) { if (logger.isWarnEnabled()) { logger.warn("@Reference annotation should only be used on methods with parameters: " + method); } } PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass); elements.add(new ReferenceMethodElement(method, pd, reference)); } } });
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Method bridgedMethod = findBridgedMethod(method); if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) { return; } A annotation = findAnnotation(bridgedMethod, getAnnotationType()); if (annotation != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) { if (Modifier.isStatic(method.getModifiers())) { if (logger.isWarnEnabled()) { logger.warn("@" + getAnnotationType().getSimpleName() + " annotation is not supported on static methods: " + method); } return; } if (method.getParameterTypes().length == 0) { if (logger.isWarnEnabled()) { logger.warn("@" + getAnnotationType().getSimpleName() + " annotation should only be used on methods with parameters: " + method); } } PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass); elements.add(new AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement(method, pd, annotation)); } } });
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Method bridgedMethod = findBridgedMethod(method); if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) { return; } A annotation = findAnnotation(bridgedMethod, getAnnotationType()); if (annotation != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) { if (Modifier.isStatic(method.getModifiers())) { if (logger.isWarnEnabled()) { logger.warn("@" + getAnnotationType().getSimpleName() + " annotation is not supported on static methods: " + method); } return; } if (method.getParameterTypes().length == 0) { if (logger.isWarnEnabled()) { logger.warn("@" + getAnnotationType().getSimpleName() + " annotation should only be used on methods with parameters: " + method); } } PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass); elements.add(new AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement(method, pd, annotation)); } } });
/** * 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); }
throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new PersistenceElement(method, bridgedMethod, pd));
throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new WebServiceRefElement(method, bridgedMethod, pd)); throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new EjbRefElement(method, bridgedMethod, pd)); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new ResourceElement(method, bridgedMethod, pd));
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new AutowiredMethodElement(method, required, pd));
throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new WebServiceRefElement(method, bridgedMethod, pd)); throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new EjbRefElement(method, bridgedMethod, pd)); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new ResourceElement(method, bridgedMethod, pd));
/** * 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(); } }
throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new PersistenceElement(method, bridgedMethod, pd));
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); currElements.add(new AutowiredMethodElement(method, required, pd));
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null && ((method.equals(pd.getReadMethod()) && includeReadAttribute(method, beanKey)) || (method.equals(pd.getWriteMethod()) && includeWriteAttribute(method, beanKey)))) {
/** * 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(); } }
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null && ((method.equals(pd.getReadMethod()) && includeReadAttribute(method, beanKey)) || (method.equals(pd.getWriteMethod()) && includeWriteAttribute(method, beanKey)))) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { result = invokeAttribute(pd, invocation);
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if (pd != null) { result = invokeAttribute(pd, invocation);