src/java.scripting/share/classes/javax/script/ScriptEngineManager.java

Print this page




  49  * @since 1.6
  50  */
  51 public class ScriptEngineManager  {
  52     private static final boolean DEBUG = false;
  53     /**
  54      * The effect of calling this constructor is the same as calling
  55      * <code>ScriptEngineManager(Thread.currentThread().getContextClassLoader())</code>.
  56      *
  57      * @see java.lang.Thread#getContextClassLoader
  58      */
  59     public ScriptEngineManager() {
  60         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
  61         init(ctxtLoader);
  62     }
  63 
  64     /**
  65      * This constructor loads the implementations of
  66      * <code>ScriptEngineFactory</code> visible to the given
  67      * <code>ClassLoader</code> using the <a href="../../../technotes/guides/jar/jar.html#Service%20Provider">service provider</a> mechanism.<br><br>
  68      * If loader is <code>null</code>, the script engine factories that are
  69      * bundled with the platform and that are in the usual extension
  70      * directories (installed extensions) are loaded. <br><br>
  71      *
  72      * @param loader ClassLoader used to discover script engine factories.
  73      */
  74     public ScriptEngineManager(ClassLoader loader) {
  75         init(loader);
  76     }
  77 
  78     private void init(final ClassLoader loader) {
  79         globalScope = new SimpleBindings();
  80         engineSpis = new HashSet<ScriptEngineFactory>();
  81         nameAssociations = new HashMap<String, ScriptEngineFactory>();
  82         extensionAssociations = new HashMap<String, ScriptEngineFactory>();
  83         mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
  84         initEngines(loader);
  85     }
  86 
  87     private ServiceLoader<ScriptEngineFactory> getServiceLoader(final ClassLoader loader) {
  88         if (loader != null) {
  89             return ServiceLoader.load(ScriptEngineFactory.class, loader);
  90         } else {




  49  * @since 1.6
  50  */
  51 public class ScriptEngineManager  {
  52     private static final boolean DEBUG = false;
  53     /**
  54      * The effect of calling this constructor is the same as calling
  55      * <code>ScriptEngineManager(Thread.currentThread().getContextClassLoader())</code>.
  56      *
  57      * @see java.lang.Thread#getContextClassLoader
  58      */
  59     public ScriptEngineManager() {
  60         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
  61         init(ctxtLoader);
  62     }
  63 
  64     /**
  65      * This constructor loads the implementations of
  66      * <code>ScriptEngineFactory</code> visible to the given
  67      * <code>ClassLoader</code> using the <a href="../../../technotes/guides/jar/jar.html#Service%20Provider">service provider</a> mechanism.<br><br>
  68      * If loader is <code>null</code>, the script engine factories that are
  69      * bundled with the platform are loaded. <br>

  70      *
  71      * @param loader ClassLoader used to discover script engine factories.
  72      */
  73     public ScriptEngineManager(ClassLoader loader) {
  74         init(loader);
  75     }
  76 
  77     private void init(final ClassLoader loader) {
  78         globalScope = new SimpleBindings();
  79         engineSpis = new HashSet<ScriptEngineFactory>();
  80         nameAssociations = new HashMap<String, ScriptEngineFactory>();
  81         extensionAssociations = new HashMap<String, ScriptEngineFactory>();
  82         mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
  83         initEngines(loader);
  84     }
  85 
  86     private ServiceLoader<ScriptEngineFactory> getServiceLoader(final ClassLoader loader) {
  87         if (loader != null) {
  88             return ServiceLoader.load(ScriptEngineFactory.class, loader);
  89         } else {