[
https://jira.jboss.org/jira/browse/JGRP-1068?page=com.atlassian.jira.plug...
]
Richard Achmatowicz commented on JGRP-1068:
-------------------------------------------
This reflects what I understood during our discussion this morning.
One small issue concerning how we get the defaults. You are suggesting to add attributes
defaultIPv4 and defaultIPv6 to allow specifying IP version specific defaults for
properties which represent InetAddress (or related) values. The annotation @Property is
used for all user specified properties, whether they be int, float or
List<IpAddress>. But defaultIPv4 and defaultIPv6 don't generally make sense for
int or float.
I'm just wondering whether we could (or should?) define @Property like this:
public @interface Property {
String name() default "";
String description() default "";
String deprecatedMessage() default "";
Class<?> converter() default PropertyConverters.Default.class; String
dependsUpon() default "";
Striing default() default "";
Striing defaultIPv4() default "";
Striing defaultIPv6() default "";
}
and have a default mechanism for fields other than InetAddress values (e.g. some structure
which requires a converter to generate its initial value from a string but which is not
related to InetAddresses). So the scheme works exactly as above, except that every field
can now have a default String value assigned:
@Property(dependsUpon="mcast_port", defaultIPv4="224.5.6.7",
defaultIPv6="::FF88",converter=IpAddressConverter.class)
private IpAddress mcast_addr;
@Property(default="1234",converter=Default.class)
private int mcast_port;
So if the user does not specify a mcast_port value (ie.. props.get("mcast_port")
== null), then the default value is taken from the Property.default() call.
So any variable can have a default assigned using this mechanism: use default() for
non-InetAddress variables, and defaultIPv4()/default(IPv6() for InetAddress related
variables.
mcast_port maybe isn't a good example, because it may need to be generated during
init() based on which ports are available, but there may be other data structures which
require generation of a default value by a converter (e.g. some kind of List or Map)
which can't conveniently be defined statically.
Add programmer assigned default processing to @Property annotations
-------------------------------------------------------------------
Key: JGRP-1068
URL:
https://jira.jboss.org/jira/browse/JGRP-1068
Project: JGroups
Issue Type: Feature Request
Affects Versions: 2.8
Reporter: Richard Achmatowicz
Assignee: Richard Achmatowicz
Priority: Minor
Fix For: 2.8
There is a need to handle in a systematic way the assignment of programmer assigned
defaults to properties in JGroups. THis issue concerns incorporating the assignment of
progranmmer assigned defaults using the existing @Property mechanism.
The following comments explain the issue.
--
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