Java Code Examples for org.springframework.beans.BeanUtils#getPropertyDescriptors()
The following examples show how to use
org.springframework.beans.BeanUtils#getPropertyDescriptors() .
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: MigrateForm.java From jeecg with Apache License 2.0 | 6 votes |
public static <T> String generateUpdateSql(String tableName, Class<T> clazz, List<String> ignores){ StringBuffer updateSql = new StringBuffer("update " + tableName + " set "); String updateProperties = ""; PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor pd : pds) { if(null != ignores && ignores.size()>0){ if(ignores.contains(pd.getName())) continue; } if(pd.getName().toLowerCase().equals("id")){// || pd.getPropertyType().equals(List.class) continue; } if (pd.getWriteMethod() != null) { if(updateProperties.length()>0){ updateProperties += ","; } updateProperties += underscoreName(pd.getName()) + "=:" + pd.getName(); } } updateSql.append(updateProperties); updateSql.append(" where id=:id"); org.jeecgframework.core.util.LogUtil.info("generate updateSql for "+ clazz.getName() + ":" +updateSql.toString()); return updateSql.toString(); }
Example 2
Source File: BeanFilter.java From jdal with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Map<String, Object> getParameterMap() { PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(getClass()); Map<String, Object> map = new HashMap<String, Object>(); for (PropertyDescriptor pd : pds) { if (!ignoredProperties.contains(pd.getName())) try { map.put(pd.getName(), pd.getReadMethod().invoke(this, (Object[]) null)); } catch (Exception e) { log.error(e); } } return map; }
Example 3
Source File: BeanDefinitionDtoConverterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private BeanDefinition createBeanDefinitionByIntrospection(Object object, NamedBeanMap refs, ConversionService conversionService) { validate(object); GenericBeanDefinition def = new GenericBeanDefinition(); def.setBeanClass(object.getClass()); MutablePropertyValues propertyValues = new MutablePropertyValues(); for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(object.getClass())) { if (descriptor.getWriteMethod() != null) { try { Object value = descriptor.getReadMethod().invoke(object, (Object[]) null); if (value != null) { if ("id".equals(descriptor.getName())) { } else { propertyValues.addPropertyValue(descriptor.getName(), createMetadataElementByIntrospection(value, refs, conversionService)); } } } catch (Exception e) { // our contract says to ignore this property } } } def.setPropertyValues(propertyValues); return def; }
Example 4
Source File: MigrateForm.java From jeecg with Apache License 2.0 | 6 votes |
public static <T> String generateInsertSql(String tableName, Class<T> clazz, List<String> ignores){ StringBuffer insertSql = new StringBuffer("insert into " + tableName + "("); String tableField = ""; String clazzProperties=""; PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor pd : pds) { if(null != ignores && ignores.size()>0){ if(ignores.contains(pd.getName())) continue; } if (pd.getWriteMethod() != null) { if(tableField.length()>0 && clazzProperties.length()>0){ tableField += ","; clazzProperties += ","; } tableField += underscoreName(pd.getName()); clazzProperties += ":" + pd.getName(); } } insertSql.append(tableField); insertSql.append(") values("); insertSql.append(clazzProperties); insertSql.append(")"); org.jeecgframework.core.util.LogUtil.info("generate insertSql for "+ clazz.getName() + ":" +insertSql.toString()); return insertSql.toString(); }
Example 5
Source File: BeanPropertyRowMapper.java From effectivejava with Apache License 2.0 | 6 votes |
/** * Initialize the mapping metadata for the given class. * @param mappedClass the mapped class. */ protected void initialize(Class<T> mappedClass) { this.mappedClass = mappedClass; this.mappedFields = new HashMap<String, PropertyDescriptor>(); this.mappedProperties = new HashSet<String>(); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(mappedClass); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null) { this.mappedFields.put(pd.getName().toLowerCase(), pd); String underscoredName = underscoreName(pd.getName()); if (!pd.getName().toLowerCase().equals(underscoredName)) { this.mappedFields.put(underscoredName, pd); } this.mappedProperties.add(pd.getName()); } } }
Example 6
Source File: BeanPropertyRowMapper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Initialize the mapping metadata for the given class. * @param mappedClass the mapped class */ protected void initialize(Class<T> mappedClass) { this.mappedClass = mappedClass; this.mappedFields = new HashMap<String, PropertyDescriptor>(); this.mappedProperties = new HashSet<String>(); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(mappedClass); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null) { this.mappedFields.put(lowerCaseName(pd.getName()), pd); String underscoredName = underscoreName(pd.getName()); if (!lowerCaseName(pd.getName()).equals(underscoredName)) { this.mappedFields.put(underscoredName, pd); } this.mappedProperties.add(pd.getName()); } } }
Example 7
Source File: BeanFilter.java From jdal with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void clear() { PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(getClass()); for (PropertyDescriptor pd: pds) { if (!ignoredProperties.contains(pd.getName())) { try { pd.getWriteMethod().invoke(this, (Object) null); } catch (Exception e) { log.error("Error nullifing property: [" + pd.getName() + "]", e); } } } }
Example 8
Source File: BeanWrapperItem.java From jdal with Apache License 2.0 | 5 votes |
public BeanWrapperItem(Object bean, List<String> properties) { this.beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(bean); if (properties == null) { for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(bean.getClass())) this.properties.add(pd.getName()); } else { this.properties = properties; } }
Example 9
Source File: HbaseFindBuilder.java From springboot_cwenao with MIT License | 5 votes |
private void reflectBean(Class<T> tclazz) { tBean = BeanUtils.instantiate(tclazz); PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(tclazz); for (PropertyDescriptor p : propertyDescriptors) { if (p.getWriteMethod() != null) { this.fieldsMap.put(p.getName(), p); } } beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(tBean); }
Example 10
Source File: BeanResourceBundle.java From base-framework with Apache License 2.0 | 5 votes |
/** * 重写父类方法,将bean对象转换为map的key */ @Override public Enumeration<String> getKeys() { Vector<String> vector = new Vector<String>(); PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(bean.getClass()); //逐个遍历bean的属性 for (PropertyDescriptor pd : propertyDescriptors) { //如果该属性没有get/set方法,将不做转换 if ((pd.getWriteMethod() == null) || pd.getReadMethod() == null) { continue; } String key = pd.getName(); /* * 判断该属性是否能够添加到map中,判断条件如下: * 1.该属性必须存在include属性中 * 2.该属性不能存在exclude属性中 * 3.如果ignoreNullValue为true,该属性的值不能为null值 */ if (isIncludeProperty(key) && !isExcludeProperty(key)) { if (ignoreNullValue && ReflectionUtils.invokeGetterMethod(bean, key) == null) { continue; } vector.addElement(key); } } //返回能够转换为map的key值 return vector.elements(); }
Example 11
Source File: LanguageMetadataContributor.java From mPaaS with Apache License 2.0 | 5 votes |
private void multilingualProcess(PersistentClass pclazz, MetaEntityImpl entity, String name) { Class<?> clazz = ReflectUtil.classForName(pclazz.getClassName()); PropertyDescriptor[] descs = BeanUtils.getPropertyDescriptors(clazz); for (java.beans.PropertyDescriptor desc : descs) { // 判断是否要做多语言 if (name.equals(desc.getName())) { for (String lang : LangUtil.getSupportCountries()) { String propertyName = name + lang; MetaPropertyImpl langProp = new MetaPropertyImpl(); langProp.setShowType(ShowType.ALWAYS); langProp.setDynamic(true); langProp.setName(propertyName); SimpleValue simpleValue = (SimpleValue) pclazz.getProperty(name).getValue(); if (simpleValue.isLob()) { langProp.setType(MetaConstant.TYPE_RTF); } else { langProp.setType(MetaConstant.TYPE_STRING); } Column column = (Column) ((SimpleValue) pclazz.getProperty(name).getValue()).getConstraintColumns().get(0); if (StringUtils.isNotEmpty(column.getSqlType())) { HibernatePropertyFeature feature = new HibernatePropertyFeature(); feature.setColumnDefinition(column.getSqlType()); Map<String, Object> features = new HashMap<>(1); features.put(HibernatePropertyFeature.class.getName(), feature); langProp.setFeatures(features); } langProp.setLength(column.getLength()); parser.parse(langProp, pclazz); // 增加的字段标记为临时属性,不需要生成数据字典 entity.addTempProperty(propertyName); } } } }
Example 12
Source File: BeanPropertiesMapper.java From alfresco-mvc with Apache License 2.0 | 5 votes |
/** * Initialize the mapping metadata for the given class. * * @param mappedClass the mapped class. */ private void initialize(Class<T> mappedClass) { this.mappedClass = mappedClass; this.mappedFields = new HashMap<String, PropertyDescriptor>(); this.mappedProperties = new HashSet<String>(); this.mappedQNames = new HashMap<QName, PropertyDescriptor>(); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(mappedClass); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null) { this.mappedFields.put(pd.getName().toLowerCase(), pd); String prefixName = prefixName(pd.getName()); if (!pd.getName().toLowerCase().equals(prefixName)) { this.mappedFields.put(prefixName, pd); } this.mappedProperties.add(pd.getName()); String prefixedString = prefixName.replaceFirst("_", ":"); if (prefixedString.contains(":")) { try { QName qName = QName.createQName(prefixedString, namespaceService); if (dictionaryService.getProperty(qName) != null) { this.mappedQNames.put(qName, pd); } } catch (NamespaceException e) { LOGGER.warn("the property is not configured for this namespace", e); if (reportNamespaceException) { throw e; } } } } } afterInitialize(); }
Example 13
Source File: CopyUtil.java From stategen with GNU Affero General Public License v3.0 | 4 votes |
private static void mergeProperties(Object target,Object source, Class<?> editable, String... ignoreProperties) throws BeansException { Assert.notNull(source, "Source must not be null"); Assert.notNull(target, "Target must not be null"); Class<?> actualEditable = target.getClass(); if (editable != null) { if (!editable.isInstance(target)) { throw new IllegalArgumentException("Target class [" + target.getClass().getName() + "] not assignable to Editable class [" + editable.getName() + "]"); } actualEditable = editable; } PropertyDescriptor[] targetPds = BeanUtils.getPropertyDescriptors(actualEditable); List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null); for (PropertyDescriptor targetPd : targetPds) { Method targetWriteMethod = targetPd.getWriteMethod(); if (targetWriteMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) { PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(source.getClass(), targetPd.getName()); if (sourcePd != null) { Method sourceReadMethod = sourcePd.getReadMethod(); if (sourceReadMethod != null && ClassUtils.isAssignable(targetWriteMethod.getParameterTypes()[0], sourceReadMethod.getReturnType())) { try { if (!Modifier.isPublic(sourceReadMethod.getDeclaringClass().getModifiers())) { sourceReadMethod.setAccessible(true); } Object value = sourceReadMethod.invoke(source); if (!Modifier.isPublic(targetWriteMethod.getDeclaringClass().getModifiers())) { targetWriteMethod.setAccessible(true); } //只有当值不为空时,才copy if (value!=null){ targetWriteMethod.invoke(target, value); } } catch (Throwable ex) { throw new FatalBeanException( "Could not copy property '" + targetPd.getName() + "' from source to target", ex); } } } } } }
Example 14
Source File: CgformSqlController.java From jeecg with Apache License 2.0 | 4 votes |
private <T> void mergeMigrateInComponent(DBTable<T> dbTable) { Class<T> clazz = dbTable.getClass1(); if(null != clazz){ List<T> dataList = dbTable.getTableData(); if(null == dataList || dataList.size() < 1) return; Map<String, String> idMap = new HashMap<String, String>(); String id = ""; String countSql = ""; SqlParameterSource sqlParameterSource; List<Map<String, Object>> idList = new ArrayList<Map<String,Object>>(); for (T t : dataList) { ReflectHelper reflectHelper = new ReflectHelper(t); List<String> ignores = new ArrayList<String>(); ignores.add("class"); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor pd : pds) { if(null == reflectHelper.getMethodValue(pd.getName())){ ignores.add(pd.getName()); }else if(reflectHelper.isIgore(pd.getName())){ ignores.add(pd.getName()); } } if(t instanceof CgFormHeadPojo){ reflectHelper.setMethodValue("isDbsynch", "N"); } SqlInjectionUtil.filterContent(dbTable.getTableName()); id = (String) reflectHelper.getMethodValue("id"); countSql = "select id from "+ dbTable.getTableName() + " where id=?"; if(t instanceof CgFormHeadPojo){ countSql = "select id from "+ dbTable.getTableName() + " where table_name=?"; id = oConvertUtils.getString(reflectHelper.getMethodValue("tableName")); } idList = jdbcTemplate.queryForList(countSql, id); sqlParameterSource = MigrateForm.generateParameterMap(t, ignores); if(idList.size() > 0 && t instanceof CgFormHeadPojo){ idMap.put("id", oConvertUtils.getString(idList.get(0).get("id"))); namedJdbcTemplate.update("delete from cgform_field where table_id=:id", idMap); namedJdbcTemplate.update("delete from cgform_head where id=:id", idMap); namedJdbcTemplate.update(MigrateForm.generateInsertSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } else if(idList.size() > 0){ namedJdbcTemplate.update(MigrateForm.generateUpdateSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } else { namedJdbcTemplate.update(MigrateForm.generateInsertSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } } } }
Example 15
Source File: SpringSwaggerExtension.java From swagger-maven-plugin with Apache License 2.0 | 4 votes |
private List<Parameter> extractParametersFromModelAttributeAnnotation(Type type, Map<Class<?>, Annotation> annotations) { ModelAttribute modelAttribute = (ModelAttribute)annotations.get(ModelAttribute.class); if ((modelAttribute == null || !hasClassStartingWith(annotations.keySet(), "org.springframework.web.bind.annotation"))&& BeanUtils.isSimpleProperty(TypeUtils.getRawType(type, null))) { return Collections.emptyList(); } List<Parameter> parameters = new ArrayList<Parameter>(); Class<?> clazz = TypeUtils.getRawType(type, type); for (PropertyDescriptor propertyDescriptor : BeanUtils.getPropertyDescriptors(clazz)) { // Get all the valid setter methods inside the bean Method propertyDescriptorSetter = propertyDescriptor.getWriteMethod(); if (propertyDescriptorSetter != null) { ApiParam propertySetterApiParam = AnnotationUtils.findAnnotation(propertyDescriptorSetter, ApiParam.class); if (propertySetterApiParam == null) { // If we find a setter that doesn't have @ApiParam annotation, then skip it continue; } // Here we have a bean setter method that is annotted with @ApiParam, but we still // need to know what type of parameter to create. In order to do this, we look for // any annotation attached to the first method parameter of the setter fucntion. Annotation[][] parameterAnnotations = propertyDescriptorSetter.getParameterAnnotations(); if (parameterAnnotations == null || parameterAnnotations.length == 0) { continue; } Class parameterClass = propertyDescriptor.getPropertyType(); List<Parameter> propertySetterExtractedParameters = this.extractParametersFromAnnotation( parameterClass, toMap(Arrays.asList(parameterAnnotations[0]))); for (Parameter parameter : propertySetterExtractedParameters) { if (Strings.isNullOrEmpty(parameter.getName())) { parameter.setName(propertyDescriptor.getDisplayName()); } ParameterProcessor.applyAnnotations(new Swagger(), parameter, type, Lists.newArrayList(propertySetterApiParam)); } parameters.addAll(propertySetterExtractedParameters); } } return parameters; }
Example 16
Source File: PageQueryTemplate.java From mPass with Apache License 2.0 | 4 votes |
/** * 添加选择列,支持a.b.c,仅用于转vo的情况 */ private void appendSelectColumn4VO(QueryContextImpl<E, Tuple> context, String propName, List<MetaProperty> props, List<Selection<?>> selects, ViewInfo root) { Class<?> clazz = viewClass; ViewInfo current = root; int n = props.size() - 1; // 层级遍历 for (int i = 0; i < props.size(); i++) { MetaProperty prop = props.get(i); PropertyDescriptor desc = BeanUtils.getPropertyDescriptor(clazz, prop.getName()); if (desc == null || desc.getWriteMethod() == null || desc.getReadMethod() == null) { throw new ParamsNotValidException( StringHelper.join(propName, "对应的VO的属性不支持读/写")); } ViewInfo child = current.getOrAddChild(desc); current = child; if (prop.isCollection()) { // 列表对象 child.arrayElementType = getListActualType(clazz, desc); if (child.arrayElementType == null) { throw new ParamsNotValidException( StringHelper.join(propName, "无法获取列表的实际类型")); } clazz = child.arrayElementType; } else { // 单值对象 clazz = desc.getPropertyType(); } if (i == n) { // 最后一级 if (MetaConstant.isAssociation(prop.getType())) { // c是子对象,遍历对象下的属性 MetaEntity meta = MetaEntity.localEntity(prop.getType()); if (meta == null) { return; } PropertyDescriptor[] childDescs = BeanUtils .getPropertyDescriptors(clazz); for (PropertyDescriptor childDesc : childDescs) { if (childDesc.getWriteMethod() == null) { continue; } // 属性必须有在数据库中,并且不能是外键对象,显示类型允许在列表展现 String name = childDesc.getName(); MetaProperty childProp = meta.getProperty(name); if (childProp == null || childProp.getShowType() != ShowType.ALWAYS || MetaConstant .isAssociation(childProp.getType())) { continue; } // 追加子对象属性 child = current.getOrAddChild(childDesc); appendSelectAndLangColumn(context, childProp, StringHelper.join(propName, '.', name), selects, child); } } else { // c是普通属性,直接追加 if ("fdId".equals(propName)) { current.index = 0; } else { appendSelectAndLangColumn(context, prop, propName, selects, current); } } } } }
Example 17
Source File: ListBeanContainer.java From jdal with Apache License 2.0 | 4 votes |
private void initDefaultProperties() { for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(beanClass)) { this.properties.add(pd.getName()); this.propertyDescriptors.put(pd.getName(), pd); } }
Example 18
Source File: PropertiesEventUtils.java From youkefu with Apache License 2.0 | 4 votes |
public static List<PropertiesEvent> processPropertiesModify(HttpServletRequest request , Object newobj , Object oldobj,String... ignoreProperties){ List<PropertiesEvent> events = new ArrayList<PropertiesEvent>() ; // String[] fields = new String[]{"id" , "orgi" , "creater" ,"createtime" , "updatetime"} ; List<String> ignoreList = new ArrayList<String>(); ignoreList.addAll(Arrays.asList(fields)) ; if((ignoreProperties != null)){ ignoreList.addAll(Arrays.asList(ignoreProperties)); } PropertyDescriptor[] targetPds = BeanUtils.getPropertyDescriptors(newobj.getClass()); for (PropertyDescriptor targetPd : targetPds) { Method newReadMethod = targetPd.getReadMethod(); if (oldobj!=null && newReadMethod != null && (ignoreProperties == null || (!ignoreList.contains(targetPd.getName())))) { PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(oldobj.getClass(), targetPd.getName()); if (sourcePd != null && !targetPd.getName().equalsIgnoreCase("id")) { Method readMethod = sourcePd.getReadMethod(); if (readMethod != null) { try { Object newValue = readMethod.invoke(newobj); Object oldValue = readMethod.invoke(oldobj); if(newValue != null && !newValue.equals(oldValue)){ PropertiesEvent event = new PropertiesEvent(); event.setField(targetPd.getName()); event.setCreatetime(new Date()); event.setName(targetPd.getName()); event.setPropertity(targetPd.getName()); event.setOldvalue(oldValue!=null && oldValue.toString().length()<100 ? oldValue.toString() : null); event.setNewvalue(newValue!=null && newValue.toString().length()<100 ? newValue.toString() : null); if(request!=null && !StringUtils.isBlank(request.getParameter(targetPd.getName()+".text"))){ event.setTextvalue(request.getParameter(targetPd.getName()+".text")); } events.add(event) ; } } catch (Throwable ex) { throw new FatalBeanException( "Could not copy property '" + targetPd.getName() + "' from source to target", ex); } } } } } return events ; }
Example 19
Source File: CgformSqlController.java From jeewx with Apache License 2.0 | 4 votes |
private <T> void mergeMigrateInComponent(DBTable<T> dbTable) { Class<T> clazz = dbTable.getClass1(); if(null != clazz){ List<T> dataList = dbTable.getTableData(); if(null == dataList || dataList.size() < 1) return; Map<String, String> idMap = new HashMap<String, String>(); String id = ""; String countSql = ""; SqlParameterSource sqlParameterSource; List<Map<String, Object>> idList = new ArrayList<Map<String,Object>>(); for (T t : dataList) { ReflectHelper reflectHelper = new ReflectHelper(t); List<String> ignores = new ArrayList<String>(); ignores.add("class"); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor pd : pds) { if(null == reflectHelper.getMethodValue(pd.getName())){ ignores.add(pd.getName()); } } if(t instanceof CgFormHeadPojo){ reflectHelper.setMethodValue("isDbsynch", "N"); } id = (String) reflectHelper.getMethodValue("id"); countSql = "select id from "+ dbTable.getTableName() + " where id=?"; if(t instanceof CgFormHeadPojo){ countSql = "select id from "+ dbTable.getTableName() + " where table_name=?"; id = oConvertUtils.getString(reflectHelper.getMethodValue("tableName")); } idList = jdbcTemplate.queryForList(countSql, id); sqlParameterSource = MigrateForm.generateParameterMap(t, ignores); if(idList.size() > 0 && t instanceof CgFormHeadPojo){ idMap.put("id", oConvertUtils.getString(idList.get(0).get("id"))); namedJdbcTemplate.update("delete from cgform_field where table_id=:id", idMap); namedJdbcTemplate.update("delete from cgform_head where id=:id", idMap); namedJdbcTemplate.update(MigrateForm.generateInsertSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } else if(idList.size() > 0){ namedJdbcTemplate.update(MigrateForm.generateUpdateSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } else { namedJdbcTemplate.update(MigrateForm.generateInsertSql(dbTable.getTableName(), clazz, ignores), sqlParameterSource); } } } }
Example 20
Source File: AbstractReflectiveMBeanInfoAssembler.java From spring-analysis-note with MIT License | 4 votes |
/** * Iterate through all properties on the MBean class and gives subclasses * the chance to vote on the inclusion of both the accessor and mutator. * If a particular accessor or mutator is voted for inclusion, the appropriate * metadata is assembled and passed to the subclass for descriptor population. * @param managedBean the bean instance (might be an AOP proxy) * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the attribute metadata * @throws JMException in case of errors * @see #populateAttributeDescriptor */ @Override protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException { PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean)); List<ModelMBeanAttributeInfo> infos = new ArrayList<>(); for (PropertyDescriptor prop : props) { Method getter = prop.getReadMethod(); if (getter != null && getter.getDeclaringClass() == Object.class) { continue; } if (getter != null && !includeReadAttribute(getter, beanKey)) { getter = null; } Method setter = prop.getWriteMethod(); if (setter != null && !includeWriteAttribute(setter, beanKey)) { setter = null; } if (getter != null || setter != null) { // If both getter and setter are null, then this does not need exposing. String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing()); String description = getAttributeDescription(prop, beanKey); ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter); Descriptor desc = info.getDescriptor(); if (getter != null) { desc.setField(FIELD_GET_METHOD, getter.getName()); } if (setter != null) { desc.setField(FIELD_SET_METHOD, setter.getName()); } populateAttributeDescriptor(desc, getter, setter, beanKey); info.setDescriptor(desc); infos.add(info); } } return infos.toArray(new ModelMBeanAttributeInfo[0]); }