}
private static Script getCompiledScript(Context cx, String code, String fileName)
{
ScriptRunner runner = (ScriptRunner)cx.getThreadLocal(ScriptRunner.RUNNER);
ClassCache cache = runner.getEnvironment().getClassCache();
if (cache == null) {
return compileScript(cx, code, fileName);
}
String cacheKey = makeCacheKey(code);
Script compiled = cache.getCachedScript(cacheKey);
if (compiled == null) {
compiled = compileScript(cx, code, fileName);
if (compiled != null) {
cache.putCachedScript(cacheKey, compiled);
}
}
// Still may be null at this point...
return compiled;
}