Class AbstractPropertySourceLoader

java.lang.Object
com.alibaba.cloud.nacos.parser.AbstractPropertySourceLoader
All Implemented Interfaces:
org.springframework.boot.env.PropertySourceLoader
Direct Known Subclasses:
NacosJsonPropertySourceLoader, NacosXmlPropertySourceLoader

public abstract class AbstractPropertySourceLoader extends Object implements org.springframework.boot.env.PropertySourceLoader
Nacos-specific loader, If need to support other methods of parsing,you need to do the following steps:

1.inherit AbstractPropertySourceLoader;
2. define the filespring.factories and append org.springframework.boot.env.PropertySourceLoader=..;
3.the last step validate.

Notice the use of NacosByteArrayResource .
Author:
zkz
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    canLoad(String name, org.springframework.core.io.Resource resource)
    Prevent interference with other loaders.Nacos-specific loader, unless the reload changes it.
    protected abstract List<org.springframework.core.env.PropertySource<?>>
    doLoad(String name, org.springframework.core.io.Resource resource)
    Load the resource into one or more property sources.
    protected void
    flattenedMap(Map<String,Object> result, Map<String,Object> dataMap, String parentKey)
     
    List<org.springframework.core.env.PropertySource<?>>
    load(String name, org.springframework.core.io.Resource resource)
    Load the resource into one or more property sources.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.boot.env.PropertySourceLoader

    getFileExtensions
  • Constructor Details

    • AbstractPropertySourceLoader

      public AbstractPropertySourceLoader()
  • Method Details

    • canLoad

      protected boolean canLoad(String name, org.springframework.core.io.Resource resource)
      Prevent interference with other loaders.Nacos-specific loader, unless the reload changes it.
      Parameters:
      name - the root name of the property source. If multiple documents are loaded an additional suffix should be added to the name for each source loaded.
      resource - the resource to load
      Returns:
      if the resource can be loaded
    • load

      public List<org.springframework.core.env.PropertySource<?>> load(String name, org.springframework.core.io.Resource resource) throws IOException
      Load the resource into one or more property sources. Implementations may either return a list containing a single source, or in the case of a multi-document format such as yaml a source for each document in the resource.
      Specified by:
      load in interface org.springframework.boot.env.PropertySourceLoader
      Parameters:
      name - the root name of the property source. If multiple documents are loaded an additional suffix should be added to the name for each source loaded.
      resource - the resource to load
      Returns:
      a list property sources
      Throws:
      IOException - if the source cannot be loaded
    • doLoad

      protected abstract List<org.springframework.core.env.PropertySource<?>> doLoad(String name, org.springframework.core.io.Resource resource) throws IOException
      Load the resource into one or more property sources. Implementations may either return a list containing a single source, or in the case of a multi-document format such as yaml a source for each document in the resource.
      Parameters:
      name - the root name of the property source. If multiple documents are loaded an additional suffix should be added to the name for each source loaded.
      resource - the resource to load
      Returns:
      a list property sources
      Throws:
      IOException - if the source cannot be loaded
    • flattenedMap

      protected void flattenedMap(Map<String,Object> result, Map<String,Object> dataMap, String parentKey)