30,6 → 30,7 |
// http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/ |
|
import java.io.IOException; |
import java.io.Reader; |
import java.lang.reflect.Method; |
import java.net.URI; |
import java.util.Collection; |
162,7 → 163,6 |
if (null != prependText) { |
rhino.eval(prependText); |
} |
|
if (null != pluginUri) { |
result = rhino.eval(new PluginReader(pluginUri)); |
} |
228,7 → 228,7 |
preCode.append("};\n"); |
|
final ScriptEngine rhino = execute(preCode.toString(), null, null).rhino; |
|
|
try { |
final StringBuilder retriever = new StringBuilder(); |
retriever.append("new ") |
358,4 → 358,27 |
public ScriptEngine getCurrentEngine() { |
return currentEngine; |
} |
|
/** |
* {@inheritDoc} |
*/ |
public Object inject(final Reader code) throws IllegalStateException, PluginException { |
synchronized (currentEngine) { // Probably not needed |
if (null == currentEngine) { |
throw new IllegalStateException("Can only inject code while a sandbox is executing"); |
} |
try { |
return currentEngine.eval(code); |
} |
catch (final ScriptException e) { |
throw new PluginException("Failed to inject code: " + e.getMessage(), e); |
} |
} |
} |
|
@Override public String toString() { |
return "Sandbox("+getClass().getSimpleName()+")["+loadedFrom()+"]"; |
} |
|
|
} |