Leo:
This process started out based on the issue of how to handle extended attributes - i.e. a container wants to be able to know if a component is declaring somerthing that it needs to know to be able to deploy something. While the entire topic is interesting with respect to approaches in "open-attribute-defintion" - I have not yet figured out how any of this actually addresses the original problem.
Can you help me out here. I need to know how a container recognizes that an attribute must be recognized, and how a container establishes validity of a attribute that must be recognized, and how a container establishes that an attribute has in fact been recognized.
Stephen.
Leo Sutic wrote:
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]
--
Stephen J. McConnell mailto:[EMAIL PROTECTED] http://www.osm.net
Sent via James running under Merlin as an NT service. http://avalon.apache.org/sandbox/merlin
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
