You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2013/11/05 09:58:17 UTC

InterceptorListeners

Hi,

What do you think about adding possibility to create listeners which
will be executed before/after given interceptor?

Something like this:

public interface InterceptorListener {

    boolean accept(InterceptorMapping mapping);

    void beforeInterceptor(ActionInvocation invocation);

    void afterInterceptor(ActionInvocation invocation);

}

You can define them as a beens in struts.xml

<bean type="com.opensymphony.xwork2.interceptor.InterceptorListener"
class="com.demo.MyInterceptorListener"/>


There are already few interceptors defined:

https://cwiki.apache.org/confluence/display/WW/ActionEventListener
https://cwiki.apache.org/confluence/display/WW/DispatcherListener
https://cwiki.apache.org/confluence/display/WW/PreResultListener


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Steven Benitez <st...@gmail.com>.
I just wrote a long reply on why I don't think this API makes any sense and
how I don't follow the arguments in favor of it, but I scrapped it because
I could distill it down to the following:

"When in doubt, leave it out." -- Josh Bloch

Regards,
Steven


On Tue, Nov 5, 2013 at 9:23 AM, Ali Akhtar <al...@gmail.com> wrote:

> There's one case where it may be useful to have these listeners. Suppose if
> you have a lot of packages, and you just need to modify one or two
> interceptors in each package. You would have to paste your whole
> interceptor stack in order to do this.
>
> I think this feature could be useful for such cases.
>
>
> On Tue, Nov 5, 2013 at 7:13 PM, <um...@gmail.com> wrote:
>
> > I am agree with Steven, existing API is really good.
> > We need to put more work of documents and showing user how to use or
> > modify existing API.
> >
> >
> >
> > Thanks
> > Umesh
> > Sent from BlackBerry® on Airtel
> >
> > -----Original Message-----
> > From: Steven Benitez <st...@gmail.com>
> > Date: Tue, 5 Nov 2013 09:00:14
> > To: Struts Developers List<de...@struts.apache.org>
> > Reply-To: "Struts Developers List" <de...@struts.apache.org>
> > Subject: Re: InterceptorListeners
> >
> > I feel pretty strongly that we should not broaden the API to accommodate
> > users who don't know how to use the existing API, which is really pretty
> > straight forward. We'd be better off educating users how the existing
> > interceptor API works rather than introducing new complexity.
> >
> >
> > On Tue, Nov 5, 2013 at 4:11 AM, Lukasz Lenart <lukaszlenart@apache.org
> > >wrote:
> >
> > > 2013/11/5 Steven Benitez <st...@gmail.com>:
> > > > Why not just create an interceptor and run it before or after the
> > > > interceptor you need? What specific use case does this address?
> > >
> > > You are perfectly right, it's the prefer way to achieve the same
> > behaviour.
> > >
> > > But there are some users which just stick with defaultStack or
> > > cannot/don't know how to modify the defaultStack - and it's solution
> > > just for them. Maybe I'm wrong and we should educated users to don't
> > > stick with default stack and always prepare their own stack (at least
> > > to improve performance).
> > >
> > >
> > > Regards
> > > --
> > > Łukasz
> > > + 48 606 323 122 http://www.lenart.org.pl/
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: dev-help@struts.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>

Re: InterceptorListeners

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/6 Ali Akhtar <al...@gmail.com>:
> I'd be in favor of your proposal if it could be defined per package / per
> stack.

I have checked that and it isn't possible or rather it isn't easily
possible to implement such logic.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Ali Akhtar <al...@gmail.com>.
I'd be in favor of your proposal if it could be defined per package / per
stack.


On Wed, Nov 6, 2013 at 3:16 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2013/11/6 Ali Akhtar <al...@gmail.com>:
> > Right, but say you wanted to change the order slightly or insert one
> > interceptor before / after one from the top package. Now you'd have to
> copy
> > the whole stack to the other package.
>
> So then you should define few stacks as it's done in struts-default.xml
> And in my proposal listener will work independently from packages and
> stacks - it will be applied to each interceptor (depending on how
> accept() method will be implemented)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: InterceptorListeners

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/6 Ali Akhtar <al...@gmail.com>:
> Right, but say you wanted to change the order slightly or insert one
> interceptor before / after one from the top package. Now you'd have to copy
> the whole stack to the other package.

So then you should define few stacks as it's done in struts-default.xml
And in my proposal listener will work independently from packages and
stacks - it will be applied to each interceptor (depending on how
accept() method will be implemented)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Ali Akhtar <al...@gmail.com>.
Right, but say you wanted to change the order slightly or insert one
interceptor before / after one from the top package. Now you'd have to copy
the whole stack to the other package.


On Wed, Nov 6, 2013 at 2:20 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2013/11/5 Ali Akhtar <al...@gmail.com>:
> > There's one case where it may be useful to have these listeners. Suppose
> if
> > you have a lot of packages, and you just need to modify one or two
> > interceptors in each package. You would have to paste your whole
> > interceptor stack in order to do this.
> >
> > I think this feature could be useful for such cases.
>
> But you can define all in your top package which should be used
> instead of defaultStack. That's the normal case and the most
> suggested.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: InterceptorListeners

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/5 Ali Akhtar <al...@gmail.com>:
> There's one case where it may be useful to have these listeners. Suppose if
> you have a lot of packages, and you just need to modify one or two
> interceptors in each package. You would have to paste your whole
> interceptor stack in order to do this.
>
> I think this feature could be useful for such cases.

But you can define all in your top package which should be used
instead of defaultStack. That's the normal case and the most
suggested.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Ali Akhtar <al...@gmail.com>.
There's one case where it may be useful to have these listeners. Suppose if
you have a lot of packages, and you just need to modify one or two
interceptors in each package. You would have to paste your whole
interceptor stack in order to do this.

I think this feature could be useful for such cases.


On Tue, Nov 5, 2013 at 7:13 PM, <um...@gmail.com> wrote:

> I am agree with Steven, existing API is really good.
> We need to put more work of documents and showing user how to use or
> modify existing API.
>
>
>
> Thanks
> Umesh
> Sent from BlackBerry® on Airtel
>
> -----Original Message-----
> From: Steven Benitez <st...@gmail.com>
> Date: Tue, 5 Nov 2013 09:00:14
> To: Struts Developers List<de...@struts.apache.org>
> Reply-To: "Struts Developers List" <de...@struts.apache.org>
> Subject: Re: InterceptorListeners
>
> I feel pretty strongly that we should not broaden the API to accommodate
> users who don't know how to use the existing API, which is really pretty
> straight forward. We'd be better off educating users how the existing
> interceptor API works rather than introducing new complexity.
>
>
> On Tue, Nov 5, 2013 at 4:11 AM, Lukasz Lenart <lukaszlenart@apache.org
> >wrote:
>
> > 2013/11/5 Steven Benitez <st...@gmail.com>:
> > > Why not just create an interceptor and run it before or after the
> > > interceptor you need? What specific use case does this address?
> >
> > You are perfectly right, it's the prefer way to achieve the same
> behaviour.
> >
> > But there are some users which just stick with defaultStack or
> > cannot/don't know how to modify the defaultStack - and it's solution
> > just for them. Maybe I'm wrong and we should educated users to don't
> > stick with default stack and always prepare their own stack (at least
> > to improve performance).
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: InterceptorListeners

Posted by um...@gmail.com.
I am agree with Steven, existing API is really good.
We need to put more work of documents and showing user how to use or modify existing API.



Thanks
Umesh
Sent from BlackBerry® on Airtel

-----Original Message-----
From: Steven Benitez <st...@gmail.com>
Date: Tue, 5 Nov 2013 09:00:14 
To: Struts Developers List<de...@struts.apache.org>
Reply-To: "Struts Developers List" <de...@struts.apache.org>
Subject: Re: InterceptorListeners

I feel pretty strongly that we should not broaden the API to accommodate
users who don't know how to use the existing API, which is really pretty
straight forward. We'd be better off educating users how the existing
interceptor API works rather than introducing new complexity.


On Tue, Nov 5, 2013 at 4:11 AM, Lukasz Lenart <lu...@apache.org>wrote:

> 2013/11/5 Steven Benitez <st...@gmail.com>:
> > Why not just create an interceptor and run it before or after the
> > interceptor you need? What specific use case does this address?
>
> You are perfectly right, it's the prefer way to achieve the same behaviour.
>
> But there are some users which just stick with defaultStack or
> cannot/don't know how to modify the defaultStack - and it's solution
> just for them. Maybe I'm wrong and we should educated users to don't
> stick with default stack and always prepare their own stack (at least
> to improve performance).
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Steven Benitez <st...@gmail.com>.
I feel pretty strongly that we should not broaden the API to accommodate
users who don't know how to use the existing API, which is really pretty
straight forward. We'd be better off educating users how the existing
interceptor API works rather than introducing new complexity.


On Tue, Nov 5, 2013 at 4:11 AM, Lukasz Lenart <lu...@apache.org>wrote:

> 2013/11/5 Steven Benitez <st...@gmail.com>:
> > Why not just create an interceptor and run it before or after the
> > interceptor you need? What specific use case does this address?
>
> You are perfectly right, it's the prefer way to achieve the same behaviour.
>
> But there are some users which just stick with defaultStack or
> cannot/don't know how to modify the defaultStack - and it's solution
> just for them. Maybe I'm wrong and we should educated users to don't
> stick with default stack and always prepare their own stack (at least
> to improve performance).
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: InterceptorListeners

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/5 Steven Benitez <st...@gmail.com>:
> Why not just create an interceptor and run it before or after the
> interceptor you need? What specific use case does this address?

You are perfectly right, it's the prefer way to achieve the same behaviour.

But there are some users which just stick with defaultStack or
cannot/don't know how to modify the defaultStack - and it's solution
just for them. Maybe I'm wrong and we should educated users to don't
stick with default stack and always prepare their own stack (at least
to improve performance).


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: InterceptorListeners

Posted by Steven Benitez <st...@gmail.com>.
Why not just create an interceptor and run it before or after the
interceptor you need? What specific use case does this address?

On Tuesday, November 5, 2013, Ali Akhtar wrote:

> It could be useful, especially for the interceptors in the default stack.
>
>
> On Tue, Nov 5, 2013 at 1:58 PM, Lukasz Lenart <lukaszlenart@apache.org<javascript:;>
> >wrote:
>
> > Hi,
> >
> > What do you think about adding possibility to create listeners which
> > will be executed before/after given interceptor?
> >
> > Something like this:
> >
> > public interface InterceptorListener {
> >
> >     boolean accept(InterceptorMapping mapping);
> >
> >     void beforeInterceptor(ActionInvocation invocation);
> >
> >     void afterInterceptor(ActionInvocation invocation);
> >
> > }
> >
> > You can define them as a beens in struts.xml
> >
> > <bean type="com.opensymphony.xwork2.interceptor.InterceptorListener"
> > class="com.demo.MyInterceptorListener"/>
> >
> >
> > There are already few interceptors defined:
> >
> > https://cwiki.apache.org/confluence/display/WW/ActionEventListener
> > https://cwiki.apache.org/confluence/display/WW/DispatcherListener
> > https://cwiki.apache.org/confluence/display/WW/PreResultListener
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org <javascript:;>
> > For additional commands, e-mail: dev-help@struts.apache.org<javascript:;>
> >
> >
>

Re: InterceptorListeners

Posted by Ali Akhtar <al...@gmail.com>.
It could be useful, especially for the interceptors in the default stack.


On Tue, Nov 5, 2013 at 1:58 PM, Lukasz Lenart <lu...@apache.org>wrote:

> Hi,
>
> What do you think about adding possibility to create listeners which
> will be executed before/after given interceptor?
>
> Something like this:
>
> public interface InterceptorListener {
>
>     boolean accept(InterceptorMapping mapping);
>
>     void beforeInterceptor(ActionInvocation invocation);
>
>     void afterInterceptor(ActionInvocation invocation);
>
> }
>
> You can define them as a beens in struts.xml
>
> <bean type="com.opensymphony.xwork2.interceptor.InterceptorListener"
> class="com.demo.MyInterceptorListener"/>
>
>
> There are already few interceptors defined:
>
> https://cwiki.apache.org/confluence/display/WW/ActionEventListener
> https://cwiki.apache.org/confluence/display/WW/DispatcherListener
> https://cwiki.apache.org/confluence/display/WW/PreResultListener
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>