[jboss-jira] [JBoss JIRA] Closed: (JGRP-1066) Introduce dependencies for @Property annotations
Richard Achmatowicz (JIRA)
jira-events at lists.jboss.org
Wed Sep 30 13:36:02 EDT 2009
[ https://jira.jboss.org/jira/browse/JGRP-1066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Achmatowicz closed JGRP-1066.
-------------------------------------
Resolution: Done
Comitted the code to JGroups HEAD (2.8) after testing.
> Introduce dependencies for @Property annotations
> ------------------------------------------------
>
> Key: JGRP-1066
> URL: https://jira.jboss.org/jira/browse/JGRP-1066
> Project: JGroups
> Issue Type: Feature Request
> Affects Versions: 2.8
> Reporter: Richard Achmatowicz
> Assignee: Richard Achmatowicz
> Priority: Minor
> Fix For: 2.8
>
>
> When processing properties annotated by @Property in protocols, there is a need to reference one property when processing anoither; an example is that the setting of initial_hosts requires a list of host[port] entries, as well as a port_range value. Usually, this sort of property processing requirement forced delaying the processing of initial_hosts in the init() phase, after protocol property processing had completed.
> We introduce a dependency mechanism for @Property annotations:
> 1. @Properties have a name - it can either be explicitly specified in the annotation
> @Property(name=X)
> int i = 0 ;
> or it can default to the variable name of a Field
> @Property(desc=...)
> int Y = 0 ;
> ir it can default to the method name without the prefix set.
> @Property(desc=...)
> void setZ(int i)
> 2. You can specify a dependency on one or more properties (fields or methods) in the same protocol by specifying a comma separated list of @Property names in a dependsUpon attribte:
> @Property(name="X", desc=..., dependsUpon="Y,Z")
> int i = 0 ;
> This ensures that properties Y and Z will be processed by their converters (default or specified) before property X is processed.
> 3. Which leads to the main reason for introducing dependscies: in this way, the converter for property X may refer to the converters for property Y and Z in its processing.
> public static class InitialHosts implements PropertyConverter{
> public Object convert(Protocol protocol, Class<?> propertyFieldType, Properties props, String propertyValue) throws Exception {
> int port_range = getPortRange(protocol) ;
> List<IpAddress> addresses = Util.parseCommaDelimitedHosts(propertyValue, port_range) ; return addresses ;
> }
> private int getPortRange(Protocol protocol) {
> int port_range = 0 ; try {
> Field f = protocol.getClass().getDeclaredField("port_range") ;
> port_range = ((Integer) Configurator.getField(f,protocol)).intValue() ;
> }
> catch(NoSuchFieldException e) { System.out.println("InitialHosts: no such field: port_range");
> }
> return port_range ;
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list