jscover.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in
Java. It is typically embedded into Java applications to provide
scripting to end users.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package jscover.mozilla.javascript.commonjs.module.provider;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import jscover.mozilla.javascript.Context;
import jscover.mozilla.javascript.Script;
import jscover.mozilla.javascript.Scriptable;
import jscover.mozilla.javascript.commonjs.module.ModuleScript;
/**
* A module script provider that uses a module source provider to load modules
* and caches the loaded modules. It softly references the loaded modules'
* Rhino {@link Script} objects, thus a module once loaded can become eligible
* for garbage collection if it is otherwise unused under memory pressure.
* Instances of this class are thread safe.
* @author Attila Szegedi
* @version $Id: SoftCachingModuleScriptProvider.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $
*/
public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase
{
private static final long serialVersionUID = 1L;
private transient ReferenceQueue