commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: [Attributes] Inherit and Develop
Date Wed, 20 Aug 2003 09:16:15 GMT


> From: Noel J. Bergman [mailto:noel@devtech.com] 
> 
> Leo,
> 
> I figure that you should go for it.
> 
> I'd like to hear more about your plans.  JSR 175 is the 
> normative statement of what attributes must be in Java.  How 
> do your plans compare and contrast with JSR 175, nanning, 
> Aspect4J, etc?

The major differences (that I'm aware of) are:

 + I store attributes in generated classes. The classes are
   generated at compile-time by the attribute compiler as
   source files.

 + Attributes are object instances of any class (not just
   serializable). Last I checked, nanning attributes only
   allowed string valued attributes. Attrib4J used .class
   file manipulation, but was moving away from that.

 + I'm sure I'm missing out on something here...

I wish I had a copy of JSR175 - are you aware of any place
I can get it? I've been searching for it in order to make
my implementation sort-of conformant.

An explanation of how my impl works is at:

    http://marc.theaimsgroup.com/?l=avalon-dev&m=105974933614920&w=2:

    (...)

    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 {
    }

    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;
        }
    }

    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...

/LS


Mime
View raw message