[
https://jira.jboss.org/jira/browse/JGRP-1066?page=com.atlassian.jira.plug...
]
Richard Achmatowicz commented on JGRP-1066:
-------------------------------------------
The modifications are in:
- Property.java (change to convert method signature)
- PropertyConverters.java (adding new PropertyConverter for InitialHosts)
- Configurator (adding in depenency processing method computePropertyDependencies which
takes a Protocol and creates and ordered list of @Property annotated Field and Methods,
ordered in such a way as to be consistent with depenencies specified. The
ProrocolConfiguration.createLayer() went from this:
removeDeprecatedProperties(retval, properties);
resolveAndAssignFields(retval, properties) ;
resolveAndInvokeMethods(retval, properties)
to this:
removeDeprecatedProperties(retval, properties); // before processing Field and Method
based properties, take dependencies specified with @Property.dependsUpon into account
AccessibleObject[] dependencyOrderedFieldsAndMethods = computePropertyDependencies(retval)
;
for(AccessibleObject ordered: dependencyOrderedFieldsAndMethods) {
if (ordered instanceof Field) {
resolveAndAssignField(retval, (Field)ordered, properties) ;
}
else if (ordered instanceof Method) {
resolveAndInvokePropertyMethod(retval, (Method)ordered, properties) ;
}
}
I've left the processing of ConfigurableObjects without depenency processing, but the
same lines of code can be used to implement it there too.
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