1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.beanshell;
17
18 import bsh.EvalError;
19
20 import org.apache.commons.jelly.JellyContext;
21 import org.apache.commons.jelly.JellyException;
22 import org.apache.commons.jelly.expression.Expression;
23 import org.apache.commons.jelly.expression.ExpressionFactory;
24
25 /*** Represents a factory of <a href="http://www.beanshell.org" target="alexandria_uri">http://www.beanshell.org">beanshell</a> expressions
26 *
27 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
28 * @version $Revision: 155420 $
29 */
30 public class BeanShellExpressionFactory implements ExpressionFactory {
31
32 /***
33 * A helper method to return the JellyInterpreter for the given JellyContext
34 */
35 public static JellyInterpreter getInterpreter(JellyContext context) throws EvalError {
36
37 /***
38 * @todo when we can unify the BeanShell and Jelly variable scopes we can share a single
39 * BeanShell context for each JellyContext.
40 * For now lets create a new one each time, which is slower.
41 */
42 JellyInterpreter interpreter = new JellyInterpreter();
43 interpreter.setJellyContext(context);
44 return interpreter;
45
46
47
48
49
50
51
52
53
54
55 }
56
57
58
59
60 public Expression createExpression(String text) throws JellyException {
61 return new BeanShellExpression(text);
62 }
63 }