7576777879808182838485
return create(null, null); } protected BeanContext<?> create(Class[] initTypes, Object[] initValues) { BeanContext ctx; ctx = createBeanContext(); container.pushContext(ctx); try { container.injectBeanContext(ctx);
9293949596979899100101102
synchronized (pool) { if (!pool.isEmpty()) { BeanContext bean = (BeanContext) pool.removeFirst(); ++inUse; return bean; } } return null;
140141142143144145146147148149150
* * @return Context /w instance */ public BeanContext get() { BeanContext bean = acquire(); if(bean != null) return bean; try {
163164165166167168169170171172173
return bean; } public BeanContext get(Class[] initTypes, Object[] initValues) { BeanContext bean = acquire(); if(bean != null) return bean; try {
271272273274275276277278279280281
private void freeAll() { LinkedList clone = (LinkedList) pool.clone(); for (int i = 0; i < clone.size(); i++) { BeanContext bc = (BeanContext) clone.get(i); // Clear TX so that still TX entity pools get killed as well discard(bc); } pool.clear(); inUse = 0;
7778798081828384858687
inUse.getAndSet(0); } public BeanContext get() { BeanContext ctx = currentBeanContext.get(); if (ctx != null) currentBeanContext.set(null); else ctx = create();
90919293949596979899100
return ctx; } public BeanContext get(Class[] initTypes, Object[] initValues) { BeanContext ctx = currentBeanContext.get(); if (ctx != null) currentBeanContext.set(null); else ctx = create(initTypes, initValues);
208209210211212213214215216217218219
{ public void run() { for(int i = 0; i < 10; i++) { BeanContext ctx = pool.get(); BeanContext ctx2 = pool.get(); pool.release(ctx2); ctx2 = null; used ++;
6162636465666768697071
ThreadlocalPool pool = new ThreadlocalPool(); Container container = new MockContainer(); int maxSize = -1; int timeout = -1; pool.initialize(container, maxSize, timeout); BeanContext ctx = pool.get(); pool.release(ctx); ctx = null; gc();
8788899091929394959697
int timeout = -1; pool.initialize(container, maxSize, timeout); assertEquals(0, pool.getAvailableCount()); BeanContext ctx = pool.get(); assertEquals(0, pool.getAvailableCount()); pool.release(ctx); ctx = null;