Search in sources :

Example 1 with OriginTrackedResource

use of cn.taketoday.origin.OriginTrackedResource in project today-framework by TAKETODAY.

the class StandardConfigDataLoader method load.

@Override
public ConfigData load(ConfigDataLoaderContext context, StandardConfigDataResource resource) throws IOException, ConfigDataNotFoundException {
    if (resource.isEmptyDirectory()) {
        return ConfigData.EMPTY;
    }
    ConfigDataResourceNotFoundException.throwIfDoesNotExist(resource, resource.getResource());
    StandardConfigDataReference reference = resource.getReference();
    Resource originTrackedResource = OriginTrackedResource.from(resource.getResource(), Origin.from(reference.getConfigDataLocation()));
    String name = String.format("Config resource '%s' via location '%s'", resource, reference.getConfigDataLocation());
    List<PropertySource<?>> propertySources = reference.getPropertySourceLoader().load(name, originTrackedResource);
    PropertySourceOptions options = (resource.getProfile() != null) ? PROFILE_SPECIFIC : NON_PROFILE_SPECIFIC;
    return new ConfigData(propertySources, options);
}
Also used : Resource(cn.taketoday.core.io.Resource) OriginTrackedResource(cn.taketoday.origin.OriginTrackedResource) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) PropertySource(cn.taketoday.core.env.PropertySource)

Example 2 with OriginTrackedResource

use of cn.taketoday.origin.OriginTrackedResource in project today-infrastructure by TAKETODAY.

the class StandardConfigDataLoader method load.

@Override
public ConfigData load(ConfigDataLoaderContext context, StandardConfigDataResource resource) throws IOException, ConfigDataNotFoundException {
    if (resource.isEmptyDirectory()) {
        return ConfigData.EMPTY;
    }
    ConfigDataResourceNotFoundException.throwIfDoesNotExist(resource, resource.getResource());
    StandardConfigDataReference reference = resource.getReference();
    Resource originTrackedResource = OriginTrackedResource.from(resource.getResource(), Origin.from(reference.getConfigDataLocation()));
    String name = String.format("Config resource '%s' via location '%s'", resource, reference.getConfigDataLocation());
    List<PropertySource<?>> propertySources = reference.getPropertySourceLoader().load(name, originTrackedResource);
    PropertySourceOptions options = (resource.getProfile() != null) ? PROFILE_SPECIFIC : NON_PROFILE_SPECIFIC;
    return new ConfigData(propertySources, options);
}
Also used : Resource(cn.taketoday.core.io.Resource) OriginTrackedResource(cn.taketoday.origin.OriginTrackedResource) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) PropertySource(cn.taketoday.core.env.PropertySource)

Aggregations

PropertySource (cn.taketoday.core.env.PropertySource)2 Resource (cn.taketoday.core.io.Resource)2 PropertySourceOptions (cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions)2 OriginTrackedResource (cn.taketoday.origin.OriginTrackedResource)2