1 10 11 package org.mule.config.pool; 12 13 import org.apache.commons.beanutils.BeanUtils; 14 import org.apache.commons.pool.PoolableObjectFactory; 15 import org.mule.config.i18n.Message; 16 import org.mule.config.i18n.Messages; 17 import org.mule.impl.MuleDescriptor; 18 import org.mule.umo.lifecycle.InitialisationException; 19 20 27 public class CommonsPoolProxyFactory extends AbstractProxyFactory implements PoolableObjectFactory 28 { 29 36 public CommonsPoolProxyFactory(MuleDescriptor descriptor) 37 { 38 super(descriptor); 39 } 40 41 46 public void activateObject(Object arg0) throws Exception 47 { 48 } 50 51 56 public void destroyObject(Object object) throws Exception 57 { 58 pool.onRemove(object); 59 } 60 61 66 public Object makeObject() throws Exception 67 { 68 Object object = create(); 69 pool.onAdd(object); 70 return object; 71 } 72 73 78 public void passivateObject(Object arg0) throws Exception 79 { 80 } 82 83 88 public boolean validateObject(Object arg0) 89 { 90 return true; 91 } 92 93 protected void afterComponentCreate(Object component) throws InitialisationException 94 { 95 try 96 { 97 BeanUtils.populate(component, descriptor.getProperties()); 98 } 99 catch (Exception e) 100 { 101 throw new InitialisationException(new Message(Messages.FAILED_TO_SET_PROPERTIES_ON_X, 102 "Component '" + descriptor.getName() + "'"), e, descriptor); 103 } 104 } 105 106 } 107 | Popular Tags |