Finds the SPI configuration, wraps it into a {@link ExtensionWrapper} and loads it to
{@link ServiceExtensionLoader#extensionMappings}.

@param <T>
@param extensionClass
@return
168539
private <T extends Assignable> ExtensionWrapper loadExtensionMapping(Class<T> extensionClass) {
        final InputStream extensionStream = findExtensionImpl(extensionClass);

        ExtensionWrapper extensionWrapper = loadExtensionWrapper(extensionStream, extensionClass);
        this.extensionMappings.put(extensionClass, extensionWrapper);
        return extensionWrapper;
    }
265947
public static ClassLoader resolveClassLoaderForBeanProxy(String contextId, Class<?> proxiedType, TypeInfo typeInfo, ProxyServices proxyServices) {
        Class<?> superClass = typeInfo.getSuperClass();
        if (superClass.getName().startsWith(JAVA)) {
            ClassLoader cl = proxyServices.getClassLoader(proxiedType);
            if (cl == null) {
                cl = Thread.currentThread().getContextClassLoader();
            }
            return cl;
        }
        return Container.instance(contextId).services().get(ProxyServices.class).getClassLoader(superClass);
    }
50697
public static <T> IRelationalJMapper<T> getRelationalMapper(final Class<T> configuredClass){
		return getRelationalMapper(configuredClass, undefinedXML());
	}
808434
public static <T> PluggableProviderService<T> getPluginProviderService(
        Class<T> serviceType,
        String serviceName,
        ServiceProviderLoader loader
    )
    {
        for (PluginProviderServices pluginProviderServices : pluginProviderServiceLoader) {
            if (pluginProviderServices.hasServiceFor(serviceType, serviceName)) {
                return pluginProviderServices.getServiceProviderFor(serviceType, serviceName, loader);
            }
        }
        return null;
    }
503972
private <T extends Assignable> T createExtension(Class<T> extensionImplClass, Archive<?> archive) {

        T extension;
        Constructor<T> extensionImplConstructor = findConstructor(extensionImplClass);

        @SuppressWarnings("unchecked")
        Class<T> constructorArg = (Class<T>) extensionImplConstructor.getParameterTypes()[0];
        try {

            if (constructorArg.isInstance(archive)) {
                extension = extensionImplConstructor.newInstance(archive);
            } else {
                extension = extensionImplConstructor.newInstance(load(constructorArg, archive));
            }
        } catch (InstantiationException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying class can not be abstract.", e);
        } catch (IllegalAccessException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying constructor is inaccessible.", e);
        } catch (InvocationTargetException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying constructor threw an exception.", e);
        }

        return extension;
    }
182635
public static <T> List<T> findServiceProviders( Class<T> klass )
    {
        ServiceLoader<T> loader = ServiceLoader.load( klass );
        List<T> providers = new ArrayList<T>();
        Iterator<T> it = loader.iterator();
        while ( it.hasNext() )
        {
            providers.add( it.next() );
        }
        return providers;
    }
721880
protected function getExtraConfig($class, $classConfig, $excludeMiddleware)
    {
        // Note: 'extensions' config needs to come from it's own middleware call in case
        // applied by delta middleware (e.g. Object::add_extension)
        $extensionSourceConfig = Config::inst()->get($class, null, Config::UNINHERITED | $excludeMiddleware | $this->disableFlag);
        if (empty($extensionSourceConfig['extensions'])) {
            return;
        }

        $extensions = $extensionSourceConfig['extensions'];
        foreach ($extensions as $extension) {
            list($extensionClass, $extensionArgs) = ClassInfo::parse_class_spec($extension);
            // Strip service name specifier
            $extensionClass = strtok($extensionClass, '.');
            if (!class_exists($extensionClass)) {
                throw new InvalidArgumentException("$class references nonexistent $extensionClass in 'extensions'");
            }

            // Init extension
            call_user_func(array($extensionClass, 'add_to_class'), $class, $extensionClass, $extensionArgs);

            // Check class hierarchy from root up
            foreach (ClassInfo::ancestry($extensionClass) as $extensionClassParent) {
                // Skip base classes
                switch ($extensionClassParent) {
                    case Extension::class:
                    case DataExtension::class:
                        continue 2;
                    default:
                        // continue
                }
                // Merge config from extension
                $extensionConfig = Config::inst()->get(
                    $extensionClassParent,
                    null,
                    Config::EXCLUDE_EXTRA_SOURCES | Config::UNINHERITED
                );
                if ($extensionConfig) {
                    yield $extensionConfig;
                }
                if (ClassInfo::has_method_from($extensionClassParent, 'get_extra_config', $extensionClassParent)) {
                    $extensionConfig = call_user_func(
                        [ $extensionClassParent, 'get_extra_config' ],
                        $class,
                        $extensionClass,
                        $extensionArgs
                    );
                    if ($extensionConfig) {
                        yield $extensionConfig;
                    }
                }
            }
        }
    }
928253
public <T extends ServiceConfiguration<?>> List<T> getExistingServiceConfigurations(Class<T> clazz) {
    ArrayList<T> results = new ArrayList<>();
    for (ServiceConfiguration<?> serviceConfiguration : serviceConfigurations) {
      if (clazz.equals(serviceConfiguration.getClass())) {
        results.add(clazz.cast(serviceConfiguration));
      }
    }
    return results;
  }
966729
@Override
    public Class<?> getProxyClass() {
        if (proxyClass != null) {
            return proxyClass;
        }
        try {
            if (StringUtils.isNotBlank(interfaceId)) {
                this.proxyClass = ClassUtils.forName(interfaceId);
                if (!proxyClass.isInterface()) {
                    throw ExceptionUtils.buildRuntime("service.interfaceId",
                        interfaceId, "interfaceId must set interface class, not implement class");
                }
            } else {
                throw ExceptionUtils.buildRuntime("service.interfaceId",
                    "null", "interfaceId must be not null");
            }
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new SofaRpcRuntimeException(e.getMessage(), e);
        }
        return proxyClass;
    }
688681
private static ConfigProvider<Configuration> getProviderByFileExtention(String extention) throws ConfigurationException {
        ConfigProvider<Configuration> provider;
        if (XML_EXTENTION.equals(extention)) {
            provider = new XMLConfigProvider<>(Configuration.class);
        } else if (YML_EXTENTION.equals(extention) || YAML_EXTENTION.equals(extention)) {
            provider = new YAMLConfigProvider<>(Configuration.class);
        } else {
            throw new ConfigurationException("Given file type is not supported.",
                    CONFIG_EXTENTION_NOT_SUPPORTED_EXCEPTION_ID);
        }

        return provider;
    }
600170
public <T> void load(ExtensionRepository<T> repository, Class<T> extensionType) {
//		loadExtensionFromPackage(repository, extensionType, getDefaultScanPackage());
//		String customScanPackage = getCustomScanPackage();
//		if (!Strings.isNullOrEmpty(customScanPackage)) {
//			loadExtensionFromPackage(repository, extensionType, customScanPackage);
//		}
		loadMetricsFromSPI(repository, extensionType);
	}
754996
public Iterator getCurrentServiceSelectors(Class serviceClass)
	{
		BeanContextServiceProvider provider = getLocalServiceProvider(serviceClass);
		return provider == null ? null : new BCSIterator(provider.getCurrentServiceSelectors(getBeanContextServicesPeer(), serviceClass));
	}
597237
private Document parseExtensionFile(String serviceName) {

		String extensionFileName = serviceName + "-Extensions.xml";

    	if (isIddAsResource()) {
    		InputStream is = resourceLoader.getResourceAsStream(extensionFileName);
    		if (is != null) {
    			return XmlUtil.parse(is, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    	else {
    		File extensionsFile = new File( new File(getBaseDir(), RESOURCES_DIR), extensionFileName);
    		if (extensionsFile.exists()) {
        		return XmlUtil.parse(extensionsFile, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    }
847019
public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> clazz, ExtensionLoaderListener<T> listener) {
        ExtensionLoader<T> loader = LOADER_MAP.get(clazz);
        if (loader == null) {
            synchronized (ExtensionLoaderFactory.class) {
                loader = LOADER_MAP.get(clazz);
                if (loader == null) {
                    loader = new ExtensionLoader<T>(clazz, listener);
                    LOADER_MAP.put(clazz, loader);
                }
            }
        }
        return loader;
    }
604393
@SuppressWarnings("unchecked")
  @Override
  public <C extends Configuration<K, T>> C getConfiguration(Class<C> clazz) {
    final C c = cache.getConfiguration(clazz);
    if (c instanceof CompleteConfiguration) {
      final CompleteConfiguration<K, T> cc = (CompleteConfiguration<K,T>) c;
      return (C) new CompleteConfiguration<K, T>() {
        @Override
        public Iterable<CacheEntryListenerConfiguration<K, T>> getCacheEntryListenerConfigurations() {
          return cc.getCacheEntryListenerConfigurations();
        }

        @Override
        public boolean isReadThrough() {
          return cc.isReadThrough();
        }

        @Override
        public boolean isWriteThrough() {
          return cc.isWriteThrough();
        }

        @Override
        public boolean isStatisticsEnabled() {
          return cc.isStatisticsEnabled();
        }

        @Override
        public boolean isManagementEnabled() {
          return cc.isManagementEnabled();
        }

        @Override
        public Factory<CacheLoader<K, T>> getCacheLoaderFactory() {
          return cc.getCacheLoaderFactory();
        }

        @Override
        public Factory<CacheWriter<? super K, ? super T>> getCacheWriterFactory() {
          return cc.getCacheWriterFactory();
        }

        @Override
        public Factory<ExpiryPolicy> getExpiryPolicyFactory() {
          return cc.getExpiryPolicyFactory();
        }

        @Override
        public Class<K> getKeyType() {
          return cc.getKeyType();
        }

        @Override
        public Class<T> getValueType() {
          return cc.getValueType();
        }

        @Override
        public boolean isStoreByValue() {
          return true;
        }
      };
    } else if (c instanceof Configuration) {
      return (C) new Configuration<K, T>() {
        @Override
        public Class<K> getKeyType() {
          return c.getKeyType();
        }

        @Override
        public Class<T> getValueType() {
          return c.getValueType();
        }

        @Override
        public boolean isStoreByValue() {
          return true;
        }
      };
    }
    return c;
  }
1348817
private Class getDynamicProxyClass(Class baseClass) {
        Class[] m_dynamicProxyClassInterfaces;
        if (foundInterfaces.containsKey(baseClass)) {
            m_dynamicProxyClassInterfaces = (Class[])foundInterfaces.get(baseClass);
        } else {
            m_dynamicProxyClassInterfaces = getInterfaces(baseClass);
            foundInterfaces.put(baseClass, m_dynamicProxyClassInterfaces);
        }

        // return dynymic Proxy Class implementing all interfaces
        Class proxyClazz = Proxy.getProxyClass(baseClass.getClassLoader(), m_dynamicProxyClassInterfaces);
        return proxyClazz;
    }
227075
@Override
    public Set<String> getExtensionClasses() {

        Set<String> serviceClazzes = new HashSet<>();

        if (getType() == ArchiveType.WEB_MODULE) {
            Resource webInfClassesMetaInfServicesEntry = getResource(CDIUtils.WEB_INF_CLASSES_META_INF_SERVICES_CDI_EXTENSION);
            serviceClazzes.addAll(CDIUtils.parseServiceSPIExtensionFile(webInfClassesMetaInfServicesEntry));
        }

        Resource metaInfServicesEntry = getResource(CDIUtils.META_INF_SERVICES_CDI_EXTENSION);
        serviceClazzes.addAll(CDIUtils.parseServiceSPIExtensionFile(metaInfServicesEntry));
        return serviceClazzes;
    }