load filters from SPI ServiceLoader

@see ServiceLoader
359527
private void initFromSPIServiceLoader() {

        String property = System.getProperty("druid.load.spifilter.skip");
        if (property != null) {
            return;
        }

        ServiceLoader<Filter> druidAutoFilterLoader = ServiceLoader.load(Filter.class);

        for (Filter autoFilter : druidAutoFilterLoader) {
            AutoLoad autoLoad = autoFilter.getClass().getAnnotation(AutoLoad.class);
            if (autoLoad != null && autoLoad.value()) {
                if (LOG.isInfoEnabled()) {
                    LOG.info("load filter from spi :" + autoFilter.getClass().getName());
                }
                addFilter(autoFilter);
            }
        }
    }
1338465
protected function loadResources()
    {
        $config = $this["config.service"];
        foreach (["hooks", "routes", "provider"] as $type) {
            // remnant of an old bad decission
            $confName = $type === "provider" ? "register" : "load";
            if (($config["provider.{$type}.{$confName}"] ?? false) === false) {
                continue;
            }
            if (isset($config["provider.{$type}List"]) === false
                || is_array($config["provider.{$type}List"]) === false
            ) {
                continue;
            }

            foreach ($config["provider.{$type}List"] as $class) {
                $this->register(new $class);
            }
        }
    }
498635
private function loadNativeServices(): void
    {
        // initialize memory and properties controllers
        self::$Memory = MemoryObject::instance();
        self::$Properties = new Properties();
        // initialize debugger
        if (isset($this->_services['Debug']) && $this->_services['Debug'] === true && Debug::isEnabled()) {
            self::$Debug = new Debug();
            $this->startMeasure(__METHOD__);
        }
        // prepare request data
        self::$Request = Request::createFromGlobals();
        // initialize response, securty translate and other workers
        self::$Security = new Security();
        self::$Response = new Response();
        self::$View = new View();
        self::$Translate = new Translate();
        self::$Alias = new Alias();
        self::$Event = new EventManager();
        self::$Cron = new CronManager();
        // stop debug timeline
        if (self::$Debug) {
            $this->stopMeasure(__METHOD__);
        }
    }
1304455
private function loadProfileFilters(ContainerBuilder $container, array $filters)
    {
        $gherkin = $container->getDefinition(self::MANAGER_ID);
        foreach ($filters as $type => $filterString) {
            $filter = $this->createFilterDefinition($type, $filterString);
            $gherkin->addMethodCall('addFilter', array($filter));
        }
    }
86771
@Override
    public boolean needToLoad(FilterInvoker invoker) {
        ConsumerConfig consumerConfig = (ConsumerConfig) invoker.getConfig();
        return consumerConfig.isGeneric();
    }
1045212
private function loadFilterOptions()
    {
        $otherConfig = $this->getOtherConfig();
        $otherConfig->setFields([$this->getPropertyName()]);

        $filterOptions = $this
            ->getEnvironment()
            ->getDataProvider()
            ->getFilterOptions($otherConfig);

        $options = [];
        foreach ($filterOptions as $filterKey => $filterValue) {
            $options[(string) $filterKey] = $filterValue;
        }

        $this->arrFilterOptions = $options;
    }
283622
private function loadApplicationServices()
    {
        // setting default services
        $this->container->set('bbapp', $this->application);
        $this->container->set('container.builder', $this);

        $services_directory = $this->application->getBBDir().'/Config/services';
        foreach (scandir($services_directory) as $file) {
            if (1 === preg_match('#(\w+)\.(yml|xml)$#', $file, $matches)) {
                if ('yml' === $matches[2]) {
                    ServiceLoader::loadServicesFromYamlFile($this->container, $services_directory, $matches[1]);
                } else {
                    ServiceLoader::loadServicesFromXmlFile($this->container, $services_directory, $matches[1]);
                }
            }
        }

        // define in which directory we have to looking for services yml or xml
        $directories = ConfigDirectory::getDirectories(
            null, $this->repository_directory, $this->context, $this->environment
        );

        // Loop into every directory where we can potentially found a services.yml or services.xml
        foreach ($directories as $directory) {
            if (true === is_readable($directory.DIRECTORY_SEPARATOR.self::SERVICE_FILENAME.'.yml')) {
                ServiceLoader::loadServicesFromYamlFile($this->container, $directory);
            }

            if (true === is_readable($directory.DIRECTORY_SEPARATOR.self::SERVICE_FILENAME.'.xml')) {
                ServiceLoader::loadServicesFromXmlFile($this->container, $directory);
            }
        }

        $this->loadLoggerDefinition();
    }
261176
function parseServices (loadedComponents, messages) {
  const parsedServices = serviceParser(
    loadedComponents.blueprintComponents,
    loadedComponents.pluginComponents,
    messages
  )

  if (!parsedServices) {
    fail('parsing', messages)
  }

  return parsedServices
}
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);
  }
358570
def load_filter_files(files)
      # collect the class => path => value entries from each defaults file
      hash = {}
      files.enumerate { |file| load_filter_file(file, hash) }
      logger.debug { "The migrator loaded the filters #{hash.qp}." }
      hash
    end
179478
@Deprecated
    public <T> Collection<Class<? extends T>> discover( Class<T> spi ) {
        Set<Class<? extends T>> result = new HashSet<>();

        for (PluginWrapper p : activePlugins) {
            Service.load(spi, p.classLoader, result);
        }

        return result;
    }
1221850
function load_filter($type, $name)
	{
		switch ($type) {
			case 'output':
				$_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
				require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
				smarty_core_load_plugins($_params, $this);
				break;

			case 'pre':
			case 'post':
				if (!isset($this->_plugins[$type . 'filter'][$name]))
				$this->_plugins[$type . 'filter'][$name] = false;
				break;
		}
	}
277415
public function load(string $helper)
    {
        if (isset($this->filters[$helper])) {
            return call_user_func_array($this->filters[$helper], array_slice(func_get_args(), 1));
        }
    }
1246985
@Override
    public <T> List<T> getServices(final Class<T> serviceType) {
        @SuppressWarnings("unchecked")
        List<T> found = (List<T>) servicesLoaded.get(serviceType);
        if (found != null) {
            return found;
        }

        return loadServices(serviceType);
    }
1270343
private <T> Set<Class<? extends T>> load(Class<T> serviceClass) {
        String serviceFile = SERVICES + "/" + serviceClass.getName();

        LinkedHashSet<Class<? extends T>> providers = new LinkedHashSet<Class<? extends T>>();

        try {
            Enumeration<URL> enumeration = classLoader.getResources(serviceFile);
            while (enumeration.hasMoreElements()) {
                final URL url = enumeration.nextElement();
                final InputStream is = url.openStream();
                BufferedReader reader = null;

                try {
                    reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                    String line = reader.readLine();
                    while (null != line) {
                        line = skipCommentAndTrim(line);

                        if (line.length() > 0) {
                            try {
                                Class<? extends T> provider = classLoader.loadClass(line).asSubclass(serviceClass);
                                providers.add(provider);
                            } catch (ClassCastException e) {
                                ClassLoader other = serviceClass.getClassLoader();
                                if (!classLoader.getClass().equals(serviceClass.getClassLoader())) {
                                    throw new IllegalStateException("Service " + line
                                        + " was loaded by different classloader (" + (other == null ? "bootstrap"
                                            : other.getClass().getName()) + ") then service interface "
                                        + serviceClass.getName() + " (" + classLoader.getClass().getName()
                                        + "), unable to cast classes");
                                }
                                throw new IllegalStateException("Service " + line + " does not implement expected type "
                                    + serviceClass.getName());
                            }
                        }
                        line = reader.readLine();
                    }
                } finally {
                    if (reader != null) {
                        reader.close();
                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("Could not load services for " + serviceClass.getName(), e);
        }
        return providers;
    }
906112
protected function loadService()
    {
        $service = $this->wsdl->getService();
        $this->log('Starting to load service ' . $service->getName());

        $this->service = new Service($this->config, $service->getName(), $this->types, $service->getDocumentation());

        foreach ($this->wsdl->getOperations() as $function) {
            $this->log('Loading function ' . $function->getName());

            $this->service->addOperation(new Operation($function->getName(), $function->getParams(), $function->getDocumentation(), $function->getReturns()));
        }

        $this->log('Done loading service ' . $service->getName());
    }
892920
public static function getServiceFilters(
        $action,
        $service,
        $component = null,
        $requestor = ServiceRequestorTypes::API
    ) {
        if (static::isSysAdmin()) {
            return null;
        }

        $services = (array)static::get('role.services');
        $service = strval($service);
        $component = strval($component);
        if ((false !== $parenStart = strpos($component, '(')) && (false !== $parenEnd = strpos($component, ')'))) {
            $component = substr_replace($component, '', $parenStart, $parenEnd - $parenStart + 1);
        }
        $action = VerbsMask::toNumeric(static::cleanAction($action));

        $serviceAllowed = null;
        $serviceFound = false;
        $componentAllowed = null;
        $componentFound = false;
        $exactAllowed = null;
        $exactFound = false;
        foreach ($services as $svcInfo) {
            $tempRequestors = array_get($svcInfo, 'requestor_mask', ServiceRequestorTypes::API);
            if (!($requestor & $tempRequestors)) {
                //  Requestor type not found in allowed requestors, skip access setting
                continue;
            }

            $tempVerbs = array_get($svcInfo, 'verb_mask');
            if (!($tempVerbs & $action)) {
                continue;
            }

            $tempService = strval(array_get($svcInfo, 'service'));
            if (0 !== strcasecmp($service, $tempService)) {
                continue; // filters only available starting at the service
            }

            $tempComponent = strval(array_get($svcInfo, 'component'));

            if (!empty($component)) {
                if (0 == strcasecmp($component, $tempComponent)) {
                    // exact match
                    $exactAllowed = $svcInfo;
                    $exactFound = true;
                } elseif ((false !== $tempCompStarPos = strpos($tempComponent, '*')) &&
                    (0 == strcasecmp(substr($component . '/', 0, $tempCompStarPos) . '*', $tempComponent))
                ) {
                    $componentAllowed = $svcInfo;
                    $componentFound = true;
                } elseif ('*' == $tempComponent) {
                    $serviceAllowed = $svcInfo;
                    $serviceFound = true;
                } elseif ((false !== $wildcardStart = strpos($component, '{')) &&
                    (false !== $wildcardEnd = strpos($component, '}'))) {
                    $compReg = '^' . substr_replace($component, '[a-zA-Z0-9_]{1,}$', $wildcardStart,
                            $wildcardEnd - $wildcardStart + 1);
                    $compReg = str_replace('/', '\/', $compReg);
                    if ((false !== preg_match("/$compReg/", $tempComponent, $matches)) && !empty($matches)) {
                        $componentAllowed = $svcInfo;
                        $componentFound = true;
                    }
                }
            } else {
                if (empty($tempComponent)) {
                    // exact match
                    $exactAllowed = $svcInfo;
                    $exactFound = true;
                } elseif ('*' == $tempComponent) {
                    $serviceAllowed = $svcInfo;
                    $serviceFound = true;
                }
            }
        }

        $info = null;
        if ($exactFound) {
            $info = $exactAllowed;
        } elseif ($componentFound) {
            $info = $componentAllowed;
        } elseif ($serviceFound) {
            $info = $serviceAllowed;
        }

        if ($info) {
            if (empty($filters = array_get($info, 'filters'))) {
                return null;
            }

            return ['filters' => $filters, 'filter_op' => array_get($info, 'filter_op', 'AND')];
        }

        return null;
    }