Repository: incubator-tamaya-extensions Updated Branches: refs/heads/master 4c68c583e -> 74e6cda80
[TAMAYA-206] Access to the resource paths is now encaplsulated by a getter and setter. Needed change for an example. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/74e6cda8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/74e6cda8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/74e6cda8 Branch: refs/heads/master Commit: 74e6cda8041646ad8ebfeb66cecf625e1f19280a Parents: 4c68c58 Author: Oliver B. Fischer <[email protected]> Authored: Sat Jan 21 19:21:00 2017 +0100 Committer: Oliver B. Fischer <[email protected]> Committed: Sat Jan 21 19:54:30 2017 +0100 ---------------------------------------------------------------------- .../AbstractPathPropertySourceProvider.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/74e6cda8/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java b/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java index 1b62c65..791f2c2 100644 --- a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java +++ b/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java @@ -55,13 +55,14 @@ public abstract class AbstractPathPropertySourceProvider implements PropertySour if(resourcePaths.length==0){ throw new IllegalArgumentException("At least one resource path should be configured."); } - this.resourcePaths = resourcePaths.clone(); + + setResourcePaths(resourcePaths); } @Override public Collection<PropertySource> getPropertySources() { List<PropertySource> propertySources = new ArrayList<>(); - for(String resource:resourcePaths) { + for (String resource : getResourcePaths()) { try { Collection<URL> resources = ConfigResources.getResourceResolver().getResources(resource); for (URL url : resources) { @@ -81,6 +82,14 @@ public abstract class AbstractPathPropertySourceProvider implements PropertySour return propertySources; } + protected String[] getResourcePaths() { + return resourcePaths; + } + + protected void setResourcePaths(String[] paths) { + resourcePaths = paths.clone(); + } + /** * Factory method that creates a {@link org.apache.tamaya.spi.PropertySource} based on the URL found by * the resource locator. @@ -99,11 +108,11 @@ public abstract class AbstractPathPropertySourceProvider implements PropertySour */ public static PropertySource createPropertiesPropertySource(URL url) { Properties props = new Properties(); - try(InputStream is = url.openStream()){ + try (InputStream is = url.openStream()){ props.load(is); return new PropertiesBasedPropertySource(url.toString(), props); } - catch(Exception e){ + catch (Exception e){ LOG.log(Level.WARNING, "Failed to read properties from " + url, e); return null; }
