本文整理汇总了Java中org.jgroups.util.Util.setField方法的典型用法代码示例。如果您正苦于以下问题:Java Util.setField方法的具体用法?Java Util.setField怎么用?Java Util.setField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.util.Util
的用法示例。
在下文中一共展示了Util.setField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyFields
import org.jgroups.util.Util; //导入方法依赖的package包/类
/** Copies state from main-channel to this fork-channel */
protected void copyFields() {
for(Field field: copied_fields) {
Object value=Util.getField(field,main_channel);
Util.setField(field, this, value);
}
}
示例2: setValues
import org.jgroups.util.Util; //导入方法依赖的package包/类
public Protocol setValues(Map<String,Object> values) {
if(values == null)
return this;
for(Map.Entry<String,Object> entry: values.entrySet()) {
String attrname=entry.getKey();
Object value=entry.getValue();
Field field=Util.getField(getClass(), attrname);
if(field != null) {
Util.setField(field, this, value);
}
}
return this;
}
示例3: setValue
import org.jgroups.util.Util; //导入方法依赖的package包/类
public Protocol setValue(String name, Object value) {
if(name == null || value == null)
return this;
Field field=Util.getField(getClass(), name);
if(field == null)
throw new IllegalArgumentException("field \"" + name + "\n not found");
Property prop=field.getAnnotation(Property.class);
if(prop != null) {
String deprecated_msg=prop.deprecatedMessage();
if(deprecated_msg != null && !deprecated_msg.isEmpty())
log.warn("Field " + getName() + "." + name + " is deprecated: " + deprecated_msg);
}
Util.setField(field, this, value);
return this;
}
示例4: resolveAndAssignField
import org.jgroups.util.Util; //导入方法依赖的package包/类
public static void resolveAndAssignField(Object obj, Field field, Map<String,String> props) throws Exception {
Property annotation=field.getAnnotation(Property.class);
if(annotation != null) {
String propertyName = PropertyHelper.getPropertyName(field, props) ;
String propertyValue=props.get(propertyName);
// if there is a systemProperty attribute defined in the annotation, set the property value from the system property
// only do this if the property value hasn't yet been set
if(propertyValue == null) {
String tmp=grabSystemProp(field.getAnnotation(Property.class));
if(tmp != null)
propertyValue=tmp;
}
if(propertyName != null && propertyValue != null) {
String deprecated_msg=annotation.deprecatedMessage();
if(deprecated_msg != null && !deprecated_msg.isEmpty()) {
log.warn(Util.getMessage("Deprecated"), field.getDeclaringClass().getSimpleName() + "." + field.getName(),
deprecated_msg);
}
}
if(propertyValue != null || !PropertyHelper.usesDefaultConverter(field)){
Object converted=null;
try {
converted=PropertyHelper.getConvertedValue(obj, field, props, propertyValue, true);
if(converted != null)
Util.setField(field, obj, converted);
}
catch(Exception e) {
String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
throw new Exception("Property assignment of " + propertyName + " in "
+ name + " with original property value " + propertyValue + " and converted to " + converted
+ " could not be assigned", e);
}
}
props.remove(propertyName);
}
}
示例5: nullFields
import org.jgroups.util.Util; //导入方法依赖的package包/类
protected void nullFields() {
for(Field field: copied_fields)
Util.setField(field, this, null);
}
示例6: setDefaultValues
import org.jgroups.util.Util; //导入方法依赖的package包/类
public static void setDefaultValues(List<Protocol> protocols, StackType ip_version) throws Exception {
InetAddress default_ip_address=Util.getNonLoopbackAddress();
if(default_ip_address == null) {
log.warn(Util.getMessage("OnlyLoopbackFound"), ip_version);
default_ip_address=Util.getLocalhost(ip_version);
}
for(Protocol protocol : protocols) {
String protocolName=protocol.getName();
//traverse class hierarchy and find all annotated fields and add them to the list if annotated
Field[] fields=Util.getAllDeclaredFieldsWithAnnotations(protocol.getClass(), Property.class);
for(int j=0; j < fields.length; j++) {
// get the default value for the field - check for InetAddress types
if(InetAddressInfo.isInetAddressRelated(protocol, fields[j])) {
Object propertyValue=getValueFromProtocol(protocol, fields[j]);
if(propertyValue == null) {
// add to collection of @Properties with no user specified value
Property annotation=fields[j].getAnnotation(Property.class);
String defaultValue=ip_version == StackType.IPv4? annotation.defaultValueIPv4() : annotation.defaultValueIPv6();
if(defaultValue != null && !defaultValue.isEmpty()) {
// condition for invoking converter
Object converted=null;
try {
if(defaultValue.equalsIgnoreCase(Global.NON_LOOPBACK_ADDRESS))
converted=default_ip_address;
else
converted=PropertyHelper.getConvertedValue(protocol, fields[j], defaultValue, true);
if(converted != null)
Util.setField(fields[j], protocol, converted);
}
catch(Exception e) {
throw new Exception("default could not be assigned for field " + fields[j].getName() + " in "
+ protocolName + " with default value " + defaultValue, e);
}
log.debug("set property " + protocolName + "." + fields[j].getName() + " to default value " + converted);
}
}
}
}
}
}
示例7: setBindAddress
import org.jgroups.util.Util; //导入方法依赖的package包/类
private static void setBindAddress(Protocol protocol, InetAddress bind_addr) throws Exception {
Field f=Util.getField(protocol.getClass(), "bind_addr");
Util.setField(f, protocol, bind_addr) ;
}