use of org.codehaus.groovy.util.ReferenceBundle in project groovy-core by groovy.
the class GroovyScriptEngineImpl method eval.
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);
}
}
use of org.codehaus.groovy.util.ReferenceBundle in project groovy by apache.
the class GroovyScriptEngineImpl method eval.
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);
}
}
Aggregations