< prev index next >

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

Print this page




  60     public ScriptEngineManager() {
  61         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
  62         init(ctxtLoader);
  63     }
  64 
  65     /**
  66      * This constructor loads the implementations of
  67      * <code>ScriptEngineFactory</code> visible to the given
  68      * <code>ClassLoader</code> using the service provider mechanism.<br><br>
  69      * If loader is <code>null</code>, the script engine factories that are
  70      * bundled with the platform are loaded. <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 TreeSet<ScriptEngineFactory>(Comparator.comparing(ScriptEngineFactory::getEngineName));



  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 {
  91             return ServiceLoader.loadInstalled(ScriptEngineFactory.class);
  92         }
  93     }
  94 
  95     private void initEngines(final ClassLoader loader) {
  96         Iterator<ScriptEngineFactory> itr = null;
  97         try {
  98             ServiceLoader<ScriptEngineFactory> sl = AccessController.doPrivileged(
  99                 new PrivilegedAction<ServiceLoader<ScriptEngineFactory>>() {
 100                     @Override




  60     public ScriptEngineManager() {
  61         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
  62         init(ctxtLoader);
  63     }
  64 
  65     /**
  66      * This constructor loads the implementations of
  67      * <code>ScriptEngineFactory</code> visible to the given
  68      * <code>ClassLoader</code> using the service provider mechanism.<br><br>
  69      * If loader is <code>null</code>, the script engine factories that are
  70      * bundled with the platform are loaded. <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 TreeSet<ScriptEngineFactory>(Comparator.comparing(
  81             ScriptEngineFactory::getEngineName,
  82             Comparator.nullsLast(Comparator.naturalOrder()))
  83         );
  84         nameAssociations = new HashMap<String, ScriptEngineFactory>();
  85         extensionAssociations = new HashMap<String, ScriptEngineFactory>();
  86         mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
  87         initEngines(loader);
  88     }
  89 
  90     private ServiceLoader<ScriptEngineFactory> getServiceLoader(final ClassLoader loader) {
  91         if (loader != null) {
  92             return ServiceLoader.load(ScriptEngineFactory.class, loader);
  93         } else {
  94             return ServiceLoader.loadInstalled(ScriptEngineFactory.class);
  95         }
  96     }
  97 
  98     private void initEngines(final ClassLoader loader) {
  99         Iterator<ScriptEngineFactory> itr = null;
 100         try {
 101             ServiceLoader<ScriptEngineFactory> sl = AccessController.doPrivileged(
 102                 new PrivilegedAction<ServiceLoader<ScriptEngineFactory>>() {
 103                     @Override


< prev index next >