Load the metadata for all loaded resource classes
768784
private function loadResourceMetadata()
    {
        foreach (get_declared_classes() as $className) {
            if (
                !isset($this->resources[$className]) &&
                is_subclass_of($className, 'Tonic\Resource')
            ) {
                $rm = new ResourceMetadata($className);
                if ($rm->getUri()) {
                    $this->resources[$className] = $rm;
                }
            }
        }
    }
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);
		}
	}
423493
public function load()
    {
        if ($this->fs->exists($this->filename) === false) {
            return;
        }

        try {
            $data = $this->fs->readFile($this->filename);
        } catch (\Exception $e) {
            $message = sprintf('Error loading the site metadata: %s', $e->getMessage());
            throw new LoadSiteMetadataException($message, 0, $e, $this->filename);
        }

        $this->metadata = json_decode($data, true);

        if (0 < $errorCode = json_last_error()) {
            $this->throwInvalidMetadataException($errorCode);
        }
    }
538194
def _initialize(self, **resource_attributes):
        
        super(APIResourceCollection, self)._initialize(**resource_attributes)

        dict_list = self.data
        self.data = []
        for resource in dict_list:
            self.data.append(self._expected_api_resource(**resource))
256096
public function getAllMetadata()
    {
        if (!$this->metadataLoaded) {
            // We have to load all the metadata
            $doctrineMetadata = $this->doctrine->getManager()->getMetadataFactory();

            /** @var ClassMetadata $doctrineClassMetadata */
            foreach ($doctrineMetadata->getAllMetadata() as $doctrineClassMetadata) {
                $reflectionClass = $doctrineClassMetadata->getReflectionClass();
                $this->metadata[$reflectionClass->getName()] = $this->getClassMetadata($reflectionClass);
            }

            $this->metadataLoaded = true;
        }

        $allMetadata = array_filter($this->metadata, function($element) { return null !== $element; });

        return $allMetadata;
    }
1358122
def _load_resources(self, abs_path=False):
        """"""
        from metapack.doc import MetapackDoc

        assert type(self.doc) == MetapackDoc

        for r in self.datafiles:

            # Special handling for SQL is probably a really bad idea. It should be handled as
            # a Rowgenerator.
            if r.term_is('root.sql'):

                if not r.value:
                    self.warn("No value for SQL URL for {} ".format(r.term))
                    continue

                try:
                    self._load_resource(r, abs_path)
                except Exception as e:
                    if r.props.get('ignoreerrors'):
                        self.warn(f"Ignoring errors for {r.name}: {str(e)}")
                        pass
                    else:
                        raise e

            else:

                if not r.url:
                    self.warn("No value for URL for {} ".format(r.term))
                    continue

                try:
                    if self._resource.exists(r):
                        self.prt("Resource '{}' exists, skipping".format(r.name))
                    continue
                except AttributeError:
                    pass

                self.prt("Reading resource {} from {} ".format(r.name, r.resolved_url))

                try:
                    if not r.headers:
                        raise PackageError("Resource {} does not have header. Have schemas been generated?"
                                            .format(r.name))
                except AttributeError:
                    raise PackageError("Resource '{}' of type {} does not have a headers property"
                                       .format(r.url, type(r)))

                try:
                    self._load_resource(r, abs_path)
                except Exception as e:
                    if r.props.get('ignoreerrors'):
                        self.warn(f"Ignoring errors for {r.name}: {str(e)}")
                        pass
                    else:
                        raise e
887340
private void loadEntityMetadata(String persistenceUnit)
    {
        if (persistenceUnit == null)
        {
            throw new IllegalArgumentException(
                    "Must have a persistenceUnitName in order to load entity metadata, you provided :"
                            + persistenceUnit);
        }

        Map<String, PersistenceUnitMetadata> persistentUnitMetadataMap = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadataMap();

        /** Classes to scan */
        List<String> classesToScan;
        URL[] resources = null;
        String client = null;
        List<URL> managedURLs = null;
        if (persistentUnitMetadataMap == null || persistentUnitMetadataMap.isEmpty())
        {
            log.error("It is necessary to load Persistence Unit metadata  for persistence unit " + persistenceUnit
                    + " first before loading entity metadata.");
            throw new MetamodelLoaderException("load Persistence Unit metadata  for persistence unit "
                    + persistenceUnit + " first before loading entity metadata.");
        }
        else
        {
            PersistenceUnitMetadata puMetadata = persistentUnitMetadataMap.get(persistenceUnit);
            classesToScan = puMetadata.getManagedClassNames();
            managedURLs = puMetadata.getManagedURLs();
            client = getClientFactoryName(persistenceUnit);
        }

        /*
         * Check whether Classes to scan was provided into persistence.xml If
         * yes, load them. Otherwise load them from classpath/ context path
         */
        Reader reader;
        ApplicationMetadata appMetadata = kunderaMetadata.getApplicationMetadata();
        if (classesToScan == null || classesToScan.isEmpty())
        {
            log.info("No class to scan for persistence unit " + persistenceUnit
                    + ". Entities will be loaded from classpath/ context-path");
            // Entity metadata is not related to any PU, and hence will be
            // stored at common place
            // persistenceUnit = Constants.COMMON_ENTITY_METADATAS;

            // Check whether all common entity metadata have already been loaded
            if (appMetadata.getMetamodelMap().get(persistenceUnit) != null)
            {
                log.info("All common entitity metadata already loaded, nothing need to be done");
                return;
            }

            reader = new ClasspathReader();
            // resources = reader.findResourcesByClasspath();
        }
        else
        {
            reader = new ClasspathReader(classesToScan);
            // resources = reader.findResourcesByContextLoader();
        }

        InputStream[] iStreams = null;
        PersistenceUnitMetadata puMetadata = persistentUnitMetadataMap.get(persistenceUnit);
        if (this.getClass().getClassLoader() instanceof URLClassLoader && !puMetadata.getExcludeUnlistedClasses())
        {
            URL[] managedClasses = reader.findResources();
            if (managedClasses != null)
            {
                List<URL> managedResources = Arrays.asList(managedClasses);
                managedURLs.addAll(managedResources);
            }
        }
        else
        {
            iStreams = reader.findResourcesAsStream();
        }

        if (managedURLs != null)
        {
            resources = managedURLs.toArray(new URL[] {});
        }

        // All entities to load should be annotated with @Entity
        reader.addValidAnnotations(Entity.class.getName());

        Metamodel metamodel = appMetadata.getMetamodel(persistenceUnit);
        if (metamodel == null)
        {
            metamodel = new MetamodelImpl();
        }

        Map<String, EntityMetadata> entityMetadataMap = ((MetamodelImpl) metamodel).getEntityMetadataMap();
        Map<String, Class<?>> entityNameToClassMap = ((MetamodelImpl) metamodel).getEntityNameToClassMap();
        Map<String, List<String>> puToClazzMap = new HashMap<String, List<String>>();
        Map<String, IdDiscriptor> entityNameToKeyDiscriptorMap = new HashMap<String, IdDiscriptor>();
        List<Class<?>> classes = new ArrayList<Class<?>>();
        if (resources != null && resources.length > 0)
        {
            for (URL resource : resources)
            {
                try
                {
                    ResourceIterator itr = reader.getResourceIterator(resource, reader.getFilter());

                    InputStream is = null;
                    while ((is = itr.next()) != null)
                    {
                        classes.addAll(scanClassAndPutMetadata(is, reader, entityMetadataMap, entityNameToClassMap,
                                persistenceUnit, client, puToClazzMap, entityNameToKeyDiscriptorMap));
                    }
                }
                catch (IOException e)
                {
                    log.error("Error while retrieving and storing entity metadata. Details:", e);
                    throw new MetamodelLoaderException("Error while retrieving and storing entity metadata");

                }
            }
        }
        else if (iStreams != null)
        {
            try
            {
                for (InputStream is : iStreams)
                {
                    try
                    {
                        classes.addAll(scanClassAndPutMetadata(is, reader, entityMetadataMap, entityNameToClassMap,
                                persistenceUnit, client, puToClazzMap, entityNameToKeyDiscriptorMap));
                    }
                    finally
                    {
                        if (is != null)
                        {
                            is.close();
                        }
                    }
                }
            }
            catch (IOException e)
            {
                log.error("Error while retrieving and storing entity metadata. Details:", e);
                throw new MetamodelLoaderException("Error while retrieving and storing entity metadata, Caused by : .",
                        e);

            }
        }
        ((MetamodelImpl) metamodel).setEntityMetadataMap(entityMetadataMap);
        appMetadata.getMetamodelMap().put(persistenceUnit, metamodel);
        appMetadata.setClazzToPuMap(puToClazzMap);
        ((MetamodelImpl) metamodel).addKeyValues(entityNameToKeyDiscriptorMap);
        // assign JPA metamodel.
        ((MetamodelImpl) metamodel).assignEmbeddables(kunderaMetadata.getApplicationMetadata()
                .getMetaModelBuilder(persistenceUnit).getEmbeddables());
        ((MetamodelImpl) metamodel).assignManagedTypes(kunderaMetadata.getApplicationMetadata()
                .getMetaModelBuilder(persistenceUnit).getManagedTypes());
        ((MetamodelImpl) metamodel).assignMappedSuperClass(kunderaMetadata.getApplicationMetadata()
                .getMetaModelBuilder(persistenceUnit).getMappedSuperClassTypes());
    }
1232346
void loadAdditionalServices(ServiceRegistry registry) {
        for (ResourceLoader loader : getResourceLoaders()) {
            for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) {
                Service service = metadata.getValue();
                for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) {
                    Services.put(registry, serviceInterface, service);
                }
            }
        }
    }
1326270
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $class = $metadata->getReflectionClass();

        if (!$class) {
            $class = new \ReflectionClass((string) $className);
        }

        $classAnnotations = $this->reader->getClassAnnotations($class);
        
        $classMapping = array();
        $validMapping = false;
        foreach ($classAnnotations as $annotation) {
            switch(get_class($annotation)) {
                case 'Doctrine\Search\Mapping\Annotations\ElasticSearchable':
                    $classMapping = (array) $annotation;
                    $classMapping['class'] = 'ElasticSearchable';
                    $validMapping = true;
                    break;
                case 'Doctrine\Search\Mapping\Annotations\Searchable':
                    $classMapping = (array) $annotation;
                    $classMapping['class'] = 'Searchable';
                    $validMapping = true;
                    break;
                case 'Doctrine\Search\Mapping\Annotations\ElasticRoot':
                    $rootMapping = (array) $annotation;
                    $metadata->mapRoot($this->rootToArray($rootMapping));
                    break;
            }
        }
        
        if (!$validMapping) {
            throw MappingException::classIsNotAValidDocument($className);
        }
        
        $this->annotateClassMetadata($classMapping, $metadata);

        $properties = $class->getProperties();
        foreach ($properties as $property) {
            $propertyAnnotations = $this->reader->getPropertyAnnotations($property);
            foreach ($propertyAnnotations as $annotation) {
                switch (get_class($annotation)) {
                    case 'Doctrine\Search\Mapping\Annotations\Id':
                        $metadata->identifier = $property->getName();
                        break;
                    case 'Doctrine\Search\Mapping\Annotations\Parameter':
                        $mapping = $this->parameterToArray($property->getName(), (array) $annotation);
                        $metadata->mapParameter($mapping);
                        break;
                    case 'Doctrine\Search\Mapping\Annotations\Field':
                    case 'Doctrine\Search\Mapping\Annotations\ElasticField':
                    case 'Doctrine\Search\Mapping\Annotations\SolrField':
                        $mapping = $this->fieldToArray($property->getName(), (array) $annotation);
                        $metadata->mapField($mapping);
                        break;
                }
            }
        }
    }
784052
def _load(self):
        """"""
        for attr_name, config_prop in self._iter_config_props():
            found = False
            for loader in self._loaders:
                if loader.exists(config_prop.property_key):
                    raw_value = loader.get(config_prop.property_key)
                    converted_value = config_prop.load(raw_value)

                    self._set_instance_prop(attr_name, config_prop, converted_value)
                    found = True
                    break

            if not found:
                if not config_prop.required or config_prop.default is not None:
                    self._set_instance_prop(attr_name, config_prop, config_prop.default)
                else:
                    raise ValueError('Missing required ConfigProperty {}'.format(attr_name))
152045
def _load_attributes(new_class):
        """"""
        for field_name, field_obj in new_class.meta_.declared_fields.items():
            new_class.meta_.attributes[field_obj.get_attribute_name()] = field_obj
71881
private void loadPlugins() {
		// Read the plugin class names from well known resources
		try {
			Enumeration<URL> pluginResources = classLoader.get().getResources(
					"META-INF/services/org.springsource.reloading.agent.Plugins");
			while (pluginResources.hasMoreElements()) {
				URL pluginResource = pluginResources.nextElement();
				if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.FINEST)) {
					log.finest("loadPlugins: TypeRegistry=" + this.toString() + ": loading plugin list file "
							+ pluginResource);
				}
				InputStream is = pluginResource.openStream();
				BufferedReader pluginClassNamesReader = new BufferedReader(new InputStreamReader(is));
				try {
					while (true) {
						String pluginName = pluginClassNamesReader.readLine();
						if (pluginName == null) {
							break;
						}
						if (!pluginName.startsWith("#")) {
							pluginClassNames.add(pluginName);
						}
					}
				}
				catch (IOException ioe) {
					// eof
				}
				is.close();
			}
		}
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// Now load those plugins
		for (String pluginClassName : pluginClassNames) {
			if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.FINEST)) {
				log.finest("loadPlugins: TypeRegistry=" + this.toString() + ": loading plugin " + pluginClassName);
			}
			try {
				Class<?> pluginClass = Class.forName(pluginClassName, false, this.classLoader.get());
				Plugin pluginInstance = (Plugin) pluginClass.newInstance();
				localPlugins.add(pluginInstance);
			}
			catch (Exception e) {
				log.log(Level.WARNING, "Unable to find and instantiate plugin " + pluginClassName, e);
			}
		}
	}
655850
def _load_resources(self):
        """"""

        for t in self.doc.find('Root.Table'):
            for c in t.find('Table.Column'):
                if c.get_value('datatype') == 'geometry':
                    c['transform'] = '^empty_str'
                    c['datatype'] = 'text'

        return super()._load_resources()
400269
protected function loadMetadata($class)
    {
        // first run, we have no parent
        $parent = null;

        $parentClasses = $this->getParentClasses($class);
        $parentClasses[] = $class;

        // iterate through the list of mapped service parent classes
        foreach ($parentClasses as $parentClass) {
            // create an empty metadata class
            $class = new ServiceMetadata($class);

            // copy all data from the immediate parent, if present
            if ($parent) {
                $class->setClassName($parent->getClassName());
                $class->setAllListeners($parent->getAllListeners());
            }

            // now overlay the metadata from the class itself
            if (!isset($this->loadedMetadata[$parentClass])) {
                $this->driver->loadMetadataForClass($parentClass, $class);
                $this->loadedMetadata[$parentClass] = $class;
            }

            // the parent for the next iteration will be this iteration
            $parent = $class;
        }
    }
161222
def populate_metadata(model, MetadataClass):
    
    content_type = ContentType.objects.get_for_model(model)
    for instance in model.objects.all():
        create_metadata_instance(MetadataClass, instance)
1009843
def _load_raw_data(self, resource_name):
        
        # Instantiating the resource again as a simple `Resource` ensures that
        # ``data`` will be returned as bytes.
        upcast_resource = datapackage.Resource(
            self.__resources[resource_name].descriptor,
            default_base_path=self.__base_path)
        return upcast_resource.data
594540
private void loadProfiles() {
    URL convention_default = resources.getGlobal();
    if (null == convention_default) { throw new RuntimeException("cannot find convention-default.properties!"); }
    List<Profile> defaultProfiles = buildProfiles(convention_default, true);
    if (!defaultProfiles.isEmpty()) {
      defaultProfile = defaultProfiles.get(0);
    }
    for (URL url : resources.getLocals()) {
      profiles.addAll(buildProfiles(url, false));
    }
  }