[jboss-user] [JBoss Seam] - Re: Can you merge multiple annotations in one?

CptnKirk do-not-reply at jboss.com
Tue Sep 5 21:20:10 EDT 2006


Actually I'm pretty sure Java does have limited meta-annotation support.  Look at how Seam implements its DataBinding mechanism.


  | @Target(ANNOTATION_TYPE)
  | @Retention(RUNTIME)
  | @Documented
  | public @interface DataBinderClass
  | {
  |    Class<? extends DataBinder> value();
  | }

Then in whatever your databinder annotation is

  | @Target({FIELD, METHOD})
  | @Retention(RUNTIME)
  | @Documented
  | @DataBinderClass(SelectItemsBinder.class)
  | public @interface SelectItems
  | {...

Code that looks for @DataBinderClass annotated elements will also find elements annotated with @SelectItems.  This is all pretty static, so you won't have the nice macro effect that you're looking for, but could have your own @SeamSLSB annotation that encapsulates some boilerplate code (including imports).  I haven't tried this with any annotation other than @DataBinderClass, and it has a @Target(ANNOTATION_TYPE).  It's possible that other Seam annotations may also work those with @Target(TYPE), it's possible things may fail.  Good luck.

I hope this is useful.

-Jim

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969607#3969607

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969607



More information about the jboss-user mailing list