| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.jelly.tags.beanshell.BeanShellExpressionFactory |
|
|
| 1 | /* |
|
| 2 | * Copyright 2002,2004 The Apache Software Foundation. |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at |
|
| 7 | * |
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 9 | * |
|
| 10 | * Unless required by applicable law or agreed to in writing, software |
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 13 | * See the License for the specific language governing permissions and |
|
| 14 | * limitations under the License. |
|
| 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">beanshell</a> expressions |
|
| 26 | * |
|
| 27 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> |
|
| 28 | * @version $Revision: 155420 $ |
|
| 29 | */ |
|
| 30 | 6 | 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 | 6 | JellyInterpreter interpreter = new JellyInterpreter(); |
| 43 | 6 | interpreter.setJellyContext(context); |
| 44 | 6 | return interpreter; |
| 45 | /* |
|
| 46 | JellyInterpreter interpreter |
|
| 47 | = (JellyInterpreter) context.getVariable( "org.apache.commons.jelly.beanshell.JellyInterpreter" ); |
|
| 48 | if ( interpreter == null ) { |
|
| 49 | interpreter = new JellyInterpreter(); |
|
| 50 | interpreter.setJellyContext(context); |
|
| 51 | context.setVariable( "org.apache.commons.jelly.beanshell.JellyInterpreter", interpreter ); |
|
| 52 | } |
|
| 53 | return interpreter; |
|
| 54 | */ |
|
| 55 | } |
|
| 56 | ||
| 57 | ||
| 58 | // ExpressionFactory interface |
|
| 59 | //------------------------------------------------------------------------- |
|
| 60 | public Expression createExpression(String text) throws JellyException { |
|
| 61 | 18 | return new BeanShellExpression(text); |
| 62 | } |
|
| 63 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |