JBoss Community

Re: EJB3 Session Bean Pool

created by Robert Geisler in EJB3 - View the full discussion

hello carlo,


i finally implemented a custom org.jboss.ejb3.Pool and i am going to test it during the next days.

when all the bugs are gone, i'll post the code in JBoss forum; or on github as suggested.


but today i have a few more questions:


I) remove instances that are in use??

i had a look at the code of org.jboss.ejb3.InfinitePool (written by you : )) and i noticed that InfinitePool holds a List<BeanContext> of >>active<< contexts. i guess, active means that these contexts are currently used (by a single thread)? whenever a context is created, the new instance is added to actives and then it stays there until it get released/ removed.

when the pool is destroyed (e.g. the bean gets undeployed?), InfinitePool iterates through its actives and calls remove() for each of these instances/ contexts created before. but StrictMaxPool (written by Kabir Khan) for example does not maintain such a list and thus does not call remove for active instances. so instances that are in use (/ are not located in the pool) while the pool is destroyed will never be removed, right?

is it critical? in which cases is Pool.destroy() called and is the pool required to remove such active instances?? what happens to these instances after the pool is destroyed?


II) how to synchronize pool?

a) InfinitePool and StrictMaxPool do not use synchronized methods, but synchronized statements for changes in the pool structure. i tried to adopt this for my pool. but i wonder if synchronized methods would also do the trick? or could it cause a bottleneck??

b) i checked sources of pool implementations in JBoss6. i noticed that org.jboss.ejb3.AbstractPool uses AtomicInteger to count create() and remove() while JBoss4 used a primitive instead. should a adopt this as well??



thanks in advance.


Reply to this message by going to Community

Start a new discussion in EJB3 at Community