Serves resources in the class loader.
763113
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        String path = req.getRestOfPath();
        if (path.charAt(0)=='/') path = path.substring(1);

        if(!allowedResources.containsKey(path)) {
            if(!allowResourceToBeServed(path)) {
                rsp.sendError(SC_FORBIDDEN);
                return;
            }
            // remember URLs that we can serve. but don't remember error ones, as it might be unbounded
            allowedResources.put(path,path);
        }

        URL res = classLoader.getResource(path);
        if(res==null) {
            throw HttpResponses.error(SC_NOT_FOUND,new IllegalArgumentException("No such adjunct found: "+path));
        } else {
            long expires = MetaClass.NO_CACHE ? 0 : expiration;
            rsp.serveFile(req,res,expires);
        }
    }
192914
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();
		$config = $this->validateConfig($this->defaults);

		if ($config['lazy'] === true) {
			$builder->addDefinition($this->prefix('dispatcher'))
				->setType(LazyEventDispatcher::class);
		} else {
			$builder->addDefinition($this->prefix('dispatcher'))
				->setType(EventDispatcher::class);
		}
	}
147367
private function load()
    {
        $this->initialise();
        $this->data_connector->resourceLinkShareKeyLoad($this);
        if (!is_null($this->id)) {
            $this->length = strlen($this->id);
        }
        if (!is_null($this->expires)) {
            $this->life = ($this->expires - time()) / 60 / 60;
        }
    }
1128599
protected final void load()throws Exception
	{
		synchronized (this) {
			Set<Class<?>> classes=classProvider.getLoadedClasses();
			initScriptClasses(classes);
			onScriptLoaded(classes);
		}
	}
44025
private void load(final String resourceName) {
		boolean found = false;

		try {
			resources.push(resourceName);

			// Try classloader - load the resources in reverse order of the enumeration.  Since later-loaded resources
			// override earlier-loaded ones, this better corresponds to the usual classpath behaviour.
			ClassLoader classloader = getParamsClassLoader();
			List<URL> urls = new ArrayList<>();

			for (Enumeration<URL> res = classloader.getResources(resourceName); res.
					hasMoreElements();) {
				urls.add(res.nextElement());
			}

			recordMessage("Resource " + resourceName + " was found  " + urls.size() + " times");

			// Sometimes the same URL will crop up several times (because of redundant entries in classpaths).  Also,
			// sometimes the same file appears under several URLS (because it's packaged into a jar and also a classes
			// directory, perhaps). In these circumstances we really only want to load the resource once - we load the
			// first one and then ignore later ones.
			Map<String, String> loadedFiles = new HashMap<>();

			// Build up a list of the byte arrays from the files that we then process.
			List<byte[]> contentsList = new ArrayList<>();
			List<URL> urlList = new ArrayList<>();

			// This processes from the front-of-classpath to end-of-classpath since end-of-classpath ones appear last in
			// the enumeration
			for (int i = 0; i < urls.size(); i++) {
				URL url = urls.get(i);
				found = true;

				// Load the contents of the resource, for comparison with existing resources.
				InputStream urlContentStream = url.openStream();
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				StreamUtil.copy(urlContentStream, baos);
				urlContentStream.close();
				byte[] urlContentBytes = baos.toByteArray();
				String urlContent = new String(urlContentBytes, "UTF-8");

				// Check if we have already loaded this file.
				if (loadedFiles.keySet().contains(urlContent)) {
					recordMessage("Skipped url " + url + " - duplicate of " + loadedFiles.get(urlContent));
					continue;
				}

				loadedFiles.put(urlContent, url.toString());
				contentsList.add(urlContentBytes);
				urlList.add(url);
			}

			for (int i = contentsList.size() - 1; i >= 0; i--) {
				byte[] buff = contentsList.get(i);
				URL url = urlList.get(i);
				recordMessage("Loading from url " + url + "...");
				ByteArrayInputStream in = new ByteArrayInputStream(buff);

				// Use the "IncludeProperties" to load properties into us one at a time....
				IncludeProperties properties = new IncludeProperties(url.toString());
				properties.load(in);
			}

			File file = new File(resourceName);

			// Don't reload the file in the working directory if we are in the home directory.
			if (file.exists()) {
				recordMessage("Loading from file " + filename(file) + "...");
				found = true;

				// Use the "IncludeProperties" to load properties into us, one at a time....
				IncludeProperties properties = new IncludeProperties("file:" + filename(file));
				properties.load(new BufferedInputStream(new FileInputStream(file)));
			}

			if (!found) {
				recordMessage("Did not find resource " + resourceName);
			}
		} catch (IOException ex) {
			// This is bad.
			recordException(ex);
		} catch (IllegalArgumentException ex) {
			// Most likely a "Malformed uxxxx encoding." error, which is
			// usually caused by a developer forgetting to escape backslashes
			recordException(ex);
		} finally {
			resources.pop();
		}
	}
417710
private void preloadContextCache(List<Class<?>> classes) throws JAXBException {
    if (classes != null && !classes.isEmpty()) {
      for (Class<?> clazz : classes) {
        getContext(clazz);
      }
    }
  }
11451
private static void handleResourceLoader(final Object resourceLoader, final ClassLoader classLoader,
            final ClasspathOrder classpathOrderOut, final ScanSpec scanSpec, final LogNode log) {
        if (resourceLoader == null) {
            return;
        }
        // PathResourceLoader has root field, which is a Path object
        final Object root = ReflectionUtils.getFieldVal(resourceLoader, "root", false);
        // type VirtualFile
        final File physicalFile = (File) ReflectionUtils.invokeMethod(root, "getPhysicalFile", false);
        String path = null;
        if (physicalFile != null) {
            final String name = (String) ReflectionUtils.invokeMethod(root, "getName", false);
            if (name != null) {
                // getParentFile() removes "contents" directory
                final File file = new File(physicalFile.getParentFile(), name);
                if (FileUtils.canRead(file)) {
                    path = file.getAbsolutePath();
                } else {
                    // This is an exploded jar or classpath directory
                    path = physicalFile.getAbsolutePath();
                }
            } else {
                path = physicalFile.getAbsolutePath();
            }
        } else {
            path = (String) ReflectionUtils.invokeMethod(root, "getPathName", false);
            if (path == null) {
                // Try Path or File
                final File file = root instanceof Path ? ((Path) root).toFile()
                        : root instanceof File ? (File) root : null;
                if (file != null) {
                    path = file.getAbsolutePath();
                }
            }
        }
        if (path == null) {
            final File file = (File) ReflectionUtils.getFieldVal(resourceLoader, "fileOfJar", false);
            if (file != null) {
                path = file.getAbsolutePath();
            }
        }
        if (path != null) {
            classpathOrderOut.addClasspathEntry(path, classLoader, scanSpec, log);
        } else {
            if (log != null) {
                log.log("Could not determine classpath for ResourceLoader: " + resourceLoader);
            }
        }
    }
1123015
public static <T> List<T> loadAll(
      Class<T> klass,
      Iterable<Class<?>> hardCodedClasses,
      ClassLoader classLoader,
      PriorityAccessor<T> priorityAccessor) {
    return ServiceProviders.loadAll(klass, hardCodedClasses, classLoader, priorityAccessor);
  }
1165522
public <T> T loadResources(Class<T> type, String... resources) {
    return loadResources(type, Arrays.asList(resources));
  }
971736
private function _serve_file()
    {
        // Set either the source or cache file as our datasource
        if ($this->serve_default) {
            $file_data = $this->source_file;
        } else {
            $file_data = $this->cached_file;
        }
        
        // Output the file
        $this->_output_file($file_data);
    }
489420
protected void load() {
        if (loader == null) {
            setInfiniteScrollLoader(new InfiniteScrollLoader());
        }

        offset = loadConfig.getOffset();
        limit = loadConfig.getLimit();
        load(offset, limit);
    }
1080234
def loader():
    """"""
    url = request.args.get('url')  # read image URL as a request URL param
    response = requests.get(url)  # make request to static image file
    return response.content
368766
public function loadResources()
    {
        if (is_null($this->resources) || $this->resources->isEmpty()) {
            $this->resources = $this->resourceLoader->loadResources()->map(
                function ($resource) {
                    return $this->handleExceptions(function () use ($resource) {
                        return $this->makeResource($resource);
                    });
                }
            );
        }

        return $this->resources;
    }
92500
public void load(ByteArrayBuffer buffer)
    throws IOException
  {
    synchronized (this) {
      Source classPath = getClassPath();
    
      buffer.clear();

      int retry = 3;
      for (int i = 0; i < retry; i++) {
        long length = -1;
        
        try (InputStream is = classPath.inputStream()) {
          length = classPath.length();
          long lastModified = classPath.getLastModified();

          if (length < 0)
            throw new IOException("class loading failed because class file '" + classPath + "' does not have a positive length.  Possibly the file has been overwritten");

          buffer.setLength((int) length);

          int results = IoUtil.readAll(is, buffer.getBuffer(), 0, (int) length);

          if (results == length
              && length == classPath.length()
              && lastModified == classPath.getLastModified()) {
            return;
          }

          log.warning(L.l("{0}: class file length mismatch expected={1} received={2}.  The class file may have been modified concurrently.",
                this, length, results));
        }
      }
    }
  }
899178
protected function forcePhpConsoleClassesAutoLoad() {
		foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__), \RecursiveIteratorIterator::LEAVES_ONLY) as $path) {
			/** @var $path \SplFileInfo */
			if($path->isFile() && $path->getExtension() == 'php' && $path->getFilename() !== 'PsrLogger.php') {
				require_once($path->getPathname());
			}
		}
	}
898168
function loadResourcesHandler (classpath, self) {
        var Handler = Aria.getClassRef(classpath);

        if (Handler) {
            return new Handler();
        } else {
            var callbackArgs = {
                scope : self,
                classpath : classpath
            };

            Aria.load({
                classes : [classpath],
                oncomplete : {
                    fn : delayLoading,
                    args : callbackArgs
                },
                onerror : {
                    fn : resourcesHandlerError,
                    args : callbackArgs
                }
            });

            return new PromisedHandler();
        }
    }
445023
@Override
    public void reloadClasses( String [] classNames )
        throws ClassPathException
    {
        clearCaches();

        // validate that it is a class here?

        // init base class loader if there is none...
        if ( baseLoader == null )
            initBaseLoader();

        DiscreteFilesClassLoader.ClassSourceMap map =
            new DiscreteFilesClassLoader.ClassSourceMap();

        for (int i=0; i< classNames.length; i++) {
            String name = classNames[i];

            // look in baseLoader class path
            ClassSource classSource = baseClassPath.getClassSource( name );

            // look in user class path
            if ( classSource == null ) {
                BshClassPath.getUserClassPath().insureInitialized();
                classSource = BshClassPath.getUserClassPath().getClassSource(
                    name );
            }

            // No point in checking boot class path, can't reload those.
            // else we could have used fullClassPath above.

            if ( classSource == null )
                throw new ClassPathException("Nothing known about class: "
                    +name );

            // JarClassSource is not working... just need to implement it's
            // getCode() method or, if we decide to, allow the BshClassManager
            // to handle it... since it is a URLClassLoader and can handle JARs
            if ( classSource instanceof JarClassSource )
                throw new ClassPathException("Cannot reload class: "+name+
                    " from source: "+ classSource );

            map.put( name, classSource );
        }

        // Create classloader for the set of classes
        DiscreteFilesClassLoader.newInstance( this, map );

        // map those classes the loader in the overlay map
        Iterator it = map.keySet().iterator();
        while ( it.hasNext() )
            loaderMap.put( it.next(), DiscreteFilesClassLoader.instance() );

        classLoaderChanged();
    }