本文整理汇总了Java中org.jgroups.annotations.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.jgroups.annotations包,在下文中一共展示了Property类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findMethods
import org.jgroups.annotations.Property; //导入依赖的package包/类
protected void findMethods() {
// find all methods but don't include methods from Object class
List<Method> methods = new ArrayList<>(Arrays.asList(obj.getClass().getMethods()));
methods.removeAll(OBJECT_METHODS);
for(Method method: methods) {
// does method have @ManagedAttribute annotation?
if(method.isAnnotationPresent(ManagedAttribute.class) || method.isAnnotationPresent(Property.class)) {
exposeManagedAttribute(method);
}
//or @ManagedOperation
else if (method.isAnnotationPresent(ManagedOperation.class) || expose_all){
ManagedOperation op=method.getAnnotation(ManagedOperation.class);
ops.add(new MBeanOperationInfo(op != null? op.description() : "",method));
}
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:ResourceDMBean.java
示例2: getInetAddresses
import org.jgroups.annotations.Property; //导入依赖的package包/类
public static List<InetAddress> getInetAddresses(List<Protocol> protocols) throws Exception {
List<InetAddress> retval=new LinkedList<>();
// collect InetAddressInfo
for(Protocol protocol : protocols) {
//traverse class hierarchy and find all annotated fields and add them to the list if annotated
for(Class<?> clazz=protocol.getClass(); clazz != null; clazz=clazz.getSuperclass()) {
Field[] fields=clazz.getDeclaredFields();
for(int j=0; j < fields.length; j++) {
if(fields[j].isAnnotationPresent(Property.class)) {
if(InetAddressInfo.isInetAddressRelated(protocol, fields[j])) {
Object value=getValueFromProtocol(protocol, fields[j]);
if(value instanceof InetAddress)
retval.add((InetAddress)value);
else if(value instanceof IpAddress)
retval.add(((IpAddress)value).getIpAddress());
else if(value instanceof InetSocketAddress)
retval.add(((InetSocketAddress)value).getAddress());
}
}
}
}
}
return retval;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:26,代码来源:Configurator.java
示例3: addPropertyToDependencyList
import org.jgroups.annotations.Property; //导入依赖的package包/类
/**
* DFS of dependency graph formed by Property annotations and dependsUpon parameter
* This is used to create a list of Properties in dependency order
*/
static void addPropertyToDependencyList(List<AccessibleObject> orderedList, Map<String, AccessibleObject> props, Stack<AccessibleObject> stack, AccessibleObject obj) {
if (orderedList.contains(obj))
return ;
if (stack.search(obj) > 0) {
throw new RuntimeException("Deadlock in @Property dependency processing") ;
}
// record the fact that we are processing obj
stack.push(obj) ;
// process dependencies for this object before adding it to the list
Property annotation = obj.getAnnotation(Property.class) ;
String dependsClause = annotation.dependsUpon() ;
StringTokenizer st = new StringTokenizer(dependsClause, ",") ;
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
AccessibleObject dep = props.get(token) ;
// if null, throw exception
addPropertyToDependencyList(orderedList, props, stack, dep) ;
}
// indicate we're done with processing dependencies
stack.pop() ;
// we can now add in dependency order
orderedList.add(obj) ;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:30,代码来源:Configurator.java
示例4: grabSystemProp
import org.jgroups.annotations.Property; //导入依赖的package包/类
private static String grabSystemProp(Property annotation) {
String[] system_property_names=annotation.systemProperty();
String retval=null;
for(String system_property_name: system_property_names) {
if(system_property_name != null && !system_property_name.isEmpty()) {
try {
retval=System.getProperty(system_property_name);
if(retval != null)
return retval;
}
catch(SecurityException ex) {
log.error(Util.getMessage("SyspropFailure"), system_property_name, ex);
}
}
}
return retval;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:Configurator.java
示例5: 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 ;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:PropertyHelper.java
示例6: 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));
}
}
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:32,代码来源:ResourceDMBean.java
示例7: setInitialHosts
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(name="initial_hosts", description="Comma delimited list of hosts to be contacted for initial membership",
converter=PropertyConverters.InitialHosts2.class)
public void setInitialHosts(List<InetSocketAddress> hosts) {
if(hosts == null || hosts.isEmpty())
throw new IllegalArgumentException("initial_hosts must contain the address of at least one GossipRouter");
initial_hosts.addAll(hosts) ;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:TCPGOSSIP.java
示例8: sizes
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="Max times to block for the listed messages sizes (Message.getLength()). Example: \"1000:10,5000:30,10000:500\"")
public void setMaxBlockTimes(String str) {
if(str == null) return;
Long prev_key=null, prev_val=null;
List<String> vals=Util.parseCommaDelimitedStrings(str);
if(max_block_times == null)
max_block_times=new TreeMap<>();
for(String tmp: vals) {
int index=tmp.indexOf(':');
if(index == -1)
throw new IllegalArgumentException("element '" + tmp + "' is missing a ':' separator");
Long key=Long.parseLong(tmp.substring(0, index).trim());
Long val=Long.parseLong(tmp.substring(index +1).trim());
// sanity checks:
if(key < 0 || val < 0)
throw new IllegalArgumentException("keys and values must be >= 0");
if(prev_key != null) {
if(key <= prev_key)
throw new IllegalArgumentException("keys are not sorted: " + vals);
}
prev_key=key;
if(prev_val != null) {
if(val <= prev_val)
throw new IllegalArgumentException("values are not sorted: " + vals);
}
prev_val=val;
max_block_times.put(key, val);
}
if(log.isDebugEnabled())
log.debug("max_block_times: " + max_block_times);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:35,代码来源:FlowControl.java
示例9: setMaxInterval
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="Interval (in milliseconds) when the next info " +
"message will be sent. A random value is picked from range [1..max_interval]")
public void setMaxInterval(long val) {
if(val <= 0)
throw new IllegalArgumentException("max_interval must be > 0");
max_interval=val;
check_interval=computeCheckInterval();
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:MERGE3.java
示例10: setMembershipChangePolicy
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="The fully qualified name of a class implementing MembershipChangePolicy.")
public void setMembershipChangePolicy(String classname) {
try {
membership_change_policy=(MembershipChangePolicy)Util.loadClass(classname, getClass()).newInstance();
}
catch(Throwable e) {
throw new IllegalArgumentException("membership_change_policy could not be created", e);
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:10,代码来源:GMS.java
示例11: setGossipRouterHosts
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="A comma-separated list of GossipRouter hosts, e.g. HostA[12001],HostB[12001]")
public void setGossipRouterHosts(String hosts) throws UnknownHostException {
gossip_router_hosts.clear();
// if we get passed value of List<SocketAddress>#toString() we have to strip []
if (hosts.startsWith("[") && hosts.endsWith("]")) {
hosts = hosts.substring(1, hosts.length() - 1);
}
gossip_router_hosts.addAll(Util.parseCommaDelimitedHosts2(hosts, 1));
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:10,代码来源:TUNNEL.java
示例12: setMaxRetransmitTime
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="Max number of milliseconds we try to retransmit a message to any given member. After that, " +
"the connection is removed. Any new connection to that member will start with seqno #1 again. 0 disables this")
public void setMaxRetransmitTime(long max_retransmit_time) {
this.max_retransmit_time=max_retransmit_time;
if(cache != null && max_retransmit_time > 0)
cache.setTimeout(max_retransmit_time);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:8,代码来源:UNICAST2.java
示例13: setMaxRetransmitTime
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(description="Max number of milliseconds we try to retransmit a message to any given member. After that, " +
"the connection is removed. Any new connection to that member will start with seqno #1 again. 0 disables this")
public void setMaxRetransmitTime(long max_retransmit_time) {
this.max_retransmit_time=max_retransmit_time;
if(cache != null && max_retransmit_time > 0)
cache.setTimeout(max_retransmit_time);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:8,代码来源:UNICAST3.java
示例14: setMemberList
import org.jgroups.annotations.Property; //导入依赖的package包/类
@Property(name = "fixed_members_value")
public void setMemberList(String list) throws UnknownHostException {
memberList.clear();
StringTokenizer memberListTokenizer = new StringTokenizer(list, fixed_members_seperator);
while (memberListTokenizer.hasMoreTokens()) {
String tmp=memberListTokenizer.nextToken().trim();
int index=tmp.lastIndexOf('/');
int port=index != -1? Integer.parseInt(tmp.substring(index+1)) : 0;
String addr_str=index != -1? tmp.substring(0, index) : tmp;
InetAddress addr=InetAddress.getByName(addr_str);
memberList.add(new InetSocketAddress(addr, port));
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:14,代码来源:FixedMembershipToken.java
示例15: setValue
import org.jgroups.annotations.Property; //导入依赖的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;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:16,代码来源:Protocol.java
示例16: 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) ;
}
}
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:40,代码来源:Configurator.java
示例17: resolveAndInvokePropertyMethod
import org.jgroups.annotations.Property; //导入依赖的package包/类
public static void resolveAndInvokePropertyMethod(Object obj, Method method, Map<String,String> props) throws Exception {
String methodName=method.getName();
Property annotation=method.getAnnotation(Property.class);
if(annotation != null && isSetPropertyMethod(method)) {
String propertyName=PropertyHelper.getPropertyName(method) ;
String propertyValue=props.get(propertyName);
// if there is a systemProperty attribute defined in the annotation, set the property value from the system property
String tmp=grabSystemProp(method.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"), method.getDeclaringClass().getSimpleName() + "." + methodName,
deprecated_msg);
}
}
if(propertyValue != null) {
Object converted=null;
try {
converted=PropertyHelper.getConvertedValue(obj, method, props, propertyValue, true);
method.invoke(obj, converted);
}
catch(Exception e) {
String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
throw new Exception("Could not assign property " + propertyName + " in "
+ name + ", method is " + methodName + ", converted value is " + converted, e);
}
}
props.remove(propertyName);
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:37,代码来源:Configurator.java
示例18: resolveAndAssignField
import org.jgroups.annotations.Property; //导入依赖的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);
}
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:41,代码来源:Configurator.java
示例19: getConvertedValue
import org.jgroups.annotations.Property; //导入依赖的package包/类
public static Object getConvertedValue(Object obj, Field field, Map<String, String> props, String prop, boolean check_scope) throws Exception {
if (obj == null)
throw new IllegalArgumentException("Cannot get converted value: Object is null") ;
if (field == null)
throw new IllegalArgumentException("Cannot get converted value: Field is null") ;
if (props == null)
throw new IllegalArgumentException("Cannot get converted value: Properties 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 = getPropertyName(field, props) ;
String name = obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
if(propertyConverter == null) {
throw new Exception("Could not find property converter for field " + propertyName
+ " in " + name);
}
Object converted = null ;
try {
String tmp=obj instanceof Protocol? ((Protocol)obj).getName() + "." + propertyName : propertyName;
converted=propertyConverter.convert(obj, field.getType(), tmp, prop, check_scope);
}
catch(Exception e) {
throw new Exception("Conversion of " + propertyName + " in " + name +
" with original property value " + prop + " failed", e);
}
return converted ;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:33,代码来源:PropertyHelper.java
示例20: usesDefaultConverter
import org.jgroups.annotations.Property; //导入依赖的package包/类
public static boolean usesDefaultConverter(Field field) throws IllegalArgumentException {
if (field == null) {
throw new IllegalArgumentException("Cannot check converter: field is null") ;
}
Property annotation=field.getAnnotation(Property.class);
if (annotation == null) {
throw new IllegalArgumentException("Cannot check converter for field " +
field.getName() + " which is not annotated with @Property") ;
}
return annotation.converter().equals(PropertyConverters.Default.class) ;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:12,代码来源:PropertyHelper.java
注:本文中的org.jgroups.annotations.Property类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论