deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject Re: AW: Util class to find annotations in a class
Date Thu, 12 Jul 2012 15:15:40 GMT
Mark. Do you suggest to create a class implementing extension like we do 
for CDI SPI ?

ProcessAnnotatedType



On 12/07/12 17:07, Mark Struberg wrote:
> +1
>
> public void initCamelContext(@Observes ProcessAnnotatedType<? extends CamelContext>
 pat) {...
>
> for example.
>
> Doing another scan manually is really performance intense!
>
>
> LieGrue,
> strub
>
>
>
> PS: please don't do cross posts to multiple lists at the same time. just confuses users
;)
>
>
>
> ----- Original Message -----
>> From: Arne Limburg<arne.limburg@openknowledge.de>
>> To: "deltaspike-dev@incubator.apache.org"<deltaspike-dev@incubator.apache.org>;
"user@openwebbeans.apache.org"<user@openwebbeans.apache.org>
>> Cc:
>> Sent: Thursday, July 12, 2012 2:37 PM
>> Subject: AW: Util class to find annotations in a class
>>
>> Hi,
>>
>> can't you just listen to the ProcessAnnotatedType event, inspect it and if
>> you find an @EndpointInject i.e. add an @Inject to the AnnotatedType?
>>
>> Cheers,
>> Arne
>>
>> -----Urspr√ľngliche Nachricht-----
>> Von: Charles Moulliard [mailto:cmoulliard@gmail.com]
>> Gesendet: Donnerstag, 12. Juli 2012 14:22
>> An: deltaspike-dev@incubator.apache.org; user@openwebbeans.apache.org
>> Betreff: Util class to find annotations in a class
>>
>> Hi,
>>
>> Is there a DeltaSpike or OpenWebbeans util class that I could use to scan
>> classes and find annotations (which have been of course designed without CDI in
>> mind) and next inject them ?
>>
>> Camel provides @EndpointInject(uri or ref), @Produce(uri) and @Consume
>> annotations to inject Endpoint definition or Producer/ConsumerTemplate into
>> CamelContext.
>>
>> We have to call getInjectionValue(type, uri, endpointRef, injectionPointName,
>> null, null) method of CamelPostProcessorHelper tevery time such annotation is
>> discovered o add such injected bean. Camel-guice, camel-spring and
>> camel-blueprint projects proposes such impl (which is not CDI compliant). I
>> would like to implement this in camel-cdi (where we already have defined a
>> CamelInjector) and tries to find the best strategy.
>>
>> Is there something equivalent to what we have here in camel-guice ?
>>
>>          bindAnnotationInjector(EndpointInject.class,
>> EndpointInjector.class); where bindAnnotationInjector is a method of this class
>> GuiceyFruitModule  and EndpointInjectorClass is the class containing the code to
>> find annotations wiithin a class
>>
>> public class EndpointInjector extends CamelPostProcessorHelper implements
>>      AnnotationMemberProvider<EndpointInject>  {
>>
>>      @Inject
>>      public EndpointInjector(CamelContext camelContext) {
>>          super(camelContext);
>>      }
>>
>>      public Object provide(EndpointInject inject, TypeLiteral<?>
>> typeLiteral, Field field) {
>>          Class<?>  type = field.getType();
>>          String injectionPointName = field.getName();
>>          String uri = inject.uri();
>>          String endpointRef = inject.ref();
>>
>>          return getInjectionValue(type, uri, endpointRef, injectionPointName,
>> null, null);
>>      }
>>
>> Regards,
>>
>> Apache Committer
>>
>> Blog : http://cmoulliard.blogspot.com
>> Twitter : http://twitter.com/cmoulliard
>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>> Skype: cmoulliard
>>

Mime
View raw message