public static String getPropertyName(Method method) throws IllegalArgumentException { if (method == null) { throw new IllegalArgumentException("Cannot get property name: field is null") ; } Property annotation=method.getAnnotation(Property.class); if (annotation == null) { throw new IllegalArgumentException("Cannot get property name for method " + method.getName() + " which is not annotated with @Property") ; } String propertyName=!annotation.name().isEmpty()? annotation.name() : method.getName(); propertyName=Util.methodNameToAttributeName(propertyName); return propertyName ; }
public static String getPropertyName(Field field, Map<String,String> props) throws IllegalArgumentException { if (field == null) { throw new IllegalArgumentException("Cannot get property name: field is null") ; } if (props == null) { throw new IllegalArgumentException("Cannot get property name: properties map is null") ; } Property annotation=field.getAnnotation(Property.class); if (annotation == null) { throw new IllegalArgumentException("Cannot get property name for field " + field.getName() + " which is not annotated with @Property") ; } String propertyName=field.getName(); if(props.containsKey(annotation.name())) { propertyName=annotation.name(); boolean isDeprecated=!annotation.deprecatedMessage().isEmpty(); if(isDeprecated) log.warn(Util.getMessage("Deprecated"), propertyName, annotation.deprecatedMessage()); } return propertyName ; }
throw new IllegalArgumentException("@Property annotation " + annotation.name() + " has an unresolved dependsUpon property: " + token) ;
desc="n/a"; String name = annotation.name(); if (name.length() < 1) { name = Util.methodNameToAttributeName(method.getName());
protected void findFields(Object instance) { // traverse class hierarchy and find all annotated fields for(Class<?> clazz=instance.getClass(); clazz != null && clazz != Object.class; clazz=clazz.getSuperclass()) { Field[] fields=clazz.getDeclaredFields(); for(Field field: fields) { ManagedAttribute attr=field.getAnnotation(ManagedAttribute.class); Property prop=field.getAnnotation(Property.class); boolean expose_prop=prop != null && prop.exposeAsManagedAttribute(); boolean expose=attr != null || expose_prop; if(expose) { String fieldName=attr != null? attr.name() : (prop != null? prop.name() : null); if(fieldName != null && fieldName.trim().isEmpty()) fieldName=field.getName(); String descr=attr != null? attr.description() : prop.description(); boolean writable=attr != null? attr.writable() : prop.writable(); MBeanAttributeInfo info=new MBeanAttributeInfo(fieldName, field.getType().getCanonicalName(), descr, true, !Modifier.isFinal(field.getModifiers()) && writable, false); atts.put(fieldName, new AttributeEntry(field.getName(), info)); } } } }
String attr_name=attr_annotation != null? attr_annotation.name() : prop != null? prop.name() : null; if(attr_name != null && !attr_name.trim().isEmpty()) attr_name=attr_name.trim(); String method_name=attr_annotation != null? attr_annotation.name() : prop != null? prop.name() : null; if(method_name != null && !method_name.trim().isEmpty()) method_name=method_name.trim();
@Override public String getName() { if (this.accessible.isAnnotationPresent(ManagedAttribute.class)) { String name = this.accessible.getAnnotation(ManagedAttribute.class).name(); if (!name.isEmpty()) return name; } if (this.accessible.isAnnotationPresent(Property.class)) { String name = this.accessible.getAnnotation(Property.class).name(); if (!name.isEmpty()) return name; } return null; }
final String property; final Property r = field.getAnnotation(Property.class); boolean annotationRedefinesName = !r.name().isEmpty() && r.deprecatedMessage().isEmpty(); if (annotationRedefinesName) { property = r.name(); } else { property = field.getName(); if (annotation.name().length() < 1) { name = Util.methodNameToAttributeName(method.getName()); } else { name = annotation.name();
String attr_name=attr_annotation != null? attr_annotation.name() : prop != null? prop.name() : null; if(attr_name != null && !attr_name.trim().isEmpty()) attr_name=attr_name.trim();
public static String getPropertyName(Method method) throws IllegalArgumentException { if (method == null) { throw new IllegalArgumentException("Cannot get property name: field is null") ; } Property annotation=method.getAnnotation(Property.class); if (annotation == null) { throw new IllegalArgumentException("Cannot get property name for method " + method.getName() + " which is not annotated with @Property") ; } String propertyName=!annotation.name().isEmpty()? annotation.name() : method.getName(); propertyName=Util.methodNameToAttributeName(propertyName); return propertyName ; }
public static String getPropertyName(Field field, Map<String,String> props) throws IllegalArgumentException { if (field == null) { throw new IllegalArgumentException("Cannot get property name: field is null") ; } if (props == null) { throw new IllegalArgumentException("Cannot get property name: properties map is null") ; } Property annotation=field.getAnnotation(Property.class); if (annotation == null) { throw new IllegalArgumentException("Cannot get property name for field " + field.getName() + " which is not annotated with @Property") ; } String propertyName=field.getName(); if(props.containsKey(annotation.name())) { propertyName=annotation.name(); boolean isDeprecated=!annotation.deprecatedMessage().isEmpty(); if(isDeprecated) log.warn(Util.getMessage("Deprecated"), propertyName, annotation.deprecatedMessage()); } return propertyName ; }
Introspector(org.jgroups.conf.ProtocolConfiguration config) { String name = config.getProtocolName(); try { this.protocolClass = config.getClassLoader().loadClass(name).asSubclass(Protocol.class); PrivilegedAction<Void> action = () -> { Class<?> targetClass = Introspector.this.protocolClass; while (Protocol.class.isAssignableFrom(targetClass)) { for (Method method: targetClass.getDeclaredMethods()) { if (method.isAnnotationPresent(Property.class)) { String property = method.getAnnotation(Property.class).name(); if (!property.isEmpty()) { Introspector.this.properties.add(property); } } } for (Field field: targetClass.getDeclaredFields()) { if (field.isAnnotationPresent(Property.class)) { String property = field.getAnnotation(Property.class).name(); Introspector.this.properties.add(!property.isEmpty() ? property : field.getName()); } } targetClass = targetClass.getSuperclass(); } return null; }; WildFlySecurityManager.doChecked(action); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
throw new IllegalArgumentException("@Property annotation " + annotation.name() + " has an unresolved dependsUpon property: " + token) ;
desc="n/a"; String name = annotation.name(); if (name.length() < 1) { name = Util.methodNameToAttributeName(method.getName());
protected void findFields(Object instance) { // traverse class hierarchy and find all annotated fields for(Class<?> clazz=instance.getClass(); clazz != null && clazz != Object.class; clazz=clazz.getSuperclass()) { Field[] fields=clazz.getDeclaredFields(); for(Field field: fields) { ManagedAttribute attr=field.getAnnotation(ManagedAttribute.class); Property prop=field.getAnnotation(Property.class); boolean expose_prop=prop != null && prop.exposeAsManagedAttribute(); boolean expose=attr != null || expose_prop; if(expose) { String fieldName=attr != null? attr.name() : (prop != null? prop.name() : null); if(fieldName != null && fieldName.trim().isEmpty()) fieldName=field.getName(); String descr=attr != null? attr.description() : prop.description(); boolean writable=attr != null? attr.writable() : prop.writable(); MBeanAttributeInfo info=new MBeanAttributeInfo(fieldName, field.getType().getCanonicalName(), descr, true, !Modifier.isFinal(field.getModifiers()) && writable, false); atts.put(fieldName, new AttributeEntry(field.getName(), info)); } } } }
@Override public String getName() { if (this.accessible.isAnnotationPresent(ManagedAttribute.class)) { String name = this.accessible.getAnnotation(ManagedAttribute.class).name(); if (!name.isEmpty()) return name; } if (this.accessible.isAnnotationPresent(Property.class)) { String name = this.accessible.getAnnotation(Property.class).name(); if (!name.isEmpty()) return name; } return null; }
@Override public String getName() { if (this.accessible.isAnnotationPresent(ManagedAttribute.class)) { String name = this.accessible.getAnnotation(ManagedAttribute.class).name(); if (!name.isEmpty()) return name; } if (this.accessible.isAnnotationPresent(Property.class)) { String name = this.accessible.getAnnotation(Property.class).name(); if (!name.isEmpty()) return name; } return null; }