Leo Sutic wrote:
Berin Loritsch wrote:

3) Scrap the whole thing and use a more generic library. Implication:

the


Avalon meta package goes in the crapper, and we use something like

Commons


Attributes (some work has to be done with that as they don't

support the


name="value" notation for tags).



Consider .Net: When you add attributes to something, *all* attributes get compiled in. It is then deferred to runtime which attributes are to be recognized.

I think this would solve a lot. First, we could use *one* metainfo
builder for
all containers. That builder would be forward-compatible and
container-agnostic.
You could experiment as much as you wanted with new container features.


Essentially you prefer option 3: scrap Avalon Meta as it is now defined
in sandbox, and use something more generic.  In the absence of JSR 175,
we need to look at something that will work in the mean time--perhaps
a BCEL bound tool.

-oOo-

With the risk that this turns into a "Leo's Picks" column I am also
beginning to
like the way attributes are handled in .Net, with value objects. You'd
have:

    import org.apache.avalon.framework.attributes.ThreadSafe;
    import org.apache.avalon.framework.attributes.Dependency;

    /**
     *
     * @attribute new ThreadSafe()
     * @attribute new Dependency( MyDependency.class, "my-dep" )
     */
    public class MyComponent {
    }

The .NET equivalent would be:


[ThreadSafe]
[Dependency( MyDependency.class, "name", Optional.True )]

So we would drop the "new" in the example above.

This could be compiled into a .java file and then into a .class file:

    public interface AttributeClass {
        public Set getClassAttributes ();
    }

    import org.apache.avalon.framework.attributes.ThreadSafe;
    import org.apache.avalon.framework.attributes.Dependency;

    public class MyComponent$Attributes implements AttributeClass {
        public static final Set classAttributes = new HashSet ();
        static {
            classAttributes.add ( new ThreadSafe () );
            classAttributes.add ( Dependency( MyDependency.class,
"my-dep" ) );
        }

        public Set getClassAttributes () {
            return classAttributes;
        }
    }

Or we can provide a BCEL backed utility that operates directly on the .java files altogether. The main issue here though is that some @version, @author, etc. tags don't have corresponding Attributes tags.


A standard API would be able to access this via:


    Class c = MyComponent.class;
    Class attributeClass = c.getClassLoader ().loadClass ( c.getName +
"$Attributes" );
    AttributeClass instance = (AttributeClass)
attributeClass.newInstance ();
    Set classAttributes = instance.getClassAttributes ();

and so on...

Am thinking about whacking together a sample of this.

BTW - I remember seeing a sample of JSR175, Metadata for Java, but I
have
forgotten where.

That would rock.


--

"They that give up essential liberty to obtain a little temporary safety
 deserve neither liberty nor safety."
                - Benjamin Franklin


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to