1 package org.lateralnz.panther.wrapper; 2 3 import java.util.HashMap ; 4 import javax.ejb.SessionBean ; 5 6 import org.apache.commons.pool.KeyedPoolableObjectFactory; 7 8 12 public class KeyedPoolableBeanObjectFactory implements KeyedPoolableObjectFactory { 13 14 private HashMap wrapperClasses = new HashMap (); 15 16 public KeyedPoolableBeanObjectFactory() { 17 } 18 19 public void setWrapperClass(Object key, Class wrapperClass) { 20 21 wrapperClasses.put(key, wrapperClass); 22 } 23 24 public void activateObject(Object key, Object obj) throws Exception { 25 SessionBean sb = (SessionBean )obj; 26 sb.ejbActivate(); 27 } 28 29 public void destroyObject(Object key, Object obj) throws Exception { 30 SessionBean sb = (SessionBean )obj; 31 sb.ejbRemove(); 32 } 33 34 public Object makeObject(Object key) throws Exception { 35 Class c = (Class )wrapperClasses.get(key); 36 Object obj = c.newInstance(); 37 SessionBeanWrapper sb = (SessionBeanWrapper)obj; 38 return obj; 39 } 40 41 public void passivateObject(Object key, Object obj) throws Exception { 42 SessionBean sb = (SessionBean )obj; 43 sb.ejbPassivate(); 44 } 45 46 public boolean validateObject(Object key, Object obj) { 47 return true; 48 } 49 } 50 | Popular Tags |