1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.pool;
12
13 import org.mule.config.i18n.CoreMessages;
14 import org.mule.impl.MuleDescriptor;
15 import org.mule.umo.lifecycle.InitialisationException;
16 import org.mule.umo.model.UMOModel;
17
18 import org.apache.commons.beanutils.BeanUtils;
19 import org.apache.commons.pool.PoolableObjectFactory;
20
21
22
23
24
25 public class CommonsPoolProxyFactory extends AbstractProxyFactory implements PoolableObjectFactory
26 {
27
28
29
30
31
32
33
34 public CommonsPoolProxyFactory(MuleDescriptor descriptor, UMOModel model)
35 {
36 super(descriptor, model);
37 }
38
39 public void activateObject(Object arg0) throws Exception
40 {
41
42 }
43
44 public void destroyObject(Object object) throws Exception
45 {
46 pool.onRemove(object);
47 }
48
49 public Object makeObject() throws Exception
50 {
51 Object object = create();
52 pool.onAdd(object);
53 return object;
54 }
55
56 public void passivateObject(Object arg0) throws Exception
57 {
58
59 }
60
61 public boolean validateObject(Object arg0)
62 {
63 return true;
64 }
65
66 protected void afterComponentCreate(Object component) throws InitialisationException
67 {
68 try
69 {
70 BeanUtils.populate(component, descriptor.getProperties());
71 }
72 catch (Exception e)
73 {
74 throw new InitialisationException(
75 CoreMessages.failedToSetPropertiesOn("Component '" + descriptor.getName() + "'"),
76 e, descriptor);
77 }
78 }
79
80 }