You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Davies <c....@gmail.com> on 2007/03/07 21:03:46 UTC

Service Injection for Base Pages

Dear fellow Tap-fans,

I'm looking to implement a very simple, re-usable security library for my
web applications.  The path I'm going down is one that seems to be common
(and embraced by Howard himself) - extending BasePage and implementing the
PageValidateListener to perform authorization checks within (call this the
BaseProtectedPage).

I'm a little bit stuck with a small detail though: part of my library design
is a service that should be accessible (and configurable) through the
HiveMind registry (e.g. a "PageProtectionService") which needs to be
injected into the BaseProtectedPage as part of the authorization mechanism.

Is there a clean way to inject this service into my BaseProtectedPage?
Ideally, I'd like to just be able to create a .page file corresponding to
BaseProtectedPage and specify service injections through that way, but as
far as I know, this doesn't work (as far as I'm aware, Tapestry only listens
to the page/component specification files of the lowest sub-class - doesn't
process any superclass page/component specs).  Thus the only alternative I
have is to resolve the service programmatically through the HiveMind
registry.  I don't mind doing this, but what's the cleanest way to access
the HiveMind registry held by Tapestry?  Do I have to create my own copy of
a Registry to be used within every instance of BaseProtectedPage?

Thanks for any help and guidance! =]

- Chris

Re: Service Injection for Base Pages

Posted by Chris Davies <c....@gmail.com>.
Wow, thanks for the fast replies. =]  I'll look into understanding how the
enhancement worker chain works and see if I can figure out an option from
there.

Ideally I'm trying to keep my current projects 1.4.2 compatible (a couple of
business reasons, but also personal preference: I believe that separating
security semantics out of the code is a good thing), so unfortunately I'd
only really want to use annotations as a last resort!  This is also one of
the reasons I decided against using tapestry-acegi.

Again, thanks for the replies - keep the suggestions coming. =]


Regards,

Chris


On 07/03/07, Thiago H de Paula Figueiredo <th...@terra.com.br> wrote:
>
> On Wed, 07 Mar 2007 17:03:46 -0300, Chris Davies <c....@gmail.com>
> wrote:
>
> > Is there a clean way to inject this service into my BaseProtectedPage?
>
> can you use java 5 or 6? if yes, just use some of the @Inject* annotation
> in your property. if not, i can't help, as i've never used tapestry
> without annotations.
>
> --
>
> hasta la vista!!!
>
> |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p
>
> thiago h. de paula figueiredo
> mestre em ciência da computação pelo dcc/ufmg
> ate' porque bobagem pouca e' bobagem . . .
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Service Injection for Base Pages

Posted by Thiago H de Paula Figueiredo <th...@terra.com.br>.
On Wed, 07 Mar 2007 17:03:46 -0300, Chris Davies <c....@gmail.com>  
wrote:

> Is there a clean way to inject this service into my BaseProtectedPage?

can you use java 5 or 6? if yes, just use some of the @Inject* annotation  
in your property. if not, i can't help, as i've never used tapestry  
without annotations.

-- 

hasta la vista!!!

|8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p |8) |8p

thiago h. de paula figueiredo
mestre em ciência da computação pelo dcc/ufmg
ate' porque bobagem pouca e' bobagem . . .

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


Re: Service Injection for Base Pages

Posted by Jesse Kuhnert <jk...@gmail.com>.
You can do something "globally" to everything by plugging in to the
enhancement worker chain of services:

http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/module/tapestry.enhance.html

To be honest though - I think the extending BasePage stuff was mostly
pre-annotations and may not necessarily be the most "ideal" way to do
it. (not that any on way is the best, it's all personal pref ) You
might also want to look at tapestry-acegi :

http://www.carmanconsulting.com/tapestry-acegi/

On 3/7/07, Chris Davies <c....@gmail.com> wrote:
> Dear fellow Tap-fans,
>
> I'm looking to implement a very simple, re-usable security library for my
> web applications.  The path I'm going down is one that seems to be common
> (and embraced by Howard himself) - extending BasePage and implementing the
> PageValidateListener to perform authorization checks within (call this the
> BaseProtectedPage).
>
> I'm a little bit stuck with a small detail though: part of my library design
> is a service that should be accessible (and configurable) through the
> HiveMind registry (e.g. a "PageProtectionService") which needs to be
> injected into the BaseProtectedPage as part of the authorization mechanism.
>
> Is there a clean way to inject this service into my BaseProtectedPage?
> Ideally, I'd like to just be able to create a .page file corresponding to
> BaseProtectedPage and specify service injections through that way, but as
> far as I know, this doesn't work (as far as I'm aware, Tapestry only listens
> to the page/component specification files of the lowest sub-class - doesn't
> process any superclass page/component specs).  Thus the only alternative I
> have is to resolve the service programmatically through the HiveMind
> registry.  I don't mind doing this, but what's the cleanest way to access
> the HiveMind registry held by Tapestry?  Do I have to create my own copy of
> a Registry to be used within every instance of BaseProtectedPage?
>
> Thanks for any help and guidance! =]
>
> - Chris
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

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