1 Reply Latest reply on Jun 9, 2010 5:23 AM by tittop

    Is there any utility to create an AnnotatedType?

    tittop

      i want to convert somewhat concrete class (such as a.b.SomeClass) to  an AnnotatedType. Then the converted AnnotatedTpye can be used for replace the class that is about to be processed when the ProcessAnnotatedType event fired. For example,



      <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat){
          ......
          pat.setAnnotatedType(someOtherClass);
          // how to get a newly defined AnnotatedType giving a special a.b.SomeClass??
          ......
      }



      BTW, I found that AnnotatedTypeBuilder was appearing in many weld's articles, so is it really available for that use I just mentioned?

        • 1. Re: Is there any utility to create an AnnotatedType?
          tittop

          have got it:)


          I inject a BeanManager by using its createAnnotation API.




          <T, X> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat, BeanManager bm) {
              ......
              AnnotatedType<X> someOtherClass = bm.createAnnotatedType(a.b.SomeClass);
              pat.setAnnotatedType((AnnotatedType<T>) someOtherClass);
              ......
          }