Coverage Report - org.webslinger.ext.bsf.rhino.RhinoEngine
 
Classes in this File Line Coverage Branch Coverage Complexity
RhinoEngine
71%
10/14
N/A
0
 
 1  
 package org.webslinger.ext.bsf.rhino;
 2  
 
 3  
 import java.util.Vector;
 4  
 
 5  
 import org.apache.bsf.BSFException;
 6  
 import org.apache.bsf.BSFManager;
 7  
 
 8  
 import org.mozilla.javascript.Context;
 9  
 import org.mozilla.javascript.Function;
 10  
 import org.mozilla.javascript.Scriptable;
 11  
 
 12  
 import org.webslinger.bsf.CompilingLanguageEngineImpl;
 13  
 import org.webslinger.bsf.LanguageEngineInfo;
 14  
 
 15  3
 public class RhinoEngine extends CompilingLanguageEngineImpl<Function, Function> {
 16  
     protected Scriptable scope;
 17  
 
 18  3
     public RhinoEngine() {
 19  3
         Context cx = Context.enter();
 20  
         try {
 21  3
             scope = cx.initStandardObjects();
 22  
         } finally {
 23  3
             Context.exit();
 24  3
         }
 25  3
         compiler = new RhinoCompiler(this);
 26  3
     }
 27  
 
 28  
     public Scriptable getScope() {
 29  12
         return scope;
 30  
     }
 31  
 
 32  
     public LanguageEngineInfo getLanguageEngineInfo() {
 33  0
         return RhinoInfo.INSTANCE;
 34  
     }
 35  
 
 36  
     protected Object apply(Object body, Function compiled, Object[] args) throws Exception {
 37  3
         return Context.call(compiled, getScope(), getScope(), args);
 38  
     }
 39  
 
 40  
     protected Object eval(Object body, Function compiled) throws Exception {
 41  0
         return Context.call(compiled, getScope(), getScope(), null);
 42  
     }
 43  
 
 44  
     protected void exec(Object body, Function compiled) throws Exception {
 45  0
         Context.call(compiled, getScope(), getScope(), null);
 46  0
     }
 47  
 }