class DynamicMethodInvocationHandler implements InvocationHandler {

    private final Object thiz;


    public DynamicMethodInvocationHandler(final Object thiz) {
      super();
      this.thiz = thiz;
    }


    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args)
        throws Throwable {
      String name = method.getName();
      return invokeMethod(this.thiz, name, args);
    }
  }


  @SuppressWarnings("unchecked")
  @Override
  public <T> T getInterface(final Object thiz, final Class<T> clasz) {
    return (T) Proxy.newProxyInstance(clasz.getClassLoader(), new Class[] {clasz},
        new DynamicMethodInvocationHandler(thiz));
  }



  public AviatorScriptEngine(final Bindings n) {
    super(n);
    this.factory = AviatorScriptEngineFactory.newInstance();
    this.engine = AviatorEvaluator.newInstance();
  }


  public AviatorScriptEngine(final AviatorScriptEngineFactory factory) {
    this.factory = factory;
    this.engine = AviatorEvaluator.newInstance();
    this.engine.setFunctionMissing(JavaMethodReflectionFunctionMissing.getInstance());
  }


  @Override
  public CompiledScript compile(final String script) throws ScriptException {
    return new CompiledAviatorScript(this,
        this.engine.compile(getCachingKey(script), script, this.cached));
  }


  public String getCachingKey(final String script) {<FILL_FUNCTION_BODY>

    if (script.length() < KEY_THRESHOLD) {
      return script;
    } else {
      return Utils.md5sum(script);
    }
  
<methods>public void <init>() ,public void <init>(javax.script.Bindings) ,public java.lang.Object eval(java.io.Reader) throws javax.script.ScriptException,public java.lang.Object eval(java.lang.String) throws javax.script.ScriptException,public java.lang.Object eval(java.io.Reader, javax.script.Bindings) throws javax.script.ScriptException,public java.lang.Object eval(java.lang.String, javax.script.Bindings) throws javax.script.ScriptException,public java.lang.Object get(java.lang.String) ,public javax.script.Bindings getBindings(int) ,public javax.script.ScriptContext getContext() ,public void put(java.lang.String, java.lang.Object) ,public void setBindings(javax.script.Bindings, int) ,public void setContext(javax.script.ScriptContext) <variables>protected javax.script.ScriptContext context