Re: [T5.06snap] About PERTHREAD_SCOPE?

2007-10-17 Thread Donyee
I use IE and Firefox to request the index page, the index page read data
from the BoboCachestate, and got defferent data!
They should be same!

2007/10/17, Howard Lewis Ship <[EMAIL PROTECTED]>:
>
> 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
>



-- 
徐 依伟


Re: [T5.06snap] About PERTHREAD_SCOPE?

2007-10-17 Thread Howard Lewis Ship
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


[T5.06snap] About PERTHREAD_SCOPE?

2007-10-17 Thread Donyee
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;



徐 依伟