1 22 package org.jboss.ejb3; 23 24 25 31 public class ThreadlocalPool extends AbstractPool 32 { 33 protected ThreadLocal pool = new ThreadLocal (); 34 35 public ThreadlocalPool() 36 { 37 } 38 39 public BeanContext get() 40 { 41 BeanContext ctx = (BeanContext) pool.get(); 42 if (ctx != null) 43 { 44 pool.set(null); 45 return ctx; 46 } 47 48 ctx = create(); 49 return ctx; 50 } 51 52 public BeanContext get(Class [] initTypes, Object [] initValues) 53 { 54 BeanContext ctx = (BeanContext) pool.get(); 55 if (ctx != null) 56 { 57 pool.set(null); 58 return ctx; 59 } 60 61 ctx = create(initTypes, initValues); 62 return ctx; 63 } 64 65 public void release(BeanContext ctx) 66 { 67 if (pool.get() != null) 68 remove(ctx); 69 else 70 pool.set(ctx); 71 } 72 73 } 74 | Popular Tags |