You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by hantsy <ha...@yahoo.com.cn> on 2012/12/28 03:25:27 UTC

How to replace and disable Interceptor at runtime.

Hi all,

I know there are some way to use alternative Managed Bean at runtime in
CDI. but how to process Interceptor.

1. I want to use custom Interceptor(esp extended from the Interceptor
and provides some different behavior) instead of the one shipped by some
framework/tools at runtime ?

2. How to disable an interceptor at runtime for one ManagedBean(like
Seam 2 bypass annotation), and disable it globally?


Hantsy

Re: How to replace and disable Interceptor at runtime.

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


As I said, the use case would be migration scenarios. I know big seam 2
projects that want to move do CDI and have big problems in going through
every usage of @BypassInterceptors to figure out, if it was used for
business logic reasons (i.e. to switch of transactions for that use case)
or if it was just for performance reasons.

For CDI one could imagine that there are use cases, too, where
@BypassInterceptors could be helpful. Think of a stereotype that defines
interceptor bindings and you have a bean with that stereotype and have
just one method where you don't want that interceptors.

So imho use cases are there, but I don't like @BypassInterceptors from an
architectural point of view, too.
So I am +-0 for adding it.

Cheers,
Arne

Am 29.12.12 22:30 schrieb "Cody Lerum" unter <co...@gmail.com>:

>+1 Jason
>
>
>On Sat, Dec 29, 2012 at 11:22 AM, Jason Porter
><li...@gmail.com>wrote:
>
>> Arne: I'm not quite sure I see the point in doing this. Interceptors in
>> Seam2 were completely different than in CDI. If you don't want an
>> interceptor, remove the annotation, or take it out of the beans.xml.
>>
>> I also don't see a use case for @BypassInterceptors. If there's a use
>>case
>> for it, then we can consider it, but I don't want to start adding
>>things to
>> DeltaSpike without clearly defined use cases.
>>
>>
>> On Sat, Dec 29, 2012 at 3:13 AM, Arne Limburg <
>> arne.limburg@openknowledge.de
>> > wrote:
>>
>> > Hi Hantsy,
>> >
>> >
>> > In general you could write an extension that modifies the
>>AnnotatedType
>> to
>> > remove the annotation that declares the interceptor binding.
>> >
>> > @all We should think about supporting @BypassInterceptors in
>>Deltaspike,
>> > wdyt?
>> > Not that I like this "feature" of Seam 2 that much (imho it works
>>around
>> > some design flaws of Seam 2), but it would make a migration from Seam
>>2
>> to
>> > Deltaspike much easier.
>> >
>> > Cheers,
>> > Arne
>> >
>> > Am 29.12.12 03:29 schrieb "hantsy" unter <ha...@yahoo.com.cn>:
>> >
>> > >Thanks, gerhard. Is there a way to disable interceptors globally or
>> > >bypass some interceptors on certain managed beans?
>> > >
>> > >Hantsy
>> > >
>> > >On 12/28/2012 10:39, Gerhard Petracek wrote:
>> > >> hi hantsy,
>> > >>
>> > >> in deltaspike (and codi) we are using interceptor-strategies which
>> > >>allow to
>> > >> provide alternative (/specialized) interceptor-implementations (see
>> > >> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the
>> usage
>> > >>of
>> > >> it).
>> > >>
>> > >> regards,
>> > >> gerhard
>> > >>
>> > >>
>> > >>
>> > >> 2012/12/28 hantsy <ha...@yahoo.com.cn>
>> > >>
>> > >>> Hi all,
>> > >>>
>> > >>> I know there are some way to use alternative Managed Bean at
>>runtime
>> in
>> > >>> CDI. but how to process Interceptor.
>> > >>>
>> > >>> 1. I want to use custom Interceptor(esp extended from the
>>Interceptor
>> > >>> and provides some different behavior) instead of the one shipped
>>by
>> > >>>some
>> > >>> framework/tools at runtime ?
>> > >>>
>> > >>> 2. How to disable an interceptor at runtime for one
>>ManagedBean(like
>> > >>> Seam 2 bypass annotation), and disable it globally?
>> > >>>
>> > >>>
>> > >>> Hantsy
>> > >>>
>> > >
>> >
>> >
>>
>>
>> --
>> Jason Porter
>> http://lightguard-jp.blogspot.com
>> http://twitter.com/lightguardjp
>>
>> Software Engineer
>> Open Source Advocate
>>
>> PGP key id: 926CCFF5
>> PGP key available at: keyserver.net, pgp.mit.edu
>>


Re: How to replace and disable Interceptor at runtime.

Posted by Cody Lerum <co...@gmail.com>.
+1 Jason


On Sat, Dec 29, 2012 at 11:22 AM, Jason Porter <li...@gmail.com>wrote:

> Arne: I'm not quite sure I see the point in doing this. Interceptors in
> Seam2 were completely different than in CDI. If you don't want an
> interceptor, remove the annotation, or take it out of the beans.xml.
>
> I also don't see a use case for @BypassInterceptors. If there's a use case
> for it, then we can consider it, but I don't want to start adding things to
> DeltaSpike without clearly defined use cases.
>
>
> On Sat, Dec 29, 2012 at 3:13 AM, Arne Limburg <
> arne.limburg@openknowledge.de
> > wrote:
>
> > Hi Hantsy,
> >
> >
> > In general you could write an extension that modifies the AnnotatedType
> to
> > remove the annotation that declares the interceptor binding.
> >
> > @all We should think about supporting @BypassInterceptors in Deltaspike,
> > wdyt?
> > Not that I like this "feature" of Seam 2 that much (imho it works around
> > some design flaws of Seam 2), but it would make a migration from Seam 2
> to
> > Deltaspike much easier.
> >
> > Cheers,
> > Arne
> >
> > Am 29.12.12 03:29 schrieb "hantsy" unter <ha...@yahoo.com.cn>:
> >
> > >Thanks, gerhard. Is there a way to disable interceptors globally or
> > >bypass some interceptors on certain managed beans?
> > >
> > >Hantsy
> > >
> > >On 12/28/2012 10:39, Gerhard Petracek wrote:
> > >> hi hantsy,
> > >>
> > >> in deltaspike (and codi) we are using interceptor-strategies which
> > >>allow to
> > >> provide alternative (/specialized) interceptor-implementations (see
> > >> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the
> usage
> > >>of
> > >> it).
> > >>
> > >> regards,
> > >> gerhard
> > >>
> > >>
> > >>
> > >> 2012/12/28 hantsy <ha...@yahoo.com.cn>
> > >>
> > >>> Hi all,
> > >>>
> > >>> I know there are some way to use alternative Managed Bean at runtime
> in
> > >>> CDI. but how to process Interceptor.
> > >>>
> > >>> 1. I want to use custom Interceptor(esp extended from the Interceptor
> > >>> and provides some different behavior) instead of the one shipped by
> > >>>some
> > >>> framework/tools at runtime ?
> > >>>
> > >>> 2. How to disable an interceptor at runtime for one ManagedBean(like
> > >>> Seam 2 bypass annotation), and disable it globally?
> > >>>
> > >>>
> > >>> Hantsy
> > >>>
> > >
> >
> >
>
>
> --
> Jason Porter
> http://lightguard-jp.blogspot.com
> http://twitter.com/lightguardjp
>
> Software Engineer
> Open Source Advocate
>
> PGP key id: 926CCFF5
> PGP key available at: keyserver.net, pgp.mit.edu
>

Re: How to replace and disable Interceptor at runtime.

Posted by Gerhard Petracek <ge...@gmail.com>.
i agree with jason (and that's also what we have done so far).

regards,
gerhard



2012/12/29 Jason Porter <li...@gmail.com>

> Arne: I'm not quite sure I see the point in doing this. Interceptors in
> Seam2 were completely different than in CDI. If you don't want an
> interceptor, remove the annotation, or take it out of the beans.xml.
>
> I also don't see a use case for @BypassInterceptors. If there's a use case
> for it, then we can consider it, but I don't want to start adding things to
> DeltaSpike without clearly defined use cases.
>
>
> On Sat, Dec 29, 2012 at 3:13 AM, Arne Limburg <
> arne.limburg@openknowledge.de
> > wrote:
>
> > Hi Hantsy,
> >
> >
> > In general you could write an extension that modifies the AnnotatedType
> to
> > remove the annotation that declares the interceptor binding.
> >
> > @all We should think about supporting @BypassInterceptors in Deltaspike,
> > wdyt?
> > Not that I like this "feature" of Seam 2 that much (imho it works around
> > some design flaws of Seam 2), but it would make a migration from Seam 2
> to
> > Deltaspike much easier.
> >
> > Cheers,
> > Arne
> >
> > Am 29.12.12 03:29 schrieb "hantsy" unter <ha...@yahoo.com.cn>:
> >
> > >Thanks, gerhard. Is there a way to disable interceptors globally or
> > >bypass some interceptors on certain managed beans?
> > >
> > >Hantsy
> > >
> > >On 12/28/2012 10:39, Gerhard Petracek wrote:
> > >> hi hantsy,
> > >>
> > >> in deltaspike (and codi) we are using interceptor-strategies which
> > >>allow to
> > >> provide alternative (/specialized) interceptor-implementations (see
> > >> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the
> usage
> > >>of
> > >> it).
> > >>
> > >> regards,
> > >> gerhard
> > >>
> > >>
> > >>
> > >> 2012/12/28 hantsy <ha...@yahoo.com.cn>
> > >>
> > >>> Hi all,
> > >>>
> > >>> I know there are some way to use alternative Managed Bean at runtime
> in
> > >>> CDI. but how to process Interceptor.
> > >>>
> > >>> 1. I want to use custom Interceptor(esp extended from the Interceptor
> > >>> and provides some different behavior) instead of the one shipped by
> > >>>some
> > >>> framework/tools at runtime ?
> > >>>
> > >>> 2. How to disable an interceptor at runtime for one ManagedBean(like
> > >>> Seam 2 bypass annotation), and disable it globally?
> > >>>
> > >>>
> > >>> Hantsy
> > >>>
> > >
> >
> >
>
>
> --
> Jason Porter
> http://lightguard-jp.blogspot.com
> http://twitter.com/lightguardjp
>
> Software Engineer
> Open Source Advocate
>
> PGP key id: 926CCFF5
> PGP key available at: keyserver.net, pgp.mit.edu
>

Re: How to replace and disable Interceptor at runtime.

Posted by Jason Porter <li...@gmail.com>.
Arne: I'm not quite sure I see the point in doing this. Interceptors in
Seam2 were completely different than in CDI. If you don't want an
interceptor, remove the annotation, or take it out of the beans.xml.

I also don't see a use case for @BypassInterceptors. If there's a use case
for it, then we can consider it, but I don't want to start adding things to
DeltaSpike without clearly defined use cases.


On Sat, Dec 29, 2012 at 3:13 AM, Arne Limburg <arne.limburg@openknowledge.de
> wrote:

> Hi Hantsy,
>
>
> In general you could write an extension that modifies the AnnotatedType to
> remove the annotation that declares the interceptor binding.
>
> @all We should think about supporting @BypassInterceptors in Deltaspike,
> wdyt?
> Not that I like this "feature" of Seam 2 that much (imho it works around
> some design flaws of Seam 2), but it would make a migration from Seam 2 to
> Deltaspike much easier.
>
> Cheers,
> Arne
>
> Am 29.12.12 03:29 schrieb "hantsy" unter <ha...@yahoo.com.cn>:
>
> >Thanks, gerhard. Is there a way to disable interceptors globally or
> >bypass some interceptors on certain managed beans?
> >
> >Hantsy
> >
> >On 12/28/2012 10:39, Gerhard Petracek wrote:
> >> hi hantsy,
> >>
> >> in deltaspike (and codi) we are using interceptor-strategies which
> >>allow to
> >> provide alternative (/specialized) interceptor-implementations (see
> >> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage
> >>of
> >> it).
> >>
> >> regards,
> >> gerhard
> >>
> >>
> >>
> >> 2012/12/28 hantsy <ha...@yahoo.com.cn>
> >>
> >>> Hi all,
> >>>
> >>> I know there are some way to use alternative Managed Bean at runtime in
> >>> CDI. but how to process Interceptor.
> >>>
> >>> 1. I want to use custom Interceptor(esp extended from the Interceptor
> >>> and provides some different behavior) instead of the one shipped by
> >>>some
> >>> framework/tools at runtime ?
> >>>
> >>> 2. How to disable an interceptor at runtime for one ManagedBean(like
> >>> Seam 2 bypass annotation), and disable it globally?
> >>>
> >>>
> >>> Hantsy
> >>>
> >
>
>


-- 
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp

Software Engineer
Open Source Advocate

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu

Re: How to replace and disable Interceptor at runtime.

Posted by Mark Struberg <st...@yahoo.de>.
Either by providing an empty InterceptorStrategy or by dynamically removing the interceptor annotation from the beans via a CDI exension.

Or just remove them from the beans.xml.

LieGrue,
strub




----- Original Message -----
> From: hantsy <ha...@yahoo.com.cn>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Saturday, December 29, 2012 3:29 AM
> Subject: Re: How to replace and disable Interceptor at runtime.
> 
>T hanks, gerhard. Is there a way to disable interceptors globally or
> bypass some interceptors on certain managed beans?
> 
> Hantsy
> 
> On 12/28/2012 10:39, Gerhard Petracek wrote:
>>  hi hantsy,
>> 
>>  in deltaspike (and codi) we are using interceptor-strategies which allow to
>>  provide alternative (/specialized) interceptor-implementations (see
>>  org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage of
>>  it).
>> 
>>  regards,
>>  gerhard
>> 
>> 
>> 
>>  2012/12/28 hantsy <ha...@yahoo.com.cn>
>> 
>>>  Hi all,
>>> 
>>>  I know there are some way to use alternative Managed Bean at runtime in
>>>  CDI. but how to process Interceptor.
>>> 
>>>  1. I want to use custom Interceptor(esp extended from the Interceptor
>>>  and provides some different behavior) instead of the one shipped by 
> some
>>>  framework/tools at runtime ?
>>> 
>>>  2. How to disable an interceptor at runtime for one ManagedBean(like
>>>  Seam 2 bypass annotation), and disable it globally?
>>> 
>>> 
>>>  Hantsy
>>> 
> 

Re: How to replace and disable Interceptor at runtime.

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


In general you could write an extension that modifies the AnnotatedType to
remove the annotation that declares the interceptor binding.

@all We should think about supporting @BypassInterceptors in Deltaspike,
wdyt?
Not that I like this "feature" of Seam 2 that much (imho it works around
some design flaws of Seam 2), but it would make a migration from Seam 2 to
Deltaspike much easier.

Cheers,
Arne

Am 29.12.12 03:29 schrieb "hantsy" unter <ha...@yahoo.com.cn>:

>Thanks, gerhard. Is there a way to disable interceptors globally or
>bypass some interceptors on certain managed beans?
>
>Hantsy
>
>On 12/28/2012 10:39, Gerhard Petracek wrote:
>> hi hantsy,
>>
>> in deltaspike (and codi) we are using interceptor-strategies which
>>allow to
>> provide alternative (/specialized) interceptor-implementations (see
>> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage
>>of
>> it).
>>
>> regards,
>> gerhard
>>
>>
>>
>> 2012/12/28 hantsy <ha...@yahoo.com.cn>
>>
>>> Hi all,
>>>
>>> I know there are some way to use alternative Managed Bean at runtime in
>>> CDI. but how to process Interceptor.
>>>
>>> 1. I want to use custom Interceptor(esp extended from the Interceptor
>>> and provides some different behavior) instead of the one shipped by
>>>some
>>> framework/tools at runtime ?
>>>
>>> 2. How to disable an interceptor at runtime for one ManagedBean(like
>>> Seam 2 bypass annotation), and disable it globally?
>>>
>>>
>>> Hantsy
>>>
>


Re: How to replace and disable Interceptor at runtime.

Posted by hantsy <ha...@yahoo.com.cn>.
Thanks, gerhard. Is there a way to disable interceptors globally or
bypass some interceptors on certain managed beans?

Hantsy

On 12/28/2012 10:39, Gerhard Petracek wrote:
> hi hantsy,
>
> in deltaspike (and codi) we are using interceptor-strategies which allow to
> provide alternative (/specialized) interceptor-implementations (see
> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage of
> it).
>
> regards,
> gerhard
>
>
>
> 2012/12/28 hantsy <ha...@yahoo.com.cn>
>
>> Hi all,
>>
>> I know there are some way to use alternative Managed Bean at runtime in
>> CDI. but how to process Interceptor.
>>
>> 1. I want to use custom Interceptor(esp extended from the Interceptor
>> and provides some different behavior) instead of the one shipped by some
>> framework/tools at runtime ?
>>
>> 2. How to disable an interceptor at runtime for one ManagedBean(like
>> Seam 2 bypass annotation), and disable it globally?
>>
>>
>> Hantsy
>>


Re: How to replace and disable Interceptor at runtime.

Posted by Mark Struberg <st...@yahoo.de>.
To explain this a bit more in depth. 
Our interceptors are pretty much stupid :)

They just forward the _real_ work to a @Dependent CDI bean which does all the work

@Inject TheRealWorker worker:

@AroundInvoke
public Object interceptIt(InvocationContext ic) throws Exception {
  return worker.execute(ic);
}


TheRealWorker implements InterceptorStrategy and is usually @Dependent scoped.
That way we can provide an @Alternative or @Specializes for those injected strategies.


LieGrue,
strub




----- Original Message -----
> From: Gerhard Petracek <ge...@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Friday, December 28, 2012 3:39 AM
> Subject: Re: How to replace and disable Interceptor at runtime.
> 
> hi hantsy,
> 
> in deltaspike (and codi) we are using interceptor-strategies which allow to
> provide alternative (/specialized) interceptor-implementations (see
> org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage of
> it).
> 
> regards,
> gerhard
> 
> 
> 
> 2012/12/28 hantsy <ha...@yahoo.com.cn>
> 
>>  Hi all,
>> 
>>  I know there are some way to use alternative Managed Bean at runtime in
>>  CDI. but how to process Interceptor.
>> 
>>  1. I want to use custom Interceptor(esp extended from the Interceptor
>>  and provides some different behavior) instead of the one shipped by some
>>  framework/tools at runtime ?
>> 
>>  2. How to disable an interceptor at runtime for one ManagedBean(like
>>  Seam 2 bypass annotation), and disable it globally?
>> 
>> 
>>  Hantsy
>> 
> 

Re: How to replace and disable Interceptor at runtime.

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

in deltaspike (and codi) we are using interceptor-strategies which allow to
provide alternative (/specialized) interceptor-implementations (see
org.apache.deltaspike.core.spi.InterceptorStrategy as well as the usage of
it).

regards,
gerhard



2012/12/28 hantsy <ha...@yahoo.com.cn>

> Hi all,
>
> I know there are some way to use alternative Managed Bean at runtime in
> CDI. but how to process Interceptor.
>
> 1. I want to use custom Interceptor(esp extended from the Interceptor
> and provides some different behavior) instead of the one shipped by some
> framework/tools at runtime ?
>
> 2. How to disable an interceptor at runtime for one ManagedBean(like
> Seam 2 bypass annotation), and disable it globally?
>
>
> Hantsy
>