publicinterfacePropertySourceFactory{ /** * Create a {@link PropertySource} that wraps the given resource. * @param name the name of the property source * @param resource the resource (potentially encoded) to wrap * @return the new {@link PropertySource} (never {@code null}) * @throws IOException if resource resolution failed */ PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException; }
里边只有一个createPropertySource方法,进入其中的实现类中如下:
1 2 3 4 5 6
publicclassDefaultPropertySourceFactoryimplementsPropertySourceFactory{ @Override public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException { return (name != null ? new ResourcePropertySource(name, resource) : new ResourcePropertySource(resource)); } }
/** * Create a PropertySource having the given name based on Properties * loaded from the given encoded resource. */ publicResourcePropertySource(String name, EncodedResource resource)throws IOException { super(name, PropertiesLoaderUtils.loadProperties(resource)); this.resourceName = getNameForResource(resource.getResource()); } /** * Create a PropertySource based on Properties loaded from the given resource. * The name of the PropertySource will be generated based on the * {@link Resource#getDescription() description} of the given resource. */ publicResourcePropertySource(EncodedResource resource)throws IOException { super(getNameForResource(resource.getResource()), PropertiesLoaderUtils.loadProperties(resource)); this.resourceName = null; }