dev@woodstock.java.net

Re: Proposed Annotation Change

From: Gregory Murphy <Gregory.Murphy_at_Sun.COM>
Date: Tue, 04 Sep 2007 08:59:57 -0700

Ken Paulsen wrote:
> Adding the @Renderer annotation to a UIComponent class works provided
> that you use the rendererClass property as well... AND you don't have
> a @Component annotation. The way the current annotation processor is
> written, it doesn't support 2 annotations on a single class... or at
> least I haven't figured out the correct syntax to get that to work. I
> think the problem is that when you specify both annotations, the first
> annotation annotates the 2nd annotation instead of both annotating the
> class. Separating w/ commas didn't seem to help. There's a good
> change I'm doing something wrong when defining the annotation, though.


An annotation may use another annotation as the type of one of its
elements, but you can't annotate an annotation. I don't know enough
about formal languages to be able to explain why this is.

The current library and processor do support multiple renderer
annotations, so that one renderer can be assigned to more than one
component family. For example:

    @Renderer({
         @Renders(componentFamily="org.example.input"),
         @Renders(componentFamily="org.example.output")
     })
     public class MyFavoriteRenderer {
     }

So you can use a single template renderer with a whole mess of
components, but you have to annotate the renderer to create these
associations, not the components. If users are getting the template
renderer as part of a third party JAR, they could always extend it, and
annotate the extension.

// Gregory