1 | |
package org.apache.tapestry.services.impl; |
2 | |
|
3 | |
import ognl.ClassResolver; |
4 | |
import ognl.Ognl; |
5 | |
import ognl.OgnlContext; |
6 | |
import ognl.TypeConverter; |
7 | |
import org.apache.commons.pool.BasePoolableObjectFactory; |
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
public class PoolableOgnlContextFactory extends BasePoolableObjectFactory { |
13 | |
|
14 | |
private final ClassResolver _resolver; |
15 | |
|
16 | |
private TypeConverter _typeConverter; |
17 | |
|
18 | |
public PoolableOgnlContextFactory(ClassResolver resolver, TypeConverter typeConverter) |
19 | 0 | { |
20 | 0 | _resolver = resolver; |
21 | 0 | _typeConverter = typeConverter; |
22 | 0 | } |
23 | |
|
24 | |
public Object makeObject() |
25 | |
throws Exception |
26 | |
{ |
27 | 0 | return Ognl.createDefaultContext(null, _resolver, _typeConverter); |
28 | |
} |
29 | |
|
30 | |
public void activateObject(Object obj) |
31 | |
throws Exception |
32 | |
{ |
33 | 0 | OgnlContext context = (OgnlContext)obj; |
34 | |
|
35 | 0 | if (context.getRoot() != null || context.getValues().size() > 0) |
36 | |
{ |
37 | 0 | context.clear(); |
38 | |
} |
39 | 0 | } |
40 | |
} |