本文整理汇总了Java中org.jgroups.annotations.Property.name方法的典型用法代码示例。如果您正苦于以下问题:Java Property.name方法的具体用法?Java Property.name怎么用?Java Property.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.annotations.Property
的用法示例。
在下文中一共展示了Property.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyName
import org.jgroups.annotations.Property; //导入方法依赖的package包/类
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 ;
}
示例2: findFields
import org.jgroups.annotations.Property; //导入方法依赖的package包/类
protected void findFields() {
// traverse class hierarchy and find all annotated fields
for(Class<?> clazz=obj.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));
}
}
}
}
示例3: checkDependencyReferencesPresent
import org.jgroups.annotations.Property; //导入方法依赖的package包/类
static void checkDependencyReferencesPresent(List<AccessibleObject> objects, Map<String, AccessibleObject> props) {
// iterate overall properties marked by @Property
for(int i = 0; i < objects.size(); i++) {
// get the Property annotation
AccessibleObject ao = objects.get(i) ;
Property annotation = ao.getAnnotation(Property.class) ;
if (annotation == null) {
throw new IllegalArgumentException("@Property annotation is required for checking dependencies;" +
" annotation is missing for Field/Method " + ao.toString()) ;
}
String dependsClause = annotation.dependsUpon() ;
if (dependsClause.trim().isEmpty())
continue ;
// split dependsUpon specifier into tokens; trim each token; search for token in list
StringTokenizer st = new StringTokenizer(dependsClause, ",") ;
while (st.hasMoreTokens()) {
String token = st.nextToken().trim() ;
// check that the string representing a property name is in the list
boolean found = false ;
Set<String> keyset = props.keySet();
for (Iterator<String> iter = keyset.iterator(); iter.hasNext();) {
if (iter.next().equals(token)) {
found = true ;
break ;
}
}
if (!found) {
throw new IllegalArgumentException("@Property annotation " + annotation.name() +
" has an unresolved dependsUpon property: " + token) ;
}
}
}
}
示例4: exposeManagedAttribute
import org.jgroups.annotations.Property; //导入方法依赖的package包/类
protected void exposeManagedAttribute(Method method) {
String methodName=method.getName();
ManagedAttribute attr_annotation=method.getAnnotation(ManagedAttribute.class);
Property prop=method.getAnnotation(Property.class);
boolean expose_prop=prop != null && prop.exposeAsManagedAttribute();
boolean expose=attr_annotation != null || expose_prop;
if(!expose)
return;
boolean writable=(prop != null && prop.writable()) || (attr_annotation != null && attr_annotation.writable());
// Is name of @ManagedAttributed or @Property used?
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();
else {
// getFooBar() --> foo_bar
attr_name=Util.methodNameToAttributeName(methodName);
if(!atts.containsKey(attr_name)) {
// hmm, maybe we need to look for an attribute fooBar
String tmp=Util.methodNameToJavaAttributeName(methodName);
if(atts.containsKey(tmp))
attr_name=tmp;
}
}
String descr=attr_annotation != null ? attr_annotation.description() : prop != null? prop.description() : null;
AttributeEntry attr=atts.get(attr_name);
if(attr != null) {
if(isSetMethod(method)) {
if(attr.setter != null) {
if(log.isWarnEnabled())
log.warn("setter for \"" + attr_name + "\" is already defined (new method=" + method.getName() + ")");
}
else
attr.setter=new MethodAccessor(method, obj);
}
else {
if(attr.getter != null) {
if(log.isWarnEnabled())
log.warn("getter for \"" + attr_name + "\" is already defined (new method=" + method.getName() + ")");
}
else
attr.getter=new MethodAccessor(method, obj);
}
}
else { // create a new entry in atts
boolean is_setter=isSetMethod(method);
String type=is_setter? method.getParameterTypes()[0].getCanonicalName() : method.getReturnType().getCanonicalName();
MBeanAttributeInfo info=new MBeanAttributeInfo(attr_name, type, descr, true, writable, methodName.startsWith("is"));
AttributeEntry entry=new AttributeEntry(Util.methodNameToAttributeName(methodName), info);
if(is_setter)
entry.setter(new MethodAccessor(method, obj));
else
entry.getter(new MethodAccessor(method, obj));
atts.put(attr_name, entry);
}
}