You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jack Nuzbit <fn...@googlemail.com> on 2009/02/08 13:48:32 UTC
T5 service per request
I'm trying to use the tapestry IoC to inject a per thread service into my
other services.
@Scope(ScopeConstants.PERTHREAD)
public class PerThreadService {
private MyObject myObject;
public PerThreadService(Cookies cookies) {
myObject = new MyObject(cookies.readCookieValue("userData")))
System.out.println("Constructing new per thread service.");
}
}
I want this PerThreadService to get constructed at least once per request
but I can see it gets created the first time it's required and then the
constructor never gets called again.
Does anyone know I can do this?
Thanks
Jack
Re: T5 service per request
Posted by Howard Lewis Ship <hl...@gmail.com>.
I believe there's an outstanding issue for this.
On Mon, Feb 9, 2009 at 10:20 AM, Filip S. Adamsen <fs...@fsadev.com> wrote:
> Perhaps Tapestry should throw an exception when one tries to do this instead
> of failing silently? :)
>
> -Filip
>
> On 2009-02-08 18:03, Howard Lewis Ship wrote:
>>
>> You need to define an interface for the service; only services with
>> interfaces can be proxied, and only proxied interfaces can have
>> non-default scope.
>>
>> On Sun, Feb 8, 2009 at 4:48 AM, Jack Nuzbit <fn...@googlemail.com>
>> wrote:
>>>
>>> I'm trying to use the tapestry IoC to inject a per thread service into my
>>> other services.
>>>
>>> @Scope(ScopeConstants.PERTHREAD)
>>> public class PerThreadService {
>>> private MyObject myObject;
>>> public PerThreadService(Cookies cookies) {
>>> myObject = new MyObject(cookies.readCookieValue("userData")))
>>> System.out.println("Constructing new per thread service.");
>>> }
>>> }
>>>
>>> I want this PerThreadService to get constructed at least once per request
>>> but I can see it gets created the first time it's required and then the
>>> constructor never gets called again.
>>> Does anyone know I can do this?
>>>
>>> Thanks
>>>
>>> Jack
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 service per request
Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Perhaps Tapestry should throw an exception when one tries to do this
instead of failing silently? :)
-Filip
On 2009-02-08 18:03, Howard Lewis Ship wrote:
> You need to define an interface for the service; only services with
> interfaces can be proxied, and only proxied interfaces can have
> non-default scope.
>
> On Sun, Feb 8, 2009 at 4:48 AM, Jack Nuzbit <fn...@googlemail.com> wrote:
>> I'm trying to use the tapestry IoC to inject a per thread service into my
>> other services.
>>
>> @Scope(ScopeConstants.PERTHREAD)
>> public class PerThreadService {
>> private MyObject myObject;
>> public PerThreadService(Cookies cookies) {
>> myObject = new MyObject(cookies.readCookieValue("userData")))
>> System.out.println("Constructing new per thread service.");
>> }
>> }
>>
>> I want this PerThreadService to get constructed at least once per request
>> but I can see it gets created the first time it's required and then the
>> constructor never gets called again.
>> Does anyone know I can do this?
>>
>> Thanks
>>
>> Jack
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 service per request
Posted by Howard Lewis Ship <hl...@gmail.com>.
You need to define an interface for the service; only services with
interfaces can be proxied, and only proxied interfaces can have
non-default scope.
On Sun, Feb 8, 2009 at 4:48 AM, Jack Nuzbit <fn...@googlemail.com> wrote:
> I'm trying to use the tapestry IoC to inject a per thread service into my
> other services.
>
> @Scope(ScopeConstants.PERTHREAD)
> public class PerThreadService {
> private MyObject myObject;
> public PerThreadService(Cookies cookies) {
> myObject = new MyObject(cookies.readCookieValue("userData")))
> System.out.println("Constructing new per thread service.");
> }
> }
>
> I want this PerThreadService to get constructed at least once per request
> but I can see it gets created the first time it's required and then the
> constructor never gets called again.
> Does anyone know I can do this?
>
> Thanks
>
> Jack
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org