[weld-commits] Weld SVN: r5075 - doc/trunk/reference/en-US.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Nov 15 23:18:06 EST 2009


Author: gavin.king at jboss.com
Date: 2009-11-15 23:18:06 -0500 (Sun, 15 Nov 2009)
New Revision: 5075

Modified:
   doc/trunk/reference/en-US/extend.xml
Log:
wrapping AnnotatedType

Modified: doc/trunk/reference/en-US/extend.xml
===================================================================
--- doc/trunk/reference/en-US/extend.xml	2009-11-16 03:52:02 UTC (rev 5074)
+++ doc/trunk/reference/en-US/extend.xml	2009-11-16 04:18:06 UTC (rev 5075)
@@ -285,8 +285,30 @@
    <section>
       <title>Wrapping an <literal>AnnotatedType</literal></title>
       
-      <para>TODO</para>
+      <para>
+         One of the most interesting things that an extension class can do is process the annotations of a bean class
+         <emphasis>before</emphasis> the container builds its metamodel.
+      </para>
       
+      <programlisting role="JAVA"><![CDATA[class MyExtension implements Extension {
+      
+   <T> void processAnnotatedType(ProcessAnnotatedType<T> pat) {
+      final AnnotatedType<T> type = pat.getAnnotatedType();
+      if ( Service.class.isAssignableFrom( type.getJavaClass() ) ) {
+         //if the class implements Service, make it an @Alternative
+         AnnotatedType<T> wrapped = new AnnotatedType<T>() {
+            public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+               return annotationType.equals(Alternative.class) ? 
+                  true : type.isAnnotationPresent(annotationType);
+            }
+            ...
+         }
+         pat.setAnnotatedType(wrapped);
+      }
+   } 
+   
+}]]></programlisting>
+
    </section>
 
    <section>



More information about the weld-commits mailing list