/** * Add property annotation metadata. * * @param name the property name * @param amd the annotation metadata * @return this builder */ protected BeanMetaDataBuilder addPropertyAnnotation(String name, AnnotationMetaData amd) { PropertyMetaData pmd = beanMetaData.getProperty(name); Set<AnnotationMetaData> annotations = pmd.getAnnotations(); if (annotations == null) { if (pmd instanceof AbstractFeatureMetaData == false) throw new IllegalArgumentException("PropertyMetaData is not AbstractFeatureMetaData instance: " + pmd); annotations = new HashSet<AnnotationMetaData>(); AbstractFeatureMetaData afmd = AbstractFeatureMetaData.class.cast(pmd); afmd.setAnnotations(annotations); } annotations.add(amd); return this; }
/** * Update property annotations * * @param repository the repository * @param classloader the classloader * @param mutable the mutable * @param context the context * @param propertyMetaData the property * @param beanInfo the bean info * @param add true for add, false for remove */ private void updatePropertyAnnotations(MutableMetaDataRepository repository, ClassLoader classloader, ComponentMutableMetaData mutable, KernelControllerContext context, PropertyMetaData propertyMetaData, BeanInfo beanInfo, boolean add) { Set<AnnotationMetaData> propertyAnnotations = propertyMetaData.getAnnotations(); if (propertyAnnotations == null || propertyAnnotations.size() == 0) return; PropertyInfo propertyInfo = beanInfo.getProperty(propertyMetaData.getName()); // method annotations MethodInfo methodInfo = propertyInfo.getGetter(); if (methodInfo != null) updateAnnotations(repository, classloader, mutable, context, methodInfo, propertyAnnotations, add); methodInfo = propertyInfo.getSetter(); if (methodInfo != null) updateAnnotations(repository, classloader, mutable, context, methodInfo, propertyAnnotations, add); // field annotations FieldInfo fieldInfo = propertyInfo.getFieldInfo(); if (fieldInfo != null) updateAnnotations(repository, classloader, mutable, context, fieldInfo, propertyAnnotations, add); }