Tries to load the given library using the given load/search order.

@param _libName library name
@param _loadOrder load order
@param _searchPathes search pathes
770187
public static void loadLibrary(String _libName, SearchOrder[] _loadOrder, String... _searchPathes) {
        if (!isEnabled()) {
            return;
        }

        for (SearchOrder order : _loadOrder) {
            if (INSTANCE.findProperNativeLib(order, _libName, _searchPathes) == null) {
                return;
            }
        }
        throw new RuntimeException("Could not load library from any given source: " + Arrays.toString(_loadOrder));
    }
1022621
@Nullable
  public boolean loadLibraries() {
    synchronized (mLock) {
      if (mLoadLibraries == false) {
        return mLibrariesLoaded;
      }
      try {
        if (mLibraryNames != null) {
          for (String name : mLibraryNames) {
            SoLoader.loadLibrary(name);
          }
        }
        initialNativeCheck();
        mLibrariesLoaded = true;
        mLibraryNames = null;
      } catch (UnsatisfiedLinkError error) {
        Log.e(TAG, "Failed to load native lib (initial check): ", error);
        mLinkError = error;
        mLibrariesLoaded = false;
      } catch (Throwable other) {
        Log.e(TAG, "Failed to load native lib (other error): ", other);
        mLinkError = new UnsatisfiedLinkError("Failed loading libraries");
        mLinkError.initCause(other);
        mLibrariesLoaded = false;
      }
      mLoadLibraries = false;
      return mLibrariesLoaded;
    }
  }
1055575
public static void loadNER(String path) throws LoadModelException {
		if(ner==null && pos!=null){
			ner = new NERTagger(pos);
		}
	}
289508
private static final void loadResources(final CClassLoader loader,
			final List URLList, final String resourceName) {
		final List l = loader.getPrivateResource(resourceName);

		if (l != null) {
			URLList.addAll(l);
		}

		final List loaderList = new ArrayList();

		for (final Iterator it = loader.childrenMap.entrySet().iterator(); it
				.hasNext();) {
			final Entry entry = (Entry) it.next();
			loaderList.add(entry.getValue());
		}

		for (int i = 0; i < loaderList.size(); i++) {
			final Object element = loaderList.get(i);
			final CClassLoader child = (CClassLoader) element;
			CClassLoader.loadResources(child, URLList, resourceName);
		}
	}
631213
private void loadLibraryFromStream(String libname, InputStream is) {
    try {
      File tempfile = createTempFile(libname);
      OutputStream os = new FileOutputStream(tempfile);

      logger.debug("tempfile.getPath() = " + tempfile.getPath());

      long savedTime = System.currentTimeMillis();

      // Leo says 8k block size is STANDARD ;)
      byte buf[] = new byte[8192];
      int len;
      while ((len = is.read(buf)) > 0) {
        os.write(buf, 0, len);
      }

      os.flush();
      InputStream lock = new FileInputStream(tempfile);
      os.close();

      double seconds = (double) (System.currentTimeMillis() - savedTime) / 1e3;
      logger.debug("Copying took " + seconds + " seconds.");

      logger.debug("Loading library from " + tempfile.getPath() + ".");
      System.load(tempfile.getPath());

      lock.close();
    } catch (IOException io) {
      logger.error("Could not create the temp file: " + io.toString() + ".\n");
    } catch (UnsatisfiedLinkError ule) {
      logger.error("Couldn't load copied link file: " + ule.toString() + ".\n");
      throw ule;
    }
  }
384843
function _addLibrary(app, item) {
  if (!item.name || item.name === '') {
    try {
      if (typeof item.fn.publicName === 'string') item.name = item.fn.publicName;
    } catch (e) {
    }
  }
  item.name = item.name.trim();
  if (item.name.indexOf('thorin-lib-') === 0) {
    item.name = item.name.substr(11);
  }
  if (typeof app[libraries][item.name] !== 'undefined') {
    throw new Error('Thorin.addLibrary: library ' + item.name + " is already registered. Please use a different name.");
  }
  /* Check if we have a constructor or an already created object. */
  let libType = Object.prototype.toString.call(item.fn);
  let itemObj;
  if (libType === '[object Object]') {
    itemObj = item.fn;
  } else {
    itemObj = new item.fn(app);
  }
  app[libraries][item.name] = itemObj;
}
1002956
protected String findLibrary(final String libname) {
		if (!this.isInit()) {
			if (CClassLoader.sl(CClassLoader.DEBUG)) {
				CClassLoader
						.log("Not initialized, forward to old loader "
								+ libname + " in " + this.getPath(),
								CClassLoader.DEBUG);
			}

			return super.findLibrary(libname);
		}
		final String system = CSystem.getName() + "/" + libname;
		final CThreadContext context = CThreadContext.getInstance();
		final String cpName = CClassLoader.CCLASSLOADER_NAMESPACE + system;
		try {
			List lPriorLoader = (List) context.get(cpName);

			if (lPriorLoader == null) {
				lPriorLoader = new Vector();
				context.set(cpName, lPriorLoader);
			}

			if (lPriorLoader.contains(this.toString())) {
				return null;
			}

			lPriorLoader.add(this.toString());

			if (!this.booAlone) {
				CClassLoader loader = null;

				for (final Iterator it = CClassLoader.mandatoryLoadersMap
						.entrySet().iterator(); it.hasNext();) {
					final Entry entry = (Entry) it.next();
					loader = (CClassLoader) entry.getValue();

					if (loader.dllMap.containsKey(system)) {
						if (loader != this) {
							break;
						}
						loader = null;
						break;
					}
					loader = null;
				}

				if (loader != null) {
					final String c = loader.findLibrary(libname);
					context.set(cpName, null);
					return c;
				}
			}
			String path = null;
			final Object obj = this.dllMap.get(system);
			if (obj instanceof URL) {
				final URL urlToResource = (URL) obj;
				final byte[] buffer = CClassLoader.loadByteArray(urlToResource);
				final File nfile = File.createTempFile(libname
						+ this.hashCode(), ".so");
				final FileOutputStream fout = new FileOutputStream(nfile);
				fout.write(buffer);
				fout.close();
				this.dllMap.put(system, nfile);
				path = nfile.getAbsolutePath();
			} else if (obj instanceof File) {
				final File nfile = (File) obj;
				path = nfile.getAbsolutePath();
			}
			if (path != null) {
				context.set(cpName, null);
				return path;
			}

			// then search in each children
			final List tmpLoader = new ArrayList();

			for (final Iterator it = this.childrenMap.entrySet().iterator(); it
					.hasNext();) {
				final Entry entry = (Entry) it.next();
				final CClassLoader child = (CClassLoader) entry.getValue();

				if (lPriorLoader.contains(child.toString())) {
					continue;
				}

				tmpLoader.add(child);
			}

			for (final Iterator it = tmpLoader.iterator(); it.hasNext();) {
				final Object element = it.next();
				final CClassLoader child = (CClassLoader) element;
				final String c = child.findLibrary(libname);

				if (c != null) {
					return c;
				}
			}

			// then follow to parents
			if ((this != CClassLoader.getRootLoader())
					&& !this.booDoNotForwardToParent) {
				if (lPriorLoader.contains(this.getParent().toString())) {
					return null;
				} else {
					if (this.getParent() instanceof CClassLoader) {
						final CClassLoader parent = (CClassLoader) this
								.getParent();
						return parent.findLibrary(libname);
					} else {
						return super.findLibrary(libname);
					}
				}
			} else {
				final String c = super.findLibrary(libname);
				context.set(cpName, null);
				return c;
			}
		} catch (final IOException e) {
			return super.findLibrary(libname);
		}
	}
398436
private static URL findLibraryResource(final String libraryFileName) {
    String osName = System.getProperty("os.name").toLowerCase();
    String osArch = System.getProperty("os.arch").toLowerCase();
    String resourceName = null;

    LOG.trace("Load library \"{}\" for os {}:{}", libraryFileName, osName, osArch);

    if (osName.startsWith(OS_WIN)) {
      resourceName = determineWindowsLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_LINUX)) {
      resourceName = determineLinuxLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_FREEBSD)) {
      resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_MAC)) {
      resourceName = determineMacLibrary(libraryFileName);
    } else {
      unsupportedPlatform(osName, osArch);
    }

    URL resource = NativeLoader.class.getResource(resourceName);

    if (null == resource) {
      unsupportedPlatform(osName, osArch, resourceName);
    }

    return resource;
  }
1118930
private synchronized static void loadNativeLibrary()
    {
        if (!isLoaded) {
            try {
                nativeLibFile = findNativeLibrary();
                if (nativeLibFile != null) {
                    // Load extracted or specified snappyjava native library.
                    System.load(nativeLibFile.getAbsolutePath());
                } else {
                    // Load preinstalled snappyjava (in the path -Djava.library.path)
                    System.loadLibrary("snappyjava");
                }
            }
            catch (Exception e) {
                e.printStackTrace();
                throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
            }
            isLoaded = true;
        }
    }
662625
public boolean isLibraryUpToDate(String name) {
        Optional<Path> libInst = findLibraryInstall(name);
        if (!libInst.isPresent()) return false; // can we even find it on the system.

        try {
            VersionInfo srcVer = getVersionOfLibrary(name, true);
            VersionInfo dstVer = getVersionOfLibrary(name, false);
            return dstVer.isSameOrNewerThan(srcVer);
        } catch (IOException e) {
            return false; // Library is somehow not good. Certainly not the same!
        }
    }
462883
protected static IPackageFragmentRoot[] findRootsForClasspath(IPath entry, IJavaProject[] searchOrder) {
		for (int i= 0; i < searchOrder.length; i++) {
			IPackageFragmentRoot[] elements= findRootsInProject(entry, searchOrder[i]);
			if (elements.length != 0) {
				return elements;
			}
		}
		return null;
	}
608151
private void doLookups(ClassLoader cl) {
      if (lookupFailed)
         return;
      InitialContext ctx;
      try {
         ctx = new InitialContext();
      }
      catch (NamingException e) {
         log.failedToCreateInitialCtx(e);
         lookupFailed = true;
         return;
      }

      try {
         //probe jndi lookups first
         for (LookupNames.JndiTransactionManager knownJNDIManager : LookupNames.JndiTransactionManager.values()) {
            Object jndiObject;
            try {
               log.debugf("Trying to lookup TransactionManager for %s", knownJNDIManager.getPrettyName());
               jndiObject = ctx.lookup(knownJNDIManager.getJndiLookup());
            }
            catch (NamingException e) {
               log.debugf("Failed to perform a lookup for [%s (%s)]",
                         knownJNDIManager.getJndiLookup(), knownJNDIManager.getPrettyName());
               continue;
            }
            if (jndiObject instanceof TransactionManager) {
               tm = (TransactionManager) jndiObject;
               log.debugf("Found TransactionManager for %s", knownJNDIManager.getPrettyName());
               return;
            }
         }
      } finally {
         Util.close(ctx);
      }

      boolean found = true;
      // The TM may be deployed embedded alongside the app, so this needs to be looked up on the same CL as the Cache
      for (LookupNames.TransactionManagerFactory transactionManagerFactory : LookupNames.TransactionManagerFactory.values()) {
         log.debugf("Trying %s: %s", transactionManagerFactory.getPrettyName(), transactionManagerFactory.getFactoryClazz());
         TransactionManager transactionManager = transactionManagerFactory.tryLookup(cl);
         if (transactionManager != null) {
            log.debugf("Found %s: %s", transactionManagerFactory.getPrettyName(), transactionManagerFactory.getFactoryClazz());
            tm = transactionManager;
            found = false;
         }
      }
      lookupDone = true;
      lookupFailed = found;
   }
488607
def load_tag_library(libname):
    
    from django.template.backends.django import get_installed_libraries
    from django.template.library import InvalidTemplateLibrary
    try:
        lib = get_installed_libraries()[libname]
        lib = importlib.import_module(lib).register
        return lib
    except (InvalidTemplateLibrary, KeyError):
        return None
928120
public static @Nullable String getLibraryPath(String libName) throws IOException {
    sSoSourcesLock.readLock().lock();
    String libPath = null;
    try {
      if (sSoSources != null) {
        for (int i = 0; libPath == null && i < sSoSources.length; ++i) {
          SoSource currentSource = sSoSources[i];
          libPath = currentSource.getLibraryPath(libName);
        }
      }
    } finally {
      sSoSourcesLock.readLock().unlock();
    }
    return libPath;
  }
1045642
def _LoadNvmlLibrary():
    
    global nvmlLib

    if (nvmlLib is None):
        # lock to ensure only one caller loads the library
        libLoadLock.acquire()

        try:
            # ensure the library still isn't loaded
            if (nvmlLib is None):
                try:
                    if (sys.platform[:3] == "win"):
                        searchPaths = [
                            os.path.join(os.getenv("ProgramFiles", r"C:\Program Files"), r"NVIDIA Corporation\NVSMI\nvml.dll"),
                            os.path.join(os.getenv("WinDir", r"C:\Windows"), r"System32\nvml.dll"),
                        ]
                        nvmlPath = next((x for x in searchPaths if os.path.isfile(x)), None)
                        if (nvmlPath == None):
                            _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
                        else:
                            # cdecl calling convention
                            nvmlLib = CDLL(nvmlPath)
                    else:
                        # assume linux
                        nvmlLib = CDLL("libnvidia-ml.so.1")
                except OSError as ose:
                    _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
                if (nvmlLib == None):
                    _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
        finally:
            # lock is always freed
            libLoadLock.release()
1022670
public static void writeLibraryToStream(final String libraryFileName, final DataOutput out) throws IOException {

		final LibraryCacheManager lib = get();
		lib.writeLibraryToStreamInternal(libraryFileName, out);

	}
1095758
@Override
    public T addAsLibrary(String resourceName, String target) throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName must be specified");
        Validate.notNull(target, "Target must be specified");

        return addAsLibrary(resourceName, new BasicPath(target));
    }