You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leo Simons <le...@apache.org> on 2003/01/03 16:38:26 UTC

[general][attributes][clazz][A5] metadata & the java world

Hi gang,

(commons peeps, my first post here I think, did read 
http://jakarta.apache.org/commons/charter.html but couldn't find 
anything on mailing list conventions so hope all is ok)

read a few books on .net 'n stuff last week. Got me thinking again on 
metadata in the java world. I'm gonna throw an overview of various stuff 
out at y'all, along with some thoughts. Additions/corrections much 
needed I suspect ;)

			----------------
			.Net
			----------------

.net stores metadata in compiled tables, basically mapping a reference 
(to a class, object, method, whatever) to a serialized representation of 
an attribute. An attribute is simply a serializable object extending a 
base Attribute class, very bean-like in nature.

In C#, you apply attributes to objects by placing the constructor for 
the attribute between square brackets, and optionally including a list 
of properties to set.

here's how'd might work in "Java.Net" pseudocode:

   [Avalon.Attributes.Lifestyle("singlethreaded", poolable=true)]
   class MyClass {}

   [Avalon.Attributes.Lifestyle("threadsafe")]
   class MyClass2 {}

would be preprocessed into something like:

   class MyClass
   {
     static public Attributes[] _att;
     static
     {
       _att = new Attributes[1];
       _att[0] = new Avalon.Attributes.Lifestyle("singlethreaded");
       _att[0].setPoolable(true);
     }
   }

   class MyClass2
   {
     static public Attributes[] _att;
     static
     {
       _att = new Attributes[1];
       _att[0] = new Avalon.Attributes.Lifestyle("threadsafe");
     }
   }

and the _att stuff is then serialize()d and stored into a table, ie 
resulting in something like (in some hypothetical serialization format I 
just made up):

MyAssembly.jar!/META-INF/ClassMetaData.properties
-------------------------------------------------
MyClass.attributes=array:1:Avalon.Attributes.Lifestyle(f0:singlethreaded:f1:*:f2:1):
MyClass2.attributes=array:1:Avalon.Attributes.Lifestyle(f0:threadsafe:f1:*:f2:*):


When the class loads, the attributes are deserialized and are then 
easily accessible through introspection tools, ie you have something like

class AttributeUtil
{
	public static boolean isSet(Object o,
			String attributeName) { ... };
	public static Attribute getAttribute(Object o,
			String attributeName ) { ... };
}

There's more to it of course (for example, if you leave out constructor 
argument and property info, you can leave off the (), and you can also 
often do without the full package spec), but the basic idea is simple 
enough.

			----------------
			Avalon
			----------------

As putting [] in your sourcefiles is a bit troublesome (most editors 
won't cope, for one), Pete (or someone else, doesn't matter, but he was 
the first to commit some code dealing with this that I saw) had the 
bright and obvious idea some time ago to put the metadata in the javadoc 
comments instead, ie the modified example becomes:

   /**
    * @attribute Avalon.Attributes.Lifestyle("singlethreaded",
    *                   poolable=true)
    */
   class MyClass {}

   /**
    * @attribute Avalon.Attributes.Lifestyle("threadsafe")
    */
   class MyClass2 {}

and as it is somewhat cumbersome to do actual preprocessing, the idea 
was to just store the metadata information somewhere well-known (where 
the utility classes would know how to find it). So instead of

MyAssembly.jar!/META-INF/ClassMetaData.properties
-------------------------------------------------
MyClass.attributes=array:1:Avalon.Attributes.Lifestyle(f0:singlethreaded:f1:*:f2:1):
MyClass2.attributes=array:1:Avalon.Attributes.Lifestyle(f0:threadsafe:f1:*:f2:*):

what we get is:

MyAssembly.jar!/MyClass.xinfo
-----------------------------
<Attributes>
	<Lifestyle type="singlethreaded">
		<poolable value="true"/>
	</Lifestyle>
</Attributes>

MyAssembly.jar!/MyClass2.xinfo
------------------------------
<Attributes>
	<Lifestyle type="threadsafe"/>
</Attributes>

So far so good. Of course, with a verbose xml format for storing the 
metadata information, it is also possible to edit and maintain the xml 
files by hand.

There's one big difference though: with .Net, basically their designers 
figured out a compact way to specify the metadata by closely tying their 
semantics to objects. The way we're going now, with the metadata dtds, 
we loose some compactness, but more importantly the close ties are gone. 
"Custom metadata" is more difficult with the avalon setup.

(note: none of the above actually works; it's just pseudocode examples)
			------------------
			Commons Attributes
			------------------

Commons Attributes (which I just took a first look at) is more similar 
to the .Net setup. It also uses QDox for parsing, but instead of 
defining some xml scheme, simply stores a serialized properties file. 
This is neat and simple (there's very little code neccessary to make it 
all work, the attribute parsing being handled by QDox).

Commons Attributes atm doesn't define a standard location to store 
attribute properties, nor does it contain code to automatically load the 
properties from that location and construct metadata object from them.

There's also less possibility for more complex setups than with the .Net 
way, as an attribute is a name/value pair rather than a potentially 
complex object.

			----------------
			Commons Clazz
			----------------


Then there's Commons Clazz, which does a lot more, full of reflection 
tools and the like. There's also the idea within Clazz to support 
metadata, I'm not quite sure where they're at just yet. No website 
available yet, the only docs are @ 
http://cvs.apache.org/viewcvs.cgi/*checkout*/jakarta-commons-sandbox/clazz/PROPOSAL.html?rev=1.2

As there's less docs I have less of an opinion on Clazz, but it looks 
complex to me.

			----------------
			QDox, XDoclet
			----------------

The QDox and XDoclet folks are also working on metadata stuff themselves 
I believe. Haven't looked at it much, but wanna. I'd say it'd be best to 
seperate the javadoc parsing from the metadata semantics.

			---------------------
			So which way forward?
			---------------------

I'm currently thinking about which way to go with avalon re: all this. 
I'm still liking the approach taken in .net/C# the most.

I think a way forward might be to only so slightly extend Commons 
Attributes to support the "constructor-with-property", or basically the 
GlorifiedHashMap, along with defining a common location for metadata to 
be stored in jar files, and along with an avalon container that handles 
the reading writing of that data and automatically loads it for all 
managed components.

I'm not liking the complexity and size of Clazz very much atm (for 
dealing with this metadata thing that is; I think it'll be good at 
accomplishing its primary goal of reflection done right).

Avalon peeps, I think a good place to work on the basics is Jakarta 
Commons; what we need first is some utility code for constructing and 
destructing metadata, the IoC specifics 'n stuff can come later. With 
gmane setup, it is no longer neccessary to subscribe to 
yet-another-gazillion-messages-a-day list :D


cheers all,

- Leo




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Jakob Praher <jp...@yahoo.de>.
Am Sam, 2003-01-04 um 01.22 schrieb Leo Simons:
> Jakob Praher wrote:
> <snip/>
> > I have thought about custom meta data and .Net style attributes too. 
> > how about a custom classloader and storing them as a custom java class
> > file attribute.
> 
> eh? (scratches head, hits google)
> 
> > as the avalon framework controls the loading process (IoC) through the
> > service/component manager this shouldn't be a problem.
> 
> (Avalon containers far from always have control of (or want to control) 
> classloading, for example you might want to use 'em in a J2ME env, a 
> servlet engine, or any other existing app with existing classloader 
> infrastructure.)
> 
your are definetly right here.
but at least loading is not controlled by the user like this:

mySuperComponent = new XyzSuperComponent( );

this would worsen the approach, (not IoC).


> > I imagine implementing it like this:
> > 
> > * every constant pool element in a java class file can have custom
> > attributes
> > 
> > * custom attributes in a java class file are just raw data - so you can
> > store an arbitrary serialized object as a custom attribute
> > 
> > http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817
> > 
> > attribute_info {    	
> > 	u2 attribute_name_index;    	
> > 	u4 attribute_length;    	
> > 	u1 info[attribute_length];    
> > }
> > 
> > * during class-loading, the class loader overloads the defineClass
> > method and intercepts the class for custom attributes which are .Net
> > like attributes.

would work via getResourceAsStream( ) at a later time too (I think, see
below )

> > 
> > * then it builds an attribute object model and associates with the
> > loaded class and its code source.
> > 
> > just my 2 cent.
> > 
> > to inject the attributes you would need a kind of tacker component that
> > tacks the attributes, based on a javadoc description onto a compiled
> > class file.
> > 
> > this would be insofar interesting as attributes can be attached to any
> > kind of constant pool item - fields and methods too can have custom
> > attributes.
> 
> certainly sounds like it could work, and sounds terribly similar to the 
> actual .Net setup (I know mostly zip about bytecode 'n stuff though). Is 
> it neccessary to have control over the classloading in order to get 
> access to the custom attributes? It seems to me that having this as a 
> requirment could really limit its application.

perhaps the following would work too: (w/o having control of class
loading)

InputStream clazzfile = ClassLoader.getResourceAsStream( "a/Foo.class"
);

then you could also get access to the attributes and load it.
parse the inputstream via a java class file format library and get the
custom attributes out of it.



the other way doesn't work out that easily, as defineClass is "final"

protected final Class defineClass(String name,
                                   byte data[],
                                   int offset,
                                   int length)


so you can't easily intercept the call by overriding it ...


> The other thought that occured is that this might be a step further away 
> from the well-known (and accepted) *BeanInfo setup, and hence more 
> controversial.
> 
it surely is controversal.
I hope the meta data JSR group define a generic way of getting java
class file attributes, this would solve much of the problems we have so
far.

for instance

by the introduction of java.lang.reflect.Attribute

and the following methods in the lang and reflect Package:

class Class {
	...
	Attribute[] getAttributes( );
}
class AccessibleOBject {
	..
	Attribute[] getAttributes( );
}


the only problem with the name "Attribute" is that it is very overloaded
in the java community:

* in  UML (OMG == CORBA) -> MOF -> JMI and JMX too there is the
convention that object fields are called Attributes

so it could be a little bit confusing for programmers accustomed to this
api to do something like this:

clazz = Class.forName( "a.Foo" );
Attribute[] attributes = clazz.getAttributes( ); 

so perhaps another name would suit better.



> Definately sounds as something worth exploring though (for one, it would 
> probably be several dozen times faster than another route), even if I 
> don't fully understand....
> 
> > With 
> >>gmane setup, it is no longer neccessary to subscribe to 
> >>yet-another-gazillion-messages-a-day list :D
> >>
> > sounds interesting, can you point me to more information about that 
> 
> gmane is a news<->email gateway, see http://www.gmane.org/.
> 
thanks for the info - I'll check it out



-- Jakob
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Leo Simons <le...@apache.org>.
Jakob Praher wrote:
<snip/>
> I have thought about custom meta data and .Net style attributes too. 
> how about a custom classloader and storing them as a custom java class
> file attribute.

eh? (scratches head, hits google)

> as the avalon framework controls the loading process (IoC) through the
> service/component manager this shouldn't be a problem.

(Avalon containers far from always have control of (or want to control) 
classloading, for example you might want to use 'em in a J2ME env, a 
servlet engine, or any other existing app with existing classloader 
infrastructure.)

> I imagine implementing it like this:
> 
> * every constant pool element in a java class file can have custom
> attributes
> 
> * custom attributes in a java class file are just raw data - so you can
> store an arbitrary serialized object as a custom attribute
> 
> http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817
> 
> attribute_info {    	
> 	u2 attribute_name_index;    	
> 	u4 attribute_length;    	
> 	u1 info[attribute_length];    
> }
> 
> * during class-loading, the class loader overloads the defineClass
> method and intercepts the class for custom attributes which are .Net
> like attributes.
> 
> * then it builds an attribute object model and associates with the
> loaded class and its code source.
> 
> just my 2 cent.
> 
> to inject the attributes you would need a kind of tacker component that
> tacks the attributes, based on a javadoc description onto a compiled
> class file.
> 
> this would be insofar interesting as attributes can be attached to any
> kind of constant pool item - fields and methods too can have custom
> attributes.

certainly sounds like it could work, and sounds terribly similar to the 
actual .Net setup (I know mostly zip about bytecode 'n stuff though). Is 
it neccessary to have control over the classloading in order to get 
access to the custom attributes? It seems to me that having this as a 
requirment could really limit its application.

The other thought that occured is that this might be a step further away 
from the well-known (and accepted) *BeanInfo setup, and hence more 
controversial.

Definately sounds as something worth exploring though (for one, it would 
probably be several dozen times faster than another route), even if I 
don't fully understand....

> With 
>>gmane setup, it is no longer neccessary to subscribe to 
>>yet-another-gazillion-messages-a-day list :D
>>
> sounds interesting, can you point me to more information about that 

gmane is a news<->email gateway, see http://www.gmane.org/.

cheers,

- Leo




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Jakob Praher <jp...@yahoo.de>.
hi leo,

thanks for the nice summary.
I have thought about custom meta data and .Net style attributes too. 

<snip>
> 			---------------------
> 			So which way forward?
> 			---------------------
> 
> I'm currently thinking about which way to go with avalon re: all this. 
> I'm still liking the approach taken in .net/C# the most.
> 
> I think a way forward might be to only so slightly extend Commons 
> Attributes to support the "constructor-with-property", or basically the 
> GlorifiedHashMap, along with defining a common location for metadata to 
> be stored in jar files, and along with an avalon container that handles 
> the reading writing of that data and automatically loads it for all 
> managed components.
> 

</snip>

how about a custom classloader and storing them as a custom java class
file attribute.

as the avalon framework controls the loading process (IoC) through the
service/component manager this shouldn't be a problem.

I imagine implementing it like this:

* every constant pool element in a java class file can have custom
attributes

* custom attributes in a java class file are just raw data - so you can
store an arbitrary serialized object as a custom attribute

http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817

attribute_info {    	
	u2 attribute_name_index;    	
	u4 attribute_length;    	
	u1 info[attribute_length];    
}

* during class-loading, the class loader overloads the defineClass
method and intercepts the class for custom attributes which are .Net
like attributes.

* then it builds an attribute object model and associates with the
loaded class and its code source.

just my 2 cent.

to inject the attributes you would need a kind of tacker component that
tacks the attributes, based on a javadoc description onto a compiled
class file.

this would be insofar interesting as attributes can be attached to any
kind of constant pool item - fields and methods too can have custom
attributes.


With 
> gmane setup, it is no longer neccessary to subscribe to 
> yet-another-gazillion-messages-a-day list :D
> 
sounds interesting, can you point me to more information about that 


-- Jakob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Leo Simons <le...@apache.org>.
dion@multitask.com.au wrote:
> do you know about Jereon Fritjers work on a JVM running under the CLR?
> 
> He has eclipse running on it at the moment.

I am now:

http://radio.weblogs.com/0109845/2002/12/28.html#a76
http://sourceforge.net/projects/ikvm/

looks quite promising! (though I would be even more interested in his 
work on a "jar -> assembly compiler")

- Leo




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Juozas Baliuka <ba...@centras.lt>.




> Juozas Baliuka wrote:
> > I do not think workarounds is good way to solve problems like this,  we
can
> > start [compiler] project
> > in commons, it is possible to implement attribute stuff and more.
> > We can forke some open source compiler for JVM, but I think it must not
be a
> > problem for jakarta developers to implement  compiler.
> >  jakarta# ;)
>
> that'd be:
> a) a lot of work
> b) difficult to sell to coworkers, let alone decision makers
> c) something that'd take more than a few months to finish
> d) real fun

agree, but I do not think  XML grabage in classpath and generated grabage in
sources is solution.


>
> I'd say that if you're going to take the time and effort to write (or
> fork) an all new compiler for java, it makes most sense to write a
> compiler that targets the .Net CLR. Are there developers at jakarta that
> could? Of course, we've got some of the best minds in OSS here (not that
> I'm one of 'em, but they're around ;).
>
> OTOH, if you are going to extend the language, C# and java are similar
> to an extend that it probably then makes most sense to work with either
> the mono team (adopting MCS) or the .GNU people (adoption pnet).

I do not think opensource implementation of closed standards like JAVA or
CLR have some meaning,
I think programmers will use closed implementation.

>
> cheers!
>
> - Leo
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by di...@multitask.com.au.
Leo,

do you know about Jereon Fritjers work on a JVM running under the CLR?

He has eclipse running on it at the moment.
--
dIon Gillard, Multitask Consulting
Blog:      http://www.freeroller.net/page/dion/Weblog
Work:      http://www.multitask.com.au


news <ne...@main.gmane.org> wrote on 04/01/2003 11:00:26 AM:

> Juozas Baliuka wrote:
> > I do not think workarounds is good way to solve problems like this, we 
can
> > start [compiler] project
> > in commons, it is possible to implement attribute stuff and more.
> > We can forke some open source compiler for JVM, but I think it must 
not be a
> > problem for jakarta developers to implement  compiler.
> >  jakarta# ;)
> 
> that'd be:
>    a) a lot of work
>    b) difficult to sell to coworkers, let alone decision makers
>    c) something that'd take more than a few months to finish
>    d) real fun
> 
> I'd say that if you're going to take the time and effort to write (or 
> fork) an all new compiler for java, it makes most sense to write a 
> compiler that targets the .Net CLR. Are there developers at jakarta that 

> could? Of course, we've got some of the best minds in OSS here (not that 

> I'm one of 'em, but they're around ;).
> 
> OTOH, if you are going to extend the language, C# and java are similar 
> to an extend that it probably then makes most sense to work with either 
> the mono team (adopting MCS) or the .GNU people (adoption pnet).
> 
> cheers!
> 
> - Leo
> 
> 
> 
> 
> --
> To unsubscribe, e-mail: 
<ma...@jakarta.apache.org>
> For additional commands, e-mail: 
<ma...@jakarta.apache.org>
> 

> ForwardSourceID:NT0009E2C2 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Leo Simons <le...@apache.org>.
Juozas Baliuka wrote:
> I do not think workarounds is good way to solve problems like this,  we can
> start [compiler] project
> in commons, it is possible to implement attribute stuff and more.
> We can forke some open source compiler for JVM, but I think it must not be a
> problem for jakarta developers to implement  compiler.
>  jakarta# ;)

that'd be:
	a) a lot of work
	b) difficult to sell to coworkers, let alone decision makers
	c) something that'd take more than a few months to finish
	d) real fun

I'd say that if you're going to take the time and effort to write (or 
fork) an all new compiler for java, it makes most sense to write a 
compiler that targets the .Net CLR. Are there developers at jakarta that 
could? Of course, we've got some of the best minds in OSS here (not that 
I'm one of 'em, but they're around ;).

OTOH, if you are going to extend the language, C# and java are similar 
to an extend that it probably then makes most sense to work with either 
the mono team (adopting MCS) or the .GNU people (adoption pnet).

cheers!

- Leo




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Juozas Baliuka <ba...@centras.lt>.
I do not think workarounds is good way to solve problems like this,  we can
start [compiler] project
in commons, it is possible to implement attribute stuff and more.
We can forke some open source compiler for JVM, but I think it must not be a
problem for jakarta developers to implement  compiler.
 jakarta# ;)
----- Original Message -----
From: "Leo Simons" <le...@apache.org>
To: <co...@jakarta.apache.org>
Cc: <av...@jakarta.apache.org>
Sent: Friday, January 03, 2003 5:38 PM
Subject: [general][attributes][clazz][A5] metadata & the java world


> Hi gang,
>
> (commons peeps, my first post here I think, did read
> http://jakarta.apache.org/commons/charter.html but couldn't find
> anything on mailing list conventions so hope all is ok)
>
> read a few books on .net 'n stuff last week. Got me thinking again on
> metadata in the java world. I'm gonna throw an overview of various stuff
> out at y'all, along with some thoughts. Additions/corrections much
> needed I suspect ;)
>
> ----------------
> .Net
> ----------------
>
> .net stores metadata in compiled tables, basically mapping a reference
> (to a class, object, method, whatever) to a serialized representation of
> an attribute. An attribute is simply a serializable object extending a
> base Attribute class, very bean-like in nature.
>
> In C#, you apply attributes to objects by placing the constructor for
> the attribute between square brackets, and optionally including a list
> of properties to set.
>
> here's how'd might work in "Java.Net" pseudocode:
>
>    [Avalon.Attributes.Lifestyle("singlethreaded", poolable=true)]
>    class MyClass {}
>
>    [Avalon.Attributes.Lifestyle("threadsafe")]
>    class MyClass2 {}
>
> would be preprocessed into something like:
>
>    class MyClass
>    {
>      static public Attributes[] _att;
>      static
>      {
>        _att = new Attributes[1];
>        _att[0] = new Avalon.Attributes.Lifestyle("singlethreaded");
>        _att[0].setPoolable(true);
>      }
>    }
>
>    class MyClass2
>    {
>      static public Attributes[] _att;
>      static
>      {
>        _att = new Attributes[1];
>        _att[0] = new Avalon.Attributes.Lifestyle("threadsafe");
>      }
>    }
>
> and the _att stuff is then serialize()d and stored into a table, ie
> resulting in something like (in some hypothetical serialization format I
> just made up):
>
> MyAssembly.jar!/META-INF/ClassMetaData.properties
> -------------------------------------------------
>
MyClass.attributes=array:1:Avalon.Attributes.Lifestyle(f0:singlethreaded:f1:
*:f2:1):
>
MyClass2.attributes=array:1:Avalon.Attributes.Lifestyle(f0:threadsafe:f1:*:f
2:*):
>
>
> When the class loads, the attributes are deserialized and are then
> easily accessible through introspection tools, ie you have something like
>
> class AttributeUtil
> {
> public static boolean isSet(Object o,
> String attributeName) { ... };
> public static Attribute getAttribute(Object o,
> String attributeName ) { ... };
> }
>
> There's more to it of course (for example, if you leave out constructor
> argument and property info, you can leave off the (), and you can also
> often do without the full package spec), but the basic idea is simple
> enough.
>
> ----------------
> Avalon
> ----------------
>
> As putting [] in your sourcefiles is a bit troublesome (most editors
> won't cope, for one), Pete (or someone else, doesn't matter, but he was
> the first to commit some code dealing with this that I saw) had the
> bright and obvious idea some time ago to put the metadata in the javadoc
> comments instead, ie the modified example becomes:
>
>    /**
>     * @attribute Avalon.Attributes.Lifestyle("singlethreaded",
>     *                   poolable=true)
>     */
>    class MyClass {}
>
>    /**
>     * @attribute Avalon.Attributes.Lifestyle("threadsafe")
>     */
>    class MyClass2 {}
>
> and as it is somewhat cumbersome to do actual preprocessing, the idea
> was to just store the metadata information somewhere well-known (where
> the utility classes would know how to find it). So instead of
>
> MyAssembly.jar!/META-INF/ClassMetaData.properties
> -------------------------------------------------
>
MyClass.attributes=array:1:Avalon.Attributes.Lifestyle(f0:singlethreaded:f1:
*:f2:1):
>
MyClass2.attributes=array:1:Avalon.Attributes.Lifestyle(f0:threadsafe:f1:*:f
2:*):
>
> what we get is:
>
> MyAssembly.jar!/MyClass.xinfo
> -----------------------------
> <Attributes>
> <Lifestyle type="singlethreaded">
> <poolable value="true"/>
> </Lifestyle>
> </Attributes>
>
> MyAssembly.jar!/MyClass2.xinfo
> ------------------------------
> <Attributes>
> <Lifestyle type="threadsafe"/>
> </Attributes>
>
> So far so good. Of course, with a verbose xml format for storing the
> metadata information, it is also possible to edit and maintain the xml
> files by hand.
>
> There's one big difference though: with .Net, basically their designers
> figured out a compact way to specify the metadata by closely tying their
> semantics to objects. The way we're going now, with the metadata dtds,
> we loose some compactness, but more importantly the close ties are gone.
> "Custom metadata" is more difficult with the avalon setup.
>
> (note: none of the above actually works; it's just pseudocode examples)
> ------------------
> Commons Attributes
> ------------------
>
> Commons Attributes (which I just took a first look at) is more similar
> to the .Net setup. It also uses QDox for parsing, but instead of
> defining some xml scheme, simply stores a serialized properties file.
> This is neat and simple (there's very little code neccessary to make it
> all work, the attribute parsing being handled by QDox).
>
> Commons Attributes atm doesn't define a standard location to store
> attribute properties, nor does it contain code to automatically load the
> properties from that location and construct metadata object from them.
>
> There's also less possibility for more complex setups than with the .Net
> way, as an attribute is a name/value pair rather than a potentially
> complex object.
>
> ----------------
> Commons Clazz
> ----------------
>
>
> Then there's Commons Clazz, which does a lot more, full of reflection
> tools and the like. There's also the idea within Clazz to support
> metadata, I'm not quite sure where they're at just yet. No website
> available yet, the only docs are @
>
http://cvs.apache.org/viewcvs.cgi/*checkout*/jakarta-commons-sandbox/clazz/P
ROPOSAL.html?rev=1.2
>
> As there's less docs I have less of an opinion on Clazz, but it looks
> complex to me.
>
> ----------------
> QDox, XDoclet
> ----------------
>
> The QDox and XDoclet folks are also working on metadata stuff themselves
> I believe. Haven't looked at it much, but wanna. I'd say it'd be best to
> seperate the javadoc parsing from the metadata semantics.
>
> ---------------------
> So which way forward?
> ---------------------
>
> I'm currently thinking about which way to go with avalon re: all this.
> I'm still liking the approach taken in .net/C# the most.
>
> I think a way forward might be to only so slightly extend Commons
> Attributes to support the "constructor-with-property", or basically the
> GlorifiedHashMap, along with defining a common location for metadata to
> be stored in jar files, and along with an avalon container that handles
> the reading writing of that data and automatically loads it for all
> managed components.
>
> I'm not liking the complexity and size of Clazz very much atm (for
> dealing with this metadata thing that is; I think it'll be good at
> accomplishing its primary goal of reflection done right).
>
> Avalon peeps, I think a good place to work on the basics is Jakarta
> Commons; what we need first is some utility code for constructing and
> destructing metadata, the IoC specifics 'n stuff can come later. With
> gmane setup, it is no longer neccessary to subscribe to
> yet-another-gazillion-messages-a-day list :D
>
>
> cheers all,
>
> - Leo
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [general][attributes][clazz][A5] metadata & the java world

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Leo Simons" <le...@apache.org>
> ----------------
> Commons Clazz
> ----------------
>
>
> Then there's Commons Clazz, which does a lot more, full of reflection
> tools and the like. There's also the idea within Clazz to support
> metadata, I'm not quite sure where they're at just yet. No website
> available yet, the only docs are @
>
http://cvs.apache.org/viewcvs.cgi/*checkout*/jakarta-commons-sandbox/clazz/P
ROPOSAL.html?rev=1.2
>
> As there's less docs I have less of an opinion on Clazz, but it looks
> complex to me.

[clazz] has been watching [attributes] to see how that gets on. It doesn't
really make sense for commons to have two methods to get attributes. Plus
XDoclet/ClassLoaders are not my speciality.

> I'm not liking the complexity and size of Clazz very much atm (for
> dealing with this metadata thing that is; I think it'll be good at
> accomplishing its primary goal of reflection done right).

Yep, 'advanced reflection and introspection' would be a good tag line for
[clazz], and hoopefully that involves plugging into a lower level
[attributes].

Stephen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>