@SuppressWarnings({"unchecked", "rawtypes"})
  public List evaluateMappings(Class theClass) {
    GroovyObject obj = (GroovyObject) BeanUtils.instantiateClass(theClass);

    if (obj instanceof Script) {
      Script script = (Script) obj;
      Binding b = new Binding();

      MappingCapturingClosure closure = new MappingCapturingClosure(script);
      b.setVariable("mappings", closure);
      script.setBinding(b);

      script.run();

      Closure mappings = closure.getMappings();

      Binding binding = script.getBinding();
      return evaluateMappings(script, mappings, binding);
    }

    throw new UrlMappingException(
        "Unable to configure URL mappings for class ["
            + theClass
            + "]. A URL mapping must be an instance of groovy.lang.Script.");
  }
 public GroovyScript(Script script, SearchLookup lookup) {
   this.script = script;
   this.lookup = lookup;
   this.variables = script.getBinding().getVariables();
   this.score = new UpdateableFloat(0);
   // Add the _score variable, which will be updated per-document by
   // setting .value on the UpdateableFloat instance
   this.variables.put("_score", this.score);
 }