What makes you think that it builds a singleton?

You will get a single proxy instance; internal to the proxy it finds/creates
the per-thread instance.

You need to be careful about the notification you have there; that will
probably cause a leak of BoboCacheState instances.

    @Scope(PERTHREAD_SCOPE)
    public BoboCacheState buildCacheState(ThreadCleanupHub threadCleanupHub,
@InjectService
>
> ("Cache")
>     Cache cache) {
>         final BoboCacheState state = new BoboCacheState();
>         cache.getCacheEventNotificationService().registerListener(state);


           threadCleanupHub.addThreadCleanupListener(new
ThreadCleanupListener() {
            public void threadDidCleanup() {
              cache.getCacheEventNotificationService
().unregisterListener(state);
           });



        return state;
>     }




On 10/17/07, Donyee <[EMAIL PROTECTED]> wrote:
>
> I use "@Scope(PERTHREAD_SCOPE)" on build method  in my AppModule.java.
> It will create new instance in every new request, but it seems the method
> build a singleton!
> I use IE and FireFox request the page!
> my code: in AppModule.java
> @EagerLoad
>     @Scope(PERTHREAD_SCOPE)
>     public BoboCacheState buildCacheState(@InjectService("Cache")
>     Cache cache) {
>         BoboCacheState state = new BoboCacheState();
>         cache.getCacheEventNotificationService().registerListener(state);
>         return state;
>     }
> in page index.java:
> @Inject
>     private BoboCacheState state;
>
>
>
> ----徐 依伟
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Reply via email to