You can get it from the servlet context - it adds it to a context variable.
 Registry registry = (Registry)
getServletContext().getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);

This shouldn't really be used inside another service as it is a bit
confusing. You may also have to make sure it doesn't get called until
tapestry-ioc has initialised via the servlet filter otherwise the attribute
won't be there yet.

Ben Gidley

www.gidley.co.uk
b...@gidley.co.uk


On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
alfie.kirkpatr...@ioko.com> wrote:

> You can inject ObjectLocator into a service but it doesn't sound like
> this would work for you as it's still essentially injection in the
> normal way.
>
> For webapps TapestryFilter doesn't put the registry in a static anywhere
> so there is no way to get the registry from 'outside' the dependency
> injection framework AFAIK. You could of course copy TapestryFilter,
> write your own, and put it into a static/threadlocal.
>
> Maybe you can explain why you have a static initialiser that needs the
> registry? It sounds very 'un-tapestry' ;-)
>
> Alfie.
>
> -----Original Message-----
> From: Benny Law [mailto:benny.mk....@gmail.com]
> Sent: 07 October 2009 01:34
> To: Tapestry Users
> Subject: Accessing the T5 IoC Registry
>
> Hello,
>
> How can I obtain a service from the IoC registry inside a static
> initializer? Injection doesn't seem to work with static members, so I
> need
> to access the registry directly, or is there a better way?
>
> Thanks,
>
> Benny Law
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to