wro4j-extensions/src/main/java/ro/isdc/wro/extensions/script/RhinoScriptBuilder.java
public Object evaluate(final String script, final String sourceName) {
    notNull(script);
    // make sure we have a context associated with current thread
    try {
      return getContext().evaluateString(scope, script, sourceName, 1, null);
    } catch (final RhinoException e) {
      final String message = RhinoUtils.createExceptionMessage(e);
      LOG.error("JavaScriptException occured: {}", message);
      throw new WroRuntimeException(message);
    } finally {
      // Rhino throws an exception when trying to exit twice. Make sure we don't get any exception
      if (Context.getCurrentContext() != null) {
        Context.exit();
      }
    }
  }
public Object evaluate(final String script, final String sourceName) {
    notNull(script);
    // make sure we have a context associated with current thread
    try {
      return getContext().evaluateString(scope, script, sourceName, 1, null);
    } catch (final RhinoException e) {
      final String message = RhinoUtils.createExceptionMessage(e);
      LOG.error("JavaScriptException occured: {}", message);
      throw new WroRuntimeException(message);
    } finally {
      // Rhino throws an exception when trying to exit twice. Make sure we don't get any exception
      if (Context.getCurrentContext() != null) {
        Context.exit();
      }
    }
  }
public Object evaluate ( final String script , final String sourceName ) { notNull ( script ) ; // make sure we have a context associated with current thread
 try { return getContext ( ) . evaluateString ( scope , script , sourceName , 1 , null ) ; } catch ( final RhinoException e ) { final String message = RhinoUtils . createExceptionMessage ( e ) ; LOG . error ( "JavaScriptException occured: {}" , message ) ; throw new WroRuntimeException ( message ) ; } finally { // Rhino throws an exception when trying to exit twice. Make sure we don't get any exception
 if ( Context . getCurrentContext ( ) != null ) { Context . exit ( ) ; } } }
Evaluates a script.

@param script string representation of the script to evaluate.
@param sourceName the name of the evaluated script.
@return evaluated object.
@throws IOException if the script couldn't be retrieved.
Evaluates a script .