You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Benny Law <be...@gmail.com> on 2009/10/07 02:34:13 UTC

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

Re: Accessing the T5 IoC Registry

Posted by Benny Law <be...@gmail.com>.
Thanks Javier. This is actually what I ended up doing after doing more
research. It seems to be the best approach.

Regards,

Benny

On Fri, Oct 9, 2009 at 5:28 AM, Javier Molina <javier@comunicamultimedia.com
> wrote:

> You might want to contribute to the registry startup and initialize things
> there:
>
> http://tapestry.apache.org/tapestry5/tapestry-ioc/startup.html
>
>
> Benny Law escribió:
>
>  Thanks Ben, this looks reasonably clean to me. Unless somebody else offers
>> a
>> better idea, I will probably go with this approach.
>>
>> Benny
>>
>> On Wed, Oct 7, 2009 at 10:08 AM, Ben Dotte <be...@gmail.com> wrote:
>>
>>  Here's a trick we use for this. We extend TapestryFilter and override
>>> init(Registry registry). Since this gets passed the created registry,
>>> we then store that in a static variable on our filter and provide a
>>> static getRegistry() method to retrieve it. This gets around the
>>> problem that TapestryFilter stores the registry in a private instance
>>> variable. To use your filter, just specify it in web.xml instead:
>>>
>>> <filter>
>>>   <filter-name>t5</filter-name>
>>>   <filter-class>com.whatever.MyFilter</filter-class>
>>> </filter>
>>>
>>> This still requires that the registry has been created at the point
>>> that it is requested, but at least you don't have to have access to
>>> the servlet context.
>>>
>>> Ben
>>>
>>> On Wed, Oct 7, 2009 at 6:58 AM, Benny Law <be...@gmail.com>
>>> wrote:
>>>
>>>> Thank you all for your help. This is why I need to do this:
>>>>
>>>> I have an immutable class called ProjectType, and it has a few
>>>> predefined
>>>> instances held in public static final fields (ProjectType.GD,
>>>> ProjectType.TF, etc.) These instances need to be initialized with data
>>>>
>>> from
>>>
>>>> the database, so my approach was to do that inside the static
>>>>
>>> initializer.
>>>
>>>> However, I need to access the service that provides the database
>>>>
>>> operations,
>>>
>>>> and the service is registered in the IoC container.
>>>>
>>>> If anyone has a better idea, I will be glad to learn. I believe there
>>>> are
>>>> rare occasions when the registry is needed outside of normal injection,
>>>>
>>> so
>>>
>>>> having a convenient way to get to it in Tapestry would be nice, although
>>>>
>>> it
>>>
>>>> may open up opportunities for abuse.
>>>>
>>>> Benny Law
>>>>
>>>> On Wed, Oct 7, 2009 at 4:58 AM, Ben Gidley <be...@gidley.co.uk> wrote:
>>>>
>>>>  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
>>>>> ben@gidley.co.uk
>>>>>
>>>>>
>>>>> On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
>>>>> Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Accessing the T5 IoC Registry

Posted by Javier Molina <ja...@comunicamultimedia.com>.
You might want to contribute to the registry startup and initialize 
things there:

http://tapestry.apache.org/tapestry5/tapestry-ioc/startup.html


Benny Law escribió:
> Thanks Ben, this looks reasonably clean to me. Unless somebody else offers a
> better idea, I will probably go with this approach.
> 
> Benny
> 
> On Wed, Oct 7, 2009 at 10:08 AM, Ben Dotte <be...@gmail.com> wrote:
> 
>> Here's a trick we use for this. We extend TapestryFilter and override
>> init(Registry registry). Since this gets passed the created registry,
>> we then store that in a static variable on our filter and provide a
>> static getRegistry() method to retrieve it. This gets around the
>> problem that TapestryFilter stores the registry in a private instance
>> variable. To use your filter, just specify it in web.xml instead:
>>
>> <filter>
>>    <filter-name>t5</filter-name>
>>    <filter-class>com.whatever.MyFilter</filter-class>
>> </filter>
>>
>> This still requires that the registry has been created at the point
>> that it is requested, but at least you don't have to have access to
>> the servlet context.
>>
>> Ben
>>
>> On Wed, Oct 7, 2009 at 6:58 AM, Benny Law <be...@gmail.com> wrote:
>>> Thank you all for your help. This is why I need to do this:
>>>
>>> I have an immutable class called ProjectType, and it has a few predefined
>>> instances held in public static final fields (ProjectType.GD,
>>> ProjectType.TF, etc.) These instances need to be initialized with data
>> from
>>> the database, so my approach was to do that inside the static
>> initializer.
>>> However, I need to access the service that provides the database
>> operations,
>>> and the service is registered in the IoC container.
>>>
>>> If anyone has a better idea, I will be glad to learn. I believe there are
>>> rare occasions when the registry is needed outside of normal injection,
>> so
>>> having a convenient way to get to it in Tapestry would be nice, although
>> it
>>> may open up opportunities for abuse.
>>>
>>> Benny Law
>>>
>>> On Wed, Oct 7, 2009 at 4:58 AM, Ben Gidley <be...@gidley.co.uk> wrote:
>>>
>>>> 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
>>>> ben@gidley.co.uk
>>>>
>>>>
>>>> On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
>>>> Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 


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


Re: Accessing the T5 IoC Registry

Posted by Benny Law <be...@gmail.com>.
Thanks Ben, this looks reasonably clean to me. Unless somebody else offers a
better idea, I will probably go with this approach.

Benny

On Wed, Oct 7, 2009 at 10:08 AM, Ben Dotte <be...@gmail.com> wrote:

> Here's a trick we use for this. We extend TapestryFilter and override
> init(Registry registry). Since this gets passed the created registry,
> we then store that in a static variable on our filter and provide a
> static getRegistry() method to retrieve it. This gets around the
> problem that TapestryFilter stores the registry in a private instance
> variable. To use your filter, just specify it in web.xml instead:
>
> <filter>
>    <filter-name>t5</filter-name>
>    <filter-class>com.whatever.MyFilter</filter-class>
> </filter>
>
> This still requires that the registry has been created at the point
> that it is requested, but at least you don't have to have access to
> the servlet context.
>
> Ben
>
> On Wed, Oct 7, 2009 at 6:58 AM, Benny Law <be...@gmail.com> wrote:
> > Thank you all for your help. This is why I need to do this:
> >
> > I have an immutable class called ProjectType, and it has a few predefined
> > instances held in public static final fields (ProjectType.GD,
> > ProjectType.TF, etc.) These instances need to be initialized with data
> from
> > the database, so my approach was to do that inside the static
> initializer.
> > However, I need to access the service that provides the database
> operations,
> > and the service is registered in the IoC container.
> >
> > If anyone has a better idea, I will be glad to learn. I believe there are
> > rare occasions when the registry is needed outside of normal injection,
> so
> > having a convenient way to get to it in Tapestry would be nice, although
> it
> > may open up opportunities for abuse.
> >
> > Benny Law
> >
> > On Wed, Oct 7, 2009 at 4:58 AM, Ben Gidley <be...@gidley.co.uk> wrote:
> >
> >> 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
> >> ben@gidley.co.uk
> >>
> >>
> >> On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
> >> Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >> >
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Accessing the T5 IoC Registry

Posted by Ben Dotte <be...@gmail.com>.
Here's a trick we use for this. We extend TapestryFilter and override
init(Registry registry). Since this gets passed the created registry,
we then store that in a static variable on our filter and provide a
static getRegistry() method to retrieve it. This gets around the
problem that TapestryFilter stores the registry in a private instance
variable. To use your filter, just specify it in web.xml instead:

<filter>
    <filter-name>t5</filter-name>
    <filter-class>com.whatever.MyFilter</filter-class>
</filter>

This still requires that the registry has been created at the point
that it is requested, but at least you don't have to have access to
the servlet context.

Ben

On Wed, Oct 7, 2009 at 6:58 AM, Benny Law <be...@gmail.com> wrote:
> Thank you all for your help. This is why I need to do this:
>
> I have an immutable class called ProjectType, and it has a few predefined
> instances held in public static final fields (ProjectType.GD,
> ProjectType.TF, etc.) These instances need to be initialized with data from
> the database, so my approach was to do that inside the static initializer.
> However, I need to access the service that provides the database operations,
> and the service is registered in the IoC container.
>
> If anyone has a better idea, I will be glad to learn. I believe there are
> rare occasions when the registry is needed outside of normal injection, so
> having a convenient way to get to it in Tapestry would be nice, although it
> may open up opportunities for abuse.
>
> Benny Law
>
> On Wed, Oct 7, 2009 at 4:58 AM, Ben Gidley <be...@gidley.co.uk> wrote:
>
>> 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
>> ben@gidley.co.uk
>>
>>
>> On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
>> Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>

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


Re: Accessing the T5 IoC Registry

Posted by Benny Law <be...@gmail.com>.
Thank you all for your help. This is why I need to do this:

I have an immutable class called ProjectType, and it has a few predefined
instances held in public static final fields (ProjectType.GD,
ProjectType.TF, etc.) These instances need to be initialized with data from
the database, so my approach was to do that inside the static initializer.
However, I need to access the service that provides the database operations,
and the service is registered in the IoC container.

If anyone has a better idea, I will be glad to learn. I believe there are
rare occasions when the registry is needed outside of normal injection, so
having a convenient way to get to it in Tapestry would be nice, although it
may open up opportunities for abuse.

Benny Law

On Wed, Oct 7, 2009 at 4:58 AM, Ben Gidley <be...@gidley.co.uk> wrote:

> 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
> ben@gidley.co.uk
>
>
> On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
> Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: Accessing the T5 IoC Registry

Posted by Ben Gidley <be...@gidley.co.uk>.
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
ben@gidley.co.uk


On Wed, Oct 7, 2009 at 9:37 AM, Alfie Kirkpatrick <
Alfie.Kirkpatrick@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.law@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Accessing the T5 IoC Registry

Posted by Piero Sartini <li...@pierosartini.de>.
> Maybe you can explain why you have a static initialiser that needs the
> registry? It sounds very 'un-tapestry' ;-)

I had the same problem some time ago. My requirement was to access
services from my entity beans. I think to put the registry into a
static context would be a great addition..

Piero

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


Re: Accessing the T5 IoC Registry

Posted by cordenier christophe <ch...@gmail.com>.
Hello

I don't if this can help but the Tapestry Registry is stored in the
application context under TapestryFilter.REGISTRY_CONTEXT_NAME key.

Christophe.

2009/10/7 Alfie Kirkpatrick <Al...@ioko.com>

> 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.law@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

RE: Accessing the T5 IoC Registry

Posted by Alfie Kirkpatrick <Al...@ioko.com>.
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.law@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org