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 | 52 | super(descriptor, model); |
37 | 52 | } |
38 | |
|
39 | |
public void activateObject(Object arg0) throws Exception |
40 | |
{ |
41 | |
|
42 | 70 | } |
43 | |
|
44 | |
public void destroyObject(Object object) throws Exception |
45 | |
{ |
46 | 26 | pool.onRemove(object); |
47 | 26 | } |
48 | |
|
49 | |
public Object makeObject() throws Exception |
50 | |
{ |
51 | 68 | Object object = create(); |
52 | 58 | pool.onAdd(object); |
53 | 58 | return object; |
54 | |
} |
55 | |
|
56 | |
public void passivateObject(Object arg0) throws Exception |
57 | |
{ |
58 | |
|
59 | 38 | } |
60 | |
|
61 | |
public boolean validateObject(Object arg0) |
62 | |
{ |
63 | 2 | return true; |
64 | |
} |
65 | |
|
66 | |
protected void afterComponentCreate(Object component) throws InitialisationException |
67 | |
{ |
68 | |
try |
69 | |
{ |
70 | 70 | BeanUtils.populate(component, descriptor.getProperties()); |
71 | |
} |
72 | 0 | catch (Exception e) |
73 | |
{ |
74 | 0 | throw new InitialisationException( |
75 | |
CoreMessages.failedToSetPropertiesOn("Component '" + descriptor.getName() + "'"), |
76 | |
e, descriptor); |
77 | 70 | } |
78 | 70 | } |
79 | |
|
80 | |
} |