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 |
16 |
{ |
20 |
16 |
_resolver = resolver; |
21 |
16 |
_typeConverter = typeConverter; |
22 |
16 |
} |
23 |
|
|
24 |
|
public Object makeObject() |
25 |
|
throws Exception |
26 |
|
{ |
27 |
7 |
return Ognl.createDefaultContext(null, _resolver, _typeConverter); |
28 |
|
} |
29 |
|
|
30 |
|
public void activateObject(Object obj) |
31 |
|
throws Exception |
32 |
|
{ |
33 |
9 |
OgnlContext context = (OgnlContext)obj; |
34 |
|
|
35 |
9 |
if (context.getRoot() != null || context.getValues().size() > 0) { |
36 |
0 |
context.clear(); |
37 |
0 |
context.setRoot(null); |
38 |
|
} |
39 |
9 |
} |
40 |
|
} |