public Object eval(String script, ScriptContext ctx) throws ScriptException { try { String val = (String) ctx.getAttribute("#jsr223.groovy.engine.keep.globals", ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase("soft")) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { Class<?> clazz = getScriptClass(script); if (clazz == null) throw new ScriptException("Script class is null"); return eval(clazz, ctx); } catch (Exception e) { if (debug) e.printStackTrace(); throw new ScriptException(e); } }
/** * {@inheritDoc} */ @Override public Object eval(final String script, final ScriptContext context) throws ScriptException { if (globalFunctionCacheEnabled) { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } } try { registerBindingTypes(context); final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (Exception e) { throw new ScriptException(e); } }
/** * {@inheritDoc} */ @Override public Object eval(final String script, final ScriptContext context) throws ScriptException { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { registerBindingTypes(context); final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (Exception e) { throw new ScriptException(e); } }
public Object eval(String script, ScriptContext ctx) throws ScriptException { try { String val = (String) ctx.getAttribute("#jsr223.groovy.engine.keep.globals", ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase("soft")) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { Class clazz = getScriptClass(script); if (clazz == null) throw new ScriptException("Script class is null"); return eval(clazz, ctx); } catch (SyntaxException e) { throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine()); } catch (Exception e) { if (debug) e.printStackTrace(); throw new ScriptException(e); } } public Bindings createBindings() {
public Object eval(String script, ScriptContext ctx) throws ScriptException { try { String val = (String) ctx.getAttribute("#jsr223.groovy.engine.keep.globals", ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val!=null && val.length()>0) { if (val.equalsIgnoreCase("soft")) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { Class clazz = getScriptClass(script); if (clazz == null) throw new ScriptException("Script class is null"); return eval(clazz, ctx); } catch (SyntaxException e) { throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine()); } catch (Exception e) { if (debug) e.printStackTrace(); throw new ScriptException(e); } }
@Override public Object eval(final String script, final ScriptContext context) throws ScriptException { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (SyntaxException e) { throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine()); } catch (Exception e) { throw new ScriptException(e); } }