We've spoken about this at length in the past, and got to the point where we'd be
happy with Fqns containing just Strings and Java primitives.
After discussing things further at JBoss World, we really should just limit Fqn elements
to Strings. If people wish to use other types, they could implement their own Fqn
subclasses that can encode/decode primitives, etc. into String representations.
Here is a summary of the discussions - please feel free to comment.
Purpose: partly to improve performance with Fqn usage in Maps and the calculation of Fqn
hash codes, as well as frequent creation.
1. Remove Fqn generics!
This was introduced in JBC 2.0.0 and has added an unnecessary layer of complexity for
little benefit as far as Fqns are concerned.
2. Fqns should only contain String elements
If this were to contain primitives, these would be encoded as Strings internally anyway,
so may as well let users do this themselves
Perhaps as a subclass of Fqn (but make sure we make some internal methods final)
3. Change Node.name to be a String as well instead of an Object, since Fqns would only
contain Strings.
4. Fqn.fromString() should escape "invalid" characters such as "/" to
disambiguate from a String containing such characters.
5. All Fqn constructors to be private (or protected). Instantiation via factory methods
only.
Reduces unnecessary object construction if we maintain a weak hashmap of pre-known Fqns
and we can reuse these since Fqns are immutable.
Need to be careful of and test for mem leaks!
6. Profile to see if a search-and-get or search-and-instantiate-and-put is actually
faster (on average) than outright construction, to validate the above approach.
7. Fqn factory method to allow for String varargs and Fqn + String vararg signatures.
8. All escaping of Fqn strings happens internally.
9. Fqns hold a ref to the String elements (ArrayList) as well as a complete String rep,
for quick hashCode() calculations and equals() comparisons.
10. Expose an âintern()â method akin to String.intern() with the same effects and
caveats about permgen space.
11. Always intern Fqn.ROOT and other internal Fqn constructs like /_BUDDY_BACKUP_/ by
default.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135087#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...