当前位置: 首页>>代码示例>>Java>>正文


Java Property类代码示例

本文整理汇总了Java中org.jgroups.annotations.Property的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Property类属于org.jgroups.annotations包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.jgroups.annotations.Property类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。