Hi Simone,

Thank you very much, I'll dig into this today later.

Regards,
 Oleg

On Tuesday 12 December 2000 18:09, Bordet, Simone wrote:
> Hi Oleg,
>
> > Hi Simone,
> >
> > On Tuesday 12 December 2000 15:52, Bordet, Simone wrote:
> > > The bean cache is a time-limited cache: too old bean are
> >
> > passivated out of
> >
> > > the cache when their lifetime expires.
> > > All classes are already implemented, you only need to use
> >
> > them; maybe some
> >
> > > refactoring is worth, but the main structure is there.
> >
> > Okay, I'll take a look. Where do I start from?
>
> The bean cache main implementation is org.jboss.util.LRUCachePolicy. This
> cache does not have time limits however, it only manages a LRU algorithm
> with a working set variant (ie newer beans are always in the top positions
> of the cache).
> Then, in interface org.jboss.ejb.plugins.EnterpriseContextCachePolicy I
> start a TimerQueue that accepts TimerTask jobs to be executed one-shot or
> periodically. This couple of classes (TimerQueue and TimerTask) are already
> present in JDK 1.3, but for compatibility with JDK 1.2.2 I had to rewrite
> them.
>
> Then in org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy I create 2
> TimerTasks; the one that interests us is an inner class called
> OveragerTask; in the execute() method it scans the cache from the tail
> where older beans are and passivate them.
>
> This implementation result in a single thread that executes all TimerTasks
> scheduled by all beans (in contrast to the passivation thread, of which
> there is one for each bean), and this is maybe refactoring worth: having
> this TimerQueue execute not only bean cache TimerTasks, but also other
> TimerTasks (like a security one), see below.
>
> I don't know internals of security but in principle you can:
> 1) extend org.jboss.util.CachePolicy very like
> org.jboss.ejb.plugins.EnterpriseContextCachePolicy does, and create a
> SecurityCachePolicy with a static inner class that holds a TimerQueue.
> 2) extend org.jboss.util.LRUCachePolicy into a LRUSecurityCachePolicy that
> also implements SecurityCachePolicy; LRUSecurityCachePolicy will have a
> inner class that works very like
> org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.OveragerTask to give
> time-limit capabilities to the cache.
>
> For refactoring, we may create a TimerCachePolicy base interface from where
> both LRUSecurityCachePolicy and LRUEnterpriseContextCachePolicy can inherit
> so that we share the TimerQueue (the solution I outlined above will have 2
> TimerQueues, one for the beans and one for the security), but this can be
> done later, though is very simple.
>
> Beware that LRUCachePolicy is not thread safe, so if you use it in
> multithread environment, another class must handle access synchronization
> to it (in the bean cache case this is done by
> org.jboss.ejb.plugins.AbstractInstanceCache)
>
> HTH,
>
> Simon

Reply via email to