Charles Oliver Nutter wrote:
> JRuby doesn't support annotations because Ruby doesn't support
> annotations. So what! We can extend Ruby to add something like
> annotations:
>
> class JPABean
> def self.inherited(clazz)
> @@annotations = {}
> end
> def self.anno(annotation)
> @@last_annotation = annotation
> end
>
> def self.method_added(sym)
> @@annotations[sym] = @@last_annotation
> end
>
> def self.get_annotation(sym)
> return @@annotations[sym]
> end
> end
>
Quick thought: this doesn't seem to be thread safe - load two such
classes at the same time, and you might end up with confused annotations;
Thread A: anno :foo
Thread B: anno :bar
method_added(abc)
method_added(cde)
And now methods abc and cde have annotation :bar... or am I missing
something? Is class loading atomic?
Maybe you could do something with modules, and have the annotation be a
instance var of the metaclass that uses the annotations.
murphee
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email