You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Rudy De Busscher <rd...@gmail.com> on 2011/11/17 12:43:28 UTC

Programmaticly adding interceptors to CDI bean

Hi all,

I would like to add an interceptor to a method programmatical, without the
need for the annotation on the method.

Point is that I have created a new scope and all methods of the bean
assigned to that scope should also be assigned an interceptor.  I would
like to do that automatically, so that the developer doesn't need to add
the annotation.

I found the place in the code were OWB is performing the task but there
seems no portable way of doing this.

Or is there another way of doing such functionality?

Thx
regards
Rudy

-- 
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Rudy De Busscher <rd...@gmail.com>.
Hi Mark,

I was using Weld 1.1.3.SP1 (from the Glashfish 3.1.2 trunk).

Regards
Rudy

On 26 November 2011 22:12, Mark Struberg <st...@yahoo.de> wrote:

> Hi Rudy!
>
> Thanks for the update and glad we could help!
> Which version of Weld do you use?
>
>
> LieGrue,
> strub
>
>
>
>
> >________________________________
> > From: Rudy De Busscher <rd...@gmail.com>
> >To: user@openwebbeans.apache.org
> >Sent: Friday, November 25, 2011 3:55 PM
> >Subject: Re: Programmaticly adding interceptors to CDI bean
> >
> >
> >Hi all,
> >
> >Sorry that it took so long before I had time to continue on this.
> >
> >The proposed way to go (use ProcessAnnotatedType from within an
> Extension) is working. Only in my first attempt I didn't used a wrapped
> AnnotatedType.  But thanks to the examples of Gerhard and Mark, I was able
> to make a working version.
> >
> >At least with OWB. Weld doesn't execute an interceptor on a custom scoped
> bean. Even 'hardcoded' with the interceptor annotation on the bean method.
> >
> >Looking into that know, but that is not an issue for this mailing list.
> >
> >Thx
> >Regards
> >Rudy
> >
> >
> >On 18 November 2011 11:51, Mark Struberg <st...@yahoo.de> wrote:
> >
> >Hi Rudy!
> >>
> >>Which OWB version are you using? With 1.1.2 all that stuff should work
> fine.
> >>See here for an example where I do exactly that:
> >>https://github.com/struberg/InterDyn
> >>
> >>
> >>Please note that if you add the Interceptor annotation dynamically (via
> ProcessAnnotatedType), you STILL need to manually enable the <interceptors>
> in your beans.xml file!
> >>
> >>
> >>LieGrue,
> >>strub
> >>
> >>
> >>
> >>>________________________________
> >>>From: Rudy De Busscher <rd...@gmail.com>
> >>>To: user@openwebbeans.apache.org
> >>>Sent: Thursday, November 17, 2011 9:38 PM
> >>>Subject: Re: Programmaticly adding interceptors to CDI bean
> >>
> >>>
> >>>
> >>>@Arne,
> >>>
> >>>I tried to create something but it isn't working.
> >>>
> >>>I know now that you can also put the annotation of the interceptor at
> the class level and that all methods are then intercepted.
> >>>
> >>>So I tried to add the annotation to the
> ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the
> Extension. But this isn't used to determine the interceptors.
> >>>
> >>>In the method
> org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the
> annotations are taken from the Class itself, not from the Bean or
> AnnotatedType.
> >>>
> >>>@Gerhard
> >>>I'll have a look at those classes to implement it.  But can't try it
> before the end of next week. (so no feedback before that)
> >>>
> >>>But now that I know that you can specify the interceptor annotation
> also at the class level, It is less important to add it programmaticly.
> Adding it on one place by hand isn't too bad.
> >>>
> >>>Thx
> >>>Rudy
> >>>
> >>>
> >>>
> >>>On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>
> wrote:
> >>>
> >>>hi rudy,
> >>>>
> >>>>for adding an interceptor for a whole bean, you can have a look at [1]
> >>>>
> >>>>regards,
> >>>>gerhard
> >>>>
> >>>>[1] http://goo.gl/JTw1Q
> >>>>
> >>>>http://www.irian.at
> >>>>
> >>>>Your JSF powerhouse -
> >>>>JSF Consulting, Development and
> >>>>Courses in English and German
> >>>>
> >>>>Professional Support for Apache MyFaces
> >>>>
> >>>>
> >>>>
> >>>>2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> >>>>
> >>>>> Hi Rudy,
> >>>>>
> >>>>>
> >>>>>
> >>>>> You can use a portable Extension to achieve that. With the Extension
> you can
> >>>>> observe the ProcessAnnotatedType event, modify the AnnotatedType and
> add the
> >>>>> annotation.
> >>>>>
> >>>>>
> >>>>>
> >>>>> Regards,
> >>>>>
> >>>>> Arne
> >>>>>
> >>>>>
> >>>>>
> >>>>> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> >>>>> Gesendet: Donnerstag, 17. November 2011 12:43
> >>>>> An: user@openwebbeans.apache.org
> >>>>> Betreff: Programmaticly adding interceptors to CDI bean
> >>>>>
> >>>>>
> >>>>>
> >>>>> Hi all,
> >>>>>
> >>>>> I would like to add an interceptor to a method programmatical,
> without the
> >>>>> need for the annotation on the method.
> >>>>>
> >>>>> Point is that I have created a new scope and all methods of the bean
> >>>>> assigned to that scope should also be assigned an interceptor.  I
> would like
> >>>>> to do that automatically, so that the developer doesn't need to add
> the
> >>>>> annotation.
> >>>>>
> >>>>> I found the place in the code were OWB is performing the task but
> there
> >>>>> seems no portable way of doing this.
> >>>>>
> >>>>> Or is there another way of doing such functionality?
> >>>>>
> >>>>> Thx
> >>>>> regards
> >>>>> Rudy
> >>>>>
> >>>>> --
> >>>>> Rudy De Busscher
> >>>>> http://www.c4j.be
> >>>>
> >>>>
> >>>
> >>>
> >>>--
> >>>Rudy De Busscher
> >>>http://www.c4j.be
> >>>
> >>>
> >>>
> >>>
> >>
> >
> >
> >--
> >Rudy De Busscher
> >http://www.c4j.be
> >
> >
> >
> >
>



-- 
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Mark Struberg <st...@yahoo.de>.
Hi Rudy!

Thanks for the update and glad we could help!
Which version of Weld do you use?


LieGrue,
strub




>________________________________
> From: Rudy De Busscher <rd...@gmail.com>
>To: user@openwebbeans.apache.org 
>Sent: Friday, November 25, 2011 3:55 PM
>Subject: Re: Programmaticly adding interceptors to CDI bean
> 
>
>Hi all,
>
>Sorry that it took so long before I had time to continue on this.
>
>The proposed way to go (use ProcessAnnotatedType from within an Extension) is working. Only in my first attempt I didn't used a wrapped AnnotatedType.  But thanks to the examples of Gerhard and Mark, I was able to make a working version.
>
>At least with OWB. Weld doesn't execute an interceptor on a custom scoped bean. Even 'hardcoded' with the interceptor annotation on the bean method.
>
>Looking into that know, but that is not an issue for this mailing list.
>
>Thx
>Regards
>Rudy
>
>
>On 18 November 2011 11:51, Mark Struberg <st...@yahoo.de> wrote:
>
>Hi Rudy!
>>
>>Which OWB version are you using? With 1.1.2 all that stuff should work fine.
>>See here for an example where I do exactly that:
>>https://github.com/struberg/InterDyn
>>
>>
>>Please note that if you add the Interceptor annotation dynamically (via ProcessAnnotatedType), you STILL need to manually enable the <interceptors> in your beans.xml file!
>>
>>
>>LieGrue,
>>strub
>>
>>
>>
>>>________________________________
>>>From: Rudy De Busscher <rd...@gmail.com>
>>>To: user@openwebbeans.apache.org
>>>Sent: Thursday, November 17, 2011 9:38 PM
>>>Subject: Re: Programmaticly adding interceptors to CDI bean
>>
>>>
>>>
>>>@Arne,
>>>
>>>I tried to create something but it isn't working.
>>>
>>>I know now that you can also put the annotation of the interceptor at the class level and that all methods are then intercepted.
>>>
>>>So I tried to add the annotation to the ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the Extension. But this isn't used to determine the interceptors.
>>>
>>>In the method org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the annotations are taken from the Class itself, not from the Bean or AnnotatedType.
>>>
>>>@Gerhard
>>>I'll have a look at those classes to implement it.  But can't try it before the end of next week. (so no feedback before that)
>>>
>>>But now that I know that you can specify the interceptor annotation also at the class level, It is less important to add it programmaticly.  Adding it on one place by hand isn't too bad.
>>>
>>>Thx
>>>Rudy
>>>
>>>
>>>
>>>On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com> wrote:
>>>
>>>hi rudy,
>>>>
>>>>for adding an interceptor for a whole bean, you can have a look at [1]
>>>>
>>>>regards,
>>>>gerhard
>>>>
>>>>[1] http://goo.gl/JTw1Q
>>>>
>>>>http://www.irian.at
>>>>
>>>>Your JSF powerhouse -
>>>>JSF Consulting, Development and
>>>>Courses in English and German
>>>>
>>>>Professional Support for Apache MyFaces
>>>>
>>>>
>>>>
>>>>2011/11/17 Arne Limburg <ar...@openknowledge.de>:
>>>>
>>>>> Hi Rudy,
>>>>>
>>>>>  
>>>>>
>>>>> You can use a portable Extension to achieve that. With the Extension you can
>>>>> observe the ProcessAnnotatedType event, modify the AnnotatedType and add the
>>>>> annotation.
>>>>>
>>>>>  
>>>>>
>>>>> Regards,
>>>>>
>>>>> Arne
>>>>>
>>>>>  
>>>>>
>>>>> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
>>>>> Gesendet: Donnerstag, 17. November 2011 12:43
>>>>> An: user@openwebbeans.apache.org
>>>>> Betreff: Programmaticly adding interceptors to CDI bean
>>>>>
>>>>>  
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I would like to add an interceptor to a method programmatical, without the
>>>>> need for the annotation on the method.
>>>>>
>>>>> Point is that I have created a new scope and all methods of the bean
>>>>> assigned to that scope should also be assigned an interceptor.  I would like
>>>>> to do that automatically, so that the developer doesn't need to add the
>>>>> annotation.
>>>>>
>>>>> I found the place in the code were OWB is performing the task but there
>>>>> seems no portable way of doing this.
>>>>>
>>>>> Or is there another way of doing such functionality?
>>>>>
>>>>> Thx
>>>>> regards
>>>>> Rudy
>>>>>
>>>>> --
>>>>> Rudy De Busscher
>>>>> http://www.c4j.be
>>>>
>>>>
>>>
>>>
>>>--
>>>Rudy De Busscher
>>>http://www.c4j.be
>>>
>>>
>>>
>>>
>>
>
>
>-- 
>Rudy De Busscher
>http://www.c4j.be
>
>
>
>

Re: Programmaticly adding interceptors to CDI bean

Posted by Rudy De Busscher <rd...@gmail.com>.
Hi all,

Sorry that it took so long before I had time to continue on this.

The proposed way to go (use ProcessAnnotatedType from within an Extension)
is working. Only in my first attempt I didn't used a wrapped
AnnotatedType.  But thanks to the examples of Gerhard and Mark, I was able
to make a working version.

At least with OWB. Weld doesn't execute an interceptor on a custom scoped
bean. Even 'hardcoded' with the interceptor annotation on the bean method.

Looking into that know, but that is not an issue for this mailing list.

Thx
Regards
Rudy

On 18 November 2011 11:51, Mark Struberg <st...@yahoo.de> wrote:

> Hi Rudy!
>
> Which OWB version are you using? With 1.1.2 all that stuff should work
> fine.
> See here for an example where I do exactly that:
> https://github.com/struberg/InterDyn
>
>
> Please note that if you add the Interceptor annotation dynamically (via
> ProcessAnnotatedType), you STILL need to manually enable the <interceptors>
> in your beans.xml file!
>
>
> LieGrue,
> strub
>
>
>
> >________________________________
> >From: Rudy De Busscher <rd...@gmail.com>
> >To: user@openwebbeans.apache.org
> >Sent: Thursday, November 17, 2011 9:38 PM
> >Subject: Re: Programmaticly adding interceptors to CDI bean
> >
> >
> >@Arne,
> >
> >I tried to create something but it isn't working.
> >
> >I know now that you can also put the annotation of the interceptor at the
> class level and that all methods are then intercepted.
> >
> >So I tried to add the annotation to the
> ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the
> Extension. But this isn't used to determine the interceptors.
> >
> >In the method
> org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the
> annotations are taken from the Class itself, not from the Bean or
> AnnotatedType.
> >
> >@Gerhard
> >I'll have a look at those classes to implement it.  But can't try it
> before the end of next week. (so no feedback before that)
> >
> >But now that I know that you can specify the interceptor annotation also
> at the class level, It is less important to add it programmaticly.  Adding
> it on one place by hand isn't too bad.
> >
> >Thx
> >Rudy
> >
> >
> >
> >On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>
> wrote:
> >
> >hi rudy,
> >>
> >>for adding an interceptor for a whole bean, you can have a look at [1]
> >>
> >>regards,
> >>gerhard
> >>
> >>[1] http://goo.gl/JTw1Q
> >>
> >>http://www.irian.at
> >>
> >>Your JSF powerhouse -
> >>JSF Consulting, Development and
> >>Courses in English and German
> >>
> >>Professional Support for Apache MyFaces
> >>
> >>
> >>
> >>2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> >>
> >>> Hi Rudy,
> >>>
> >>>
> >>>
> >>> You can use a portable Extension to achieve that. With the Extension
> you can
> >>> observe the ProcessAnnotatedType event, modify the AnnotatedType and
> add the
> >>> annotation.
> >>>
> >>>
> >>>
> >>> Regards,
> >>>
> >>> Arne
> >>>
> >>>
> >>>
> >>> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> >>> Gesendet: Donnerstag, 17. November 2011 12:43
> >>> An: user@openwebbeans.apache.org
> >>> Betreff: Programmaticly adding interceptors to CDI bean
> >>>
> >>>
> >>>
> >>> Hi all,
> >>>
> >>> I would like to add an interceptor to a method programmatical, without
> the
> >>> need for the annotation on the method.
> >>>
> >>> Point is that I have created a new scope and all methods of the bean
> >>> assigned to that scope should also be assigned an interceptor.  I
> would like
> >>> to do that automatically, so that the developer doesn't need to add the
> >>> annotation.
> >>>
> >>> I found the place in the code were OWB is performing the task but there
> >>> seems no portable way of doing this.
> >>>
> >>> Or is there another way of doing such functionality?
> >>>
> >>> Thx
> >>> regards
> >>> Rudy
> >>>
> >>> --
> >>> Rudy De Busscher
> >>> http://www.c4j.be
> >>
> >>
> >
> >
> >--
> >Rudy De Busscher
> >http://www.c4j.be
> >
> >
> >
> >
>



-- 
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Mark Struberg <st...@yahoo.de>.
Hi Rudy!

Which OWB version are you using? With 1.1.2 all that stuff should work fine.
See here for an example where I do exactly that:
https://github.com/struberg/InterDyn


Please note that if you add the Interceptor annotation dynamically (via ProcessAnnotatedType), you STILL need to manually enable the <interceptors> in your beans.xml file!


LieGrue,
strub



>________________________________
>From: Rudy De Busscher <rd...@gmail.com>
>To: user@openwebbeans.apache.org
>Sent: Thursday, November 17, 2011 9:38 PM
>Subject: Re: Programmaticly adding interceptors to CDI bean
>
>
>@Arne,
>
>I tried to create something but it isn't working.
>
>I know now that you can also put the annotation of the interceptor at the class level and that all methods are then intercepted.
>
>So I tried to add the annotation to the ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the Extension. But this isn't used to determine the interceptors.
>
>In the method org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the annotations are taken from the Class itself, not from the Bean or AnnotatedType.
>
>@Gerhard
>I'll have a look at those classes to implement it.  But can't try it before the end of next week. (so no feedback before that)
>
>But now that I know that you can specify the interceptor annotation also at the class level, It is less important to add it programmaticly.  Adding it on one place by hand isn't too bad.
>
>Thx
>Rudy
>
>
>
>On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com> wrote:
>
>hi rudy,
>>
>>for adding an interceptor for a whole bean, you can have a look at [1]
>>
>>regards,
>>gerhard
>>
>>[1] http://goo.gl/JTw1Q
>>
>>http://www.irian.at
>>
>>Your JSF powerhouse -
>>JSF Consulting, Development and
>>Courses in English and German
>>
>>Professional Support for Apache MyFaces
>>
>>
>>
>>2011/11/17 Arne Limburg <ar...@openknowledge.de>:
>>
>>> Hi Rudy,
>>>
>>>  
>>>
>>> You can use a portable Extension to achieve that. With the Extension you can
>>> observe the ProcessAnnotatedType event, modify the AnnotatedType and add the
>>> annotation.
>>>
>>>  
>>>
>>> Regards,
>>>
>>> Arne
>>>
>>>  
>>>
>>> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
>>> Gesendet: Donnerstag, 17. November 2011 12:43
>>> An: user@openwebbeans.apache.org
>>> Betreff: Programmaticly adding interceptors to CDI bean
>>>
>>>  
>>>
>>> Hi all,
>>>
>>> I would like to add an interceptor to a method programmatical, without the
>>> need for the annotation on the method.
>>>
>>> Point is that I have created a new scope and all methods of the bean
>>> assigned to that scope should also be assigned an interceptor.  I would like
>>> to do that automatically, so that the developer doesn't need to add the
>>> annotation.
>>>
>>> I found the place in the code were OWB is performing the task but there
>>> seems no portable way of doing this.
>>>
>>> Or is there another way of doing such functionality?
>>>
>>> Thx
>>> regards
>>> Rudy
>>>
>>> --
>>> Rudy De Busscher
>>> http://www.c4j.be
>>
>>
>
>
>-- 
>Rudy De Busscher
>http://www.c4j.be
>
>
>
>

Re: Programmaticly adding interceptors to CDI bean

Posted by Rudy De Busscher <rd...@gmail.com>.
Gerhard,

I'm not saying that the CODI example isn't working anymore.  The proposal
of Arne wasn't working.  When I have the time next week, I'll check the
example of CODI.

Rudy

On 17 November 2011 21:50, Gerhard Petracek <ge...@gmail.com>wrote:

> hi,
>
> i haven't tested it with the latest version of owb, however, it used
> to work (you can see it in the example).
>
> regards,
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
> 2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> > Hi Rudy,
> >
> >
> >
> > Good to hear that the class-level-solution works for you. Btw. that the
> > annotation from ProcessAnnotatedType are not used to determine the
> > interceptor binding is a bug imho, at least it will be with CDI 1.1.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> > Gesendet: Donnerstag, 17. November 2011 21:38
> > An: user@openwebbeans.apache.org
> > Betreff: Re: Programmaticly adding interceptors to CDI bean
> >
> >
> >
> > @Arne,
> >
> > I tried to create something but it isn't working.
> >
> > I know now that you can also put the annotation of the interceptor at the
> > class level and that all methods are then intercepted.
> >
> > So I tried to add the annotation to the
> > ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the
> > Extension. But this isn't used to determine the interceptors.
> >
> > In the method
> > org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the
> > annotations are taken from the Class itself, not from the Bean or
> > AnnotatedType.
> >
> > @Gerhard
> > I'll have a look at those classes to implement it.  But can't try it
> before
> > the end of next week. (so no feedback before that)
> >
> > But now that I know that you can specify the interceptor annotation also
> at
> > the class level, It is less important to add it programmaticly.  Adding
> it
> > on one place by hand isn't too bad.
> >
> > Thx
> > Rudy
> >
> > On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>
> > wrote:
> >
> > hi rudy,
> >
> > for adding an interceptor for a whole bean, you can have a look at [1]
> >
> > regards,
> > gerhard
> >
> > [1] http://goo.gl/JTw1Q
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> >
> >> Hi Rudy,
> >>
> >>
> >>
> >> You can use a portable Extension to achieve that. With the Extension you
> >> can
> >> observe the ProcessAnnotatedType event, modify the AnnotatedType and add
> >> the
> >> annotation.
> >>
> >>
> >>
> >> Regards,
> >>
> >> Arne
> >>
> >>
> >>
> >> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> >> Gesendet: Donnerstag, 17. November 2011 12:43
> >> An: user@openwebbeans.apache.org
> >> Betreff: Programmaticly adding interceptors to CDI bean
> >>
> >>
> >>
> >> Hi all,
> >>
> >> I would like to add an interceptor to a method programmatical, without
> the
> >> need for the annotation on the method.
> >>
> >> Point is that I have created a new scope and all methods of the bean
> >> assigned to that scope should also be assigned an interceptor.  I would
> >> like
> >> to do that automatically, so that the developer doesn't need to add the
> >> annotation.
> >>
> >> I found the place in the code were OWB is performing the task but there
> >> seems no portable way of doing this.
> >>
> >> Or is there another way of doing such functionality?
> >>
> >> Thx
> >> regards
> >> Rudy
> >>
> >> --
> >> Rudy De Busscher
> >> http://www.c4j.be
> >
> >
> > --
> > Rudy De Busscher
> > http://www.c4j.be
>



-- 
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Gerhard Petracek <ge...@gmail.com>.
hi,

i haven't tested it with the latest version of owb, however, it used
to work (you can see it in the example).

regards,
gerhard

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> Hi Rudy,
>
>
>
> Good to hear that the class-level-solution works for you. Btw. that the
> annotation from ProcessAnnotatedType are not used to determine the
> interceptor binding is a bug imho, at least it will be with CDI 1.1.
>
>
>
> Regards,
>
> Arne
>
>
>
> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> Gesendet: Donnerstag, 17. November 2011 21:38
> An: user@openwebbeans.apache.org
> Betreff: Re: Programmaticly adding interceptors to CDI bean
>
>
>
> @Arne,
>
> I tried to create something but it isn't working.
>
> I know now that you can also put the annotation of the interceptor at the
> class level and that all methods are then intercepted.
>
> So I tried to add the annotation to the
> ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the
> Extension. But this isn't used to determine the interceptors.
>
> In the method
> org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the
> annotations are taken from the Class itself, not from the Bean or
> AnnotatedType.
>
> @Gerhard
> I'll have a look at those classes to implement it.  But can't try it before
> the end of next week. (so no feedback before that)
>
> But now that I know that you can specify the interceptor annotation also at
> the class level, It is less important to add it programmaticly.  Adding it
> on one place by hand isn't too bad.
>
> Thx
> Rudy
>
> On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>
> wrote:
>
> hi rudy,
>
> for adding an interceptor for a whole bean, you can have a look at [1]
>
> regards,
> gerhard
>
> [1] http://goo.gl/JTw1Q
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
> 2011/11/17 Arne Limburg <ar...@openknowledge.de>:
>
>> Hi Rudy,
>>
>>
>>
>> You can use a portable Extension to achieve that. With the Extension you
>> can
>> observe the ProcessAnnotatedType event, modify the AnnotatedType and add
>> the
>> annotation.
>>
>>
>>
>> Regards,
>>
>> Arne
>>
>>
>>
>> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
>> Gesendet: Donnerstag, 17. November 2011 12:43
>> An: user@openwebbeans.apache.org
>> Betreff: Programmaticly adding interceptors to CDI bean
>>
>>
>>
>> Hi all,
>>
>> I would like to add an interceptor to a method programmatical, without the
>> need for the annotation on the method.
>>
>> Point is that I have created a new scope and all methods of the bean
>> assigned to that scope should also be assigned an interceptor.  I would
>> like
>> to do that automatically, so that the developer doesn't need to add the
>> annotation.
>>
>> I found the place in the code were OWB is performing the task but there
>> seems no portable way of doing this.
>>
>> Or is there another way of doing such functionality?
>>
>> Thx
>> regards
>> Rudy
>>
>> --
>> Rudy De Busscher
>> http://www.c4j.be
>
>
> --
> Rudy De Busscher
> http://www.c4j.be

AW: Programmaticly adding interceptors to CDI bean

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi Rudy,

Good to hear that the class-level-solution works for you. Btw. that the annotation from ProcessAnnotatedType are not used to determine the interceptor binding is a bug imho, at least it will be with CDI 1.1.

Regards,
Arne

Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
Gesendet: Donnerstag, 17. November 2011 21:38
An: user@openwebbeans.apache.org
Betreff: Re: Programmaticly adding interceptors to CDI bean

@Arne,

I tried to create something but it isn't working.

I know now that you can also put the annotation of the interceptor at the class level and that all methods are then intercepted.

So I tried to add the annotation to the ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the Extension. But this isn't used to determine the interceptors.

In the method org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the annotations are taken from the Class itself, not from the Bean or AnnotatedType.

@Gerhard
I'll have a look at those classes to implement it.  But can't try it before the end of next week. (so no feedback before that)

But now that I know that you can specify the interceptor annotation also at the class level, It is less important to add it programmaticly.  Adding it on one place by hand isn't too bad.

Thx
Rudy

On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>> wrote:
hi rudy,

for adding an interceptor for a whole bean, you can have a look at [1]

regards,
gerhard

[1] http://goo.gl/JTw1Q

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2011/11/17 Arne Limburg <ar...@openknowledge.de>>:

> Hi Rudy,
>
>
>
> You can use a portable Extension to achieve that. With the Extension you can
> observe the ProcessAnnotatedType event, modify the AnnotatedType and add the
> annotation.
>
>
>
> Regards,
>
> Arne
>
>
>
> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com<ma...@gmail.com>]
> Gesendet: Donnerstag, 17. November 2011 12:43
> An: user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>
> Betreff: Programmaticly adding interceptors to CDI bean
>
>
>
> Hi all,
>
> I would like to add an interceptor to a method programmatical, without the
> need for the annotation on the method.
>
> Point is that I have created a new scope and all methods of the bean
> assigned to that scope should also be assigned an interceptor.  I would like
> to do that automatically, so that the developer doesn't need to add the
> annotation.
>
> I found the place in the code were OWB is performing the task but there
> seems no portable way of doing this.
>
> Or is there another way of doing such functionality?
>
> Thx
> regards
> Rudy
>
> --
> Rudy De Busscher
> http://www.c4j.be



--
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Rudy De Busscher <rd...@gmail.com>.
@Arne,

I tried to create something but it isn't working.

I know now that you can also put the annotation of the interceptor at the
class level and that all methods are then intercepted.

So I tried to add the annotation to the
ProcessAnnotatedType.getAnnotatedType().getAnnotations() list in the
Extension. But this isn't used to determine the interceptors.

In the method
org.apache.webbeans.intercept.WebBeansInterceptorConfig#configure, the
annotations are taken from the Class itself, not from the Bean or
AnnotatedType.

@Gerhard
I'll have a look at those classes to implement it.  But can't try it before
the end of next week. (so no feedback before that)

But now that I know that you can specify the interceptor annotation also at
the class level, It is less important to add it programmaticly.  Adding it
on one place by hand isn't too bad.

Thx
Rudy


On 17 November 2011 17:26, Gerhard Petracek <ge...@gmail.com>wrote:

> hi rudy,
>
> for adding an interceptor for a whole bean, you can have a look at [1]
>
> regards,
> gerhard
>
> [1] http://goo.gl/JTw1Q
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
> 2011/11/17 Arne Limburg <ar...@openknowledge.de>:
>
> > Hi Rudy,
> >
> >
> >
> > You can use a portable Extension to achieve that. With the Extension you
> can
> > observe the ProcessAnnotatedType event, modify the AnnotatedType and add
> the
> > annotation.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> > Gesendet: Donnerstag, 17. November 2011 12:43
> > An: user@openwebbeans.apache.org
> > Betreff: Programmaticly adding interceptors to CDI bean
> >
> >
> >
> > Hi all,
> >
> > I would like to add an interceptor to a method programmatical, without
> the
> > need for the annotation on the method.
> >
> > Point is that I have created a new scope and all methods of the bean
> > assigned to that scope should also be assigned an interceptor.  I would
> like
> > to do that automatically, so that the developer doesn't need to add the
> > annotation.
> >
> > I found the place in the code were OWB is performing the task but there
> > seems no portable way of doing this.
> >
> > Or is there another way of doing such functionality?
> >
> > Thx
> > regards
> > Rudy
> >
> > --
> > Rudy De Busscher
> > http://www.c4j.be
>
>


-- 
Rudy De Busscher
http://www.c4j.be

Re: Programmaticly adding interceptors to CDI bean

Posted by Gerhard Petracek <ge...@gmail.com>.
hi rudy,

for adding an interceptor for a whole bean, you can have a look at [1]

regards,
gerhard

[1] http://goo.gl/JTw1Q

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2011/11/17 Arne Limburg <ar...@openknowledge.de>:
> Hi Rudy,
>
>
>
> You can use a portable Extension to achieve that. With the Extension you
can
> observe the ProcessAnnotatedType event, modify the AnnotatedType and add
the
> annotation.
>
>
>
> Regards,
>
> Arne
>
>
>
> Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
> Gesendet: Donnerstag, 17. November 2011 12:43
> An: user@openwebbeans.apache.org
> Betreff: Programmaticly adding interceptors to CDI bean
>
>
>
> Hi all,
>
> I would like to add an interceptor to a method programmatical, without the
> need for the annotation on the method.
>
> Point is that I have created a new scope and all methods of the bean
> assigned to that scope should also be assigned an interceptor.  I would
like
> to do that automatically, so that the developer doesn't need to add the
> annotation.
>
> I found the place in the code were OWB is performing the task but there
> seems no portable way of doing this.
>
> Or is there another way of doing such functionality?
>
> Thx
> regards
> Rudy
>
> --
> Rudy De Busscher
> http://www.c4j.be

AW: Programmaticly adding interceptors to CDI bean

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi Rudy,

You can use a portable Extension to achieve that. With the Extension you can observe the ProcessAnnotatedType event, modify the AnnotatedType and add the annotation.

Regards,
Arne

Von: Rudy De Busscher [mailto:rdebusscher@gmail.com]
Gesendet: Donnerstag, 17. November 2011 12:43
An: user@openwebbeans.apache.org
Betreff: Programmaticly adding interceptors to CDI bean

Hi all,

I would like to add an interceptor to a method programmatical, without the need for the annotation on the method.

Point is that I have created a new scope and all methods of the bean assigned to that scope should also be assigned an interceptor.  I would like to do that automatically, so that the developer doesn't need to add the annotation.

I found the place in the code were OWB is performing the task but there seems no portable way of doing this.

Or is there another way of doing such functionality?

Thx
regards
Rudy

--
Rudy De Busscher
http://www.c4j.be