OK, I've made some changes to the Attributes project.
INDEXED ATTRIBUTES
------------------
An attribute can now not only be Inheritable, it can also be Indexed. For
an attribute to be Indexed means that when you run the attribute indexer
tool on the resulting classes, you will get a list of all classes with
that attribute.
For example:
/**
* @Indexed
*/
public class AvalonService { ... }
/**
* @AvalonService ( MyService.class )
*/
public class MyImpl { ... }
/**
* @AvalonService ( MyOtherService.class )
*/
public class MyOtherImpl { ... }
Will result in:
Attribute: AvalonService
Class: MyImpl
Class: MyOtherImpl
This is normally written to a file called META-INF/attrs.index which can
be loaded via the attributes.getAttributeIndex(ClassLoader cl) method. The
resulting AttributeIndex then has a getClassesWithAttribute( String
attribute ) method. So for the above I could do:
AttributeIndex index = Attributes.getAttributeIndex ( classLoader );
Collection serviceImpls = index.getClassesWithAttribute (
AvalonService.class );
And then iterate over the class names in serviceImpls.
Note - the index ignores inherited attributes. If MyImpl hadn't declared
the AvalonService attribute, but inherited it from a superclass, it would
not have been listed in the index. This is because the superclass may
invalidate the index by changing its set of attributes.
NICER SYNTAX
------------
The attribute compiler has to figure out if a Javadoc tag is an attribute
or something else. Previously the rule was simple: If it starts with an
uppercase letter, it is an attribute. Otherwise not. This meant, however
that fully qualified attribute names didn't pass:
// OK, starts with capital letter
@Inheritable
// Not ok, ignored.
@org.apache.avalon.attributes.Inheritable
That's no good, so now the rules work like this instead:
1. Two '@' at the start means attribute:
// OK.
@@lowercaseAttribute
2. The name is analyzed - if the last token, when tokenizing on '.' is
uppercase, it is an attribute:
// OK, last token ("Inheritable" starts with uppercase)
@org.apache.avalon.attributes.Inheritable
// OK, last token ("Inheritable" starts with uppercase)
@Org.Apache.Avalon.attributes.Inheritable
// Not ok.
@Org.Apache.Avalon.attributes.inheritable
/LS
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]