Package com.alibaba.cloud.nacos.parser
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.
NacosByteArrayResource .- Author:
- zkz
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanPrevent interference with other loaders.Nacos-specific loader, unless the reload changes it.protected abstract List<org.springframework.core.env.PropertySource<?>>Load the resource into one or more property sources.protected voidList<org.springframework.core.env.PropertySource<?>>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, waitMethods inherited from interface org.springframework.boot.env.PropertySourceLoader
getFileExtensions
-
Constructor Details
-
AbstractPropertySourceLoader
public AbstractPropertySourceLoader()
-
-
Method Details
-
canLoad
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:
loadin interfaceorg.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
-