コード例 #1
0
ファイル: RhinoEngine.java プロジェクト: oberhamsi/ringojs
 Singleton getSingleton(Singleton singleton) {
   synchronized (singletons) {
     Singleton st = singletons.get(singleton);
     if (st == null) {
       st = singleton;
       singletons.put(singleton, singleton);
     }
     return st;
   }
 }
コード例 #2
0
ファイル: RhinoEngine.java プロジェクト: oberhamsi/ringojs
 /**
  * Resolves a type name to a script file within our script directory and returns a Scriptable
  * evaluated to the file.
  *
  * @param moduleName the name of the module to load
  * @param localPath the path of the resource issuing this call
  * @return The raw compiled script for the module
  * @throws JavaScriptException if an error occurred evaluating the script file
  * @throws IOException if an error occurred reading the script file
  */
 public ReloadableScript getScript(String moduleName, Repository localPath)
     throws JavaScriptException, IOException {
   ReloadableScript script;
   Resource source = findResource(moduleName, loaders, localPath);
   if (!source.exists()) {
     source = loadPackage(moduleName, localPath);
     if (!source.exists()) {
       source = findResource(moduleName, null, localPath);
     }
   }
   Context cx = Context.getCurrentContext();
   Map<Trackable, ReloadableScript> scripts = getScriptCache(cx);
   if (scripts.containsKey(source)) {
     script = scripts.get(source);
   } else {
     script = new ReloadableScript(source, this);
     if (source.exists()) {
       scripts.put(source, script);
     }
   }
   return script;
 }