org.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
A version of the Rhino Javascript engine pulled diretly from the Mozialla repos.
The newest version!
package org.mozilla.javascript.commonjs.module.provider;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import org.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.1 2010/02/15 19:31:12 szegedia%freemail.hu Exp $
*/
public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase
{
private static final long serialVersionUID = 1L;
private transient ReferenceQueue