| 1 | |
package org.webslinger.ext.bsf.beanshell; |
| 2 | |
|
| 3 | |
import org.webslinger.bsf.CompilingLanguageEngineImpl; |
| 4 | |
import org.webslinger.bsf.LanguageEngineInfo; |
| 5 | |
|
| 6 | |
import bsh.BshMethod; |
| 7 | |
import bsh.CallStack; |
| 8 | |
import bsh.EvalError; |
| 9 | |
import bsh.Interpreter; |
| 10 | |
|
| 11 | 3 | public class BeanShellEngine extends CompilingLanguageEngineImpl<BeanShellCompiled, BeanShellCompiled> { |
| 12 | 3 | public BeanShellEngine() { |
| 13 | 3 | compiler = new BeanShellCompiler(this); |
| 14 | 3 | } |
| 15 | |
|
| 16 | |
public LanguageEngineInfo getLanguageEngineInfo() { |
| 17 | 0 | return BeanShellInfo.INSTANCE; |
| 18 | |
} |
| 19 | |
|
| 20 | |
public Object apply(Object body, BeanShellCompiled compiled, Object[] args) throws Exception { |
| 21 | 3 | if (compiled == null) throw new InternalError("Nothing compiled?"); |
| 22 | 3 | return compiled.invoke(new Object[] {args}); |
| 23 | |
} |
| 24 | |
|
| 25 | |
public Object eval(Object body, BeanShellCompiled compiled) throws Exception { |
| 26 | 0 | if (compiled == null) throw new InternalError("Nothing compiled?"); |
| 27 | 0 | return compiled.invoke(null); |
| 28 | |
} |
| 29 | |
|
| 30 | |
public void exec(Object body, BeanShellCompiled compiled) throws Exception { |
| 31 | 0 | if (compiled == null) throw new InternalError("Nothing compiled?"); |
| 32 | 0 | compiled.invoke(null); |
| 33 | 0 | } |
| 34 | |
} |