You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nemanja Kostic <n....@youngculture.com> on 2005/01/21 10:27:44 UTC

Interceptors in Tapestry ?

Hi all,

    does Tapestry have something like interceptors in WebWork ?
Probably there is something like that, but as I am still a newbie in 
Tapestry I haven't
found anything similar.

I would like to intercept request before reaching my bean.
I am doing it now using filters in container.

Nemanja.




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Interceptors in Tapestry ?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
For authentication, if it is at the page level granualarity, you can 
implement the PageValidateListener on a custom base page class that all 
your pages extend from, and in the pageValidate method redirect to the 
login page if the user is is not logged in.  The VLib demo application 
does this, I believe, and I implemented this same scheme on my last 
project.

A clever trick to go along with this is to use the <property> metdata 
in a .page file to specify the role(s) allowed and check for those 
roles in pageValidate.

I question whether it makes sense for Tapestry to build in this type of 
hook or not, when there are perfectly viable and elegant solutions like 
AspectJ to deal with cross-cutting concerns.  However....

It also would be possible for you to implement your own sort of hook 
prior to invoking listener methods if you wanted to really customize 
things - you don't have to use the built-in DirectService, you could 
create your own InterceptingDirectService that does whatever you like 
prior to invoking the listener method.   This might be a slick way to 
go, as I believe you'd be able to override the "direct" service that is 
used by creating a new DirectService subclass and registering it with 
the name "direct" in your .application file.  If you try this route, 
let us know how you fare with it!

	Erik


On Jan 21, 2005, at 5:07 AM, Nemanja Kostic wrote:

> I am trying to centralize login and authentication logic.
> Don't want my listener methods to be executed if user has no enough 
> privilegies.
>
> First tried with filters but it was not elegant solution.
> Now I am using AspectJ to catch all calls to my beans and perform
> authentication logic there.
> It works great, but would be nice to have similar functionality built 
> in Tapestry.
>
> Thanks.
>
> Nemanja.
>
>
> Erik Hatcher wrote:
>
>> No, currently there is no built-in hook point between an HTTP request 
>> and the invocation of a listener method (if that is what you meant).
>>
>> What exactly are you trying to do?  HiveMind and Tapestry 3.1 may 
>> make this more easily possible.  Or, consider using AspectJ.
>>
>>     Erik
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Interceptors in Tapestry ?

Posted by Nemanja Kostic <n....@youngculture.com>.
I am trying to centralize login and authentication logic.
Don't want my listener methods to be executed if user has no enough 
privilegies.

First tried with filters but it was not elegant solution.
Now I am using AspectJ to catch all calls to my beans and perform
authentication logic there.
It works great, but would be nice to have similar functionality built in 
Tapestry.

Thanks.

Nemanja.


Erik Hatcher wrote:

> No, currently there is no built-in hook point between an HTTP request 
> and the invocation of a listener method (if that is what you meant).
>
> What exactly are you trying to do?  HiveMind and Tapestry 3.1 may make 
> this more easily possible.  Or, consider using AspectJ.
>
>     Erik



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Interceptors in Tapestry ?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
No, currently there is no built-in hook point between an HTTP request 
and the invocation of a listener method (if that is what you meant).

What exactly are you trying to do?  HiveMind and Tapestry 3.1 may make 
this more easily possible.  Or, consider using AspectJ.

	Erik


On Jan 21, 2005, at 4:27 AM, Nemanja Kostic wrote:

> Hi all,
>
>    does Tapestry have something like interceptors in WebWork ?
> Probably there is something like that, but as I am still a newbie in 
> Tapestry I haven't
> found anything similar.
>
> I would like to intercept request before reaching my bean.
> I am doing it now using filters in container.
>
> Nemanja.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org