@Override public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, URI base, Scriptable paths) throws Exception { // Overridden to clear the reference queue before retrieving the // script. for(;;) { ScriptReference ref = (ScriptReference)scriptRefQueue.poll(); if(ref == null) { break; } scripts.remove(ref.getModuleId(), ref); } return super.getModuleScript(cx, moduleId, uri, base, paths); }
@Override public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, Scriptable paths) throws Exception { // Overridden to clear the reference queue before retrieving the // script. for(;;) { ScriptReference ref = (ScriptReference)scriptRefQueue.poll(); if(ref == null) { break; } scripts.remove(ref.getModuleId(), ref); } return super.getModuleScript(cx, moduleId, uri, paths); }
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, URI base, Scriptable paths) throws Exception { for (ModuleScriptProvider provider : providers) { final ModuleScript script = provider.getModuleScript(cx, moduleId, uri, base, paths); if(script != null) { return script; } } return null; }
public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, URI baseUri, Scriptable paths) throws Exception { final CachedModuleScript cachedModule1 = getLoadedModule(moduleId); final Object validator1 = getValidator(cachedModule1); final ModuleSource moduleSource = (moduleUri == null) ? moduleSourceProvider.loadSource(moduleId, paths, validator1) : moduleSourceProvider.loadSource(moduleUri, baseUri, validator1); if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) { return cachedModule1.getModule(); } if(moduleSource == null) { return null; } final Reader reader = moduleSource.getReader(); try { final int idHash = moduleId.hashCode(); synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) { final CachedModuleScript cachedModule2 = getLoadedModule(moduleId); if(cachedModule2 != null) { if(!equal(validator1, getValidator(cachedModule2))) { return cachedModule2.getModule(); } } final URI sourceUri = moduleSource.getUri(); final ModuleScript moduleScript = new ModuleScript( cx.compileReader(reader, sourceUri.toString(), 1, moduleSource.getSecurityDomain()), sourceUri, moduleSource.getBase()); putLoadedModule(moduleId, moduleScript, moduleSource.getValidator()); return moduleScript; } } finally { reader.close(); } }
@Override protected void putLoadedModule(String moduleId, ModuleScript moduleScript, Object validator) { scripts.put(moduleId, new ScriptReference(moduleScript.getScript(), moduleId, moduleScript.getUri(), moduleScript.getBase(), validator, scriptRefQueue)); }
CachedModuleScript getCachedModuleScript() { final Script script = get(); if(script == null) { return null; } return new CachedModuleScript(new ModuleScript(script, uri, base), validator); }
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, Scriptable paths) throws Exception { for (ModuleScriptProvider provider : providers) { final ModuleScript script = provider.getModuleScript(cx, moduleId, uri, paths); if(script != null) { return script; } } return null; }
public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, Scriptable paths) throws Exception { final CachedModuleScript cachedModule1 = getLoadedModule(moduleId); final Object validator1 = getValidator(cachedModule1); final ModuleSource moduleSource = (moduleUri == null) ? moduleSourceProvider.loadSource(moduleId, paths, validator1) : moduleSourceProvider.loadSource(moduleUri, validator1); if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) { return cachedModule1.getModule(); } if(moduleSource == null) { return null; } final Reader reader = moduleSource.getReader(); try { final int idHash = moduleId.hashCode(); synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) { final CachedModuleScript cachedModule2 = getLoadedModule(moduleId); if(cachedModule2 != null) { if(!equal(validator1, getValidator(cachedModule2))) { return cachedModule2.getModule(); } } final URI sourceUri = moduleSource.getUri(); final ModuleScript moduleScript = new ModuleScript( cx.compileReader(reader, sourceUri.toString(), 1, moduleSource.getSecurityDomain()), sourceUri, moduleSource.getBase()); putLoadedModule(moduleId, moduleScript, moduleSource.getValidator()); return moduleScript; } } finally { reader.close(); } }
@Override public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, URI base, Scriptable paths) throws Exception { for (ModuleScriptProvider provider : providers) { final ModuleScript script = provider.getModuleScript(cx, moduleId, uri, base, paths); if(script != null) { return script; } } return null; }
@Override public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, URI baseUri, Scriptable paths) throws Exception { final CachedModuleScript cachedModule1 = getLoadedModule(moduleId); final Object validator1 = getValidator(cachedModule1); final ModuleSource moduleSource = (moduleUri == null) ? moduleSourceProvider.loadSource(moduleId, paths, validator1) : moduleSourceProvider.loadSource(moduleUri, baseUri, validator1); if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) { return cachedModule1.getModule(); } if(moduleSource == null) { return null; } final Reader reader = moduleSource.getReader(); try { final int idHash = moduleId.hashCode(); synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) { final CachedModuleScript cachedModule2 = getLoadedModule(moduleId); if(cachedModule2 != null) { if(!equal(validator1, getValidator(cachedModule2))) { return cachedModule2.getModule(); } } final URI sourceUri = moduleSource.getUri(); final ModuleScript moduleScript = new ModuleScript( cx.compileReader(reader, sourceUri.toString(), 1, moduleSource.getSecurityDomain()), sourceUri, moduleSource.getBase()); putLoadedModule(moduleId, moduleScript, moduleSource.getValidator()); return moduleScript; } } finally { reader.close(); } }