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
The Rhino JavaScript Engine for Java
The newest version!
/* 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 org.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 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.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