You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2020/04/14 16:50:45 UTC
[felix-dev] branch master updated: Improve configuration for reader
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 49b614c Improve configuration for reader
49b614c is described below
commit 49b614c626dfa34e62dc29c6f5cdb1246811326d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Apr 14 18:50:28 2020 +0200
Improve configuration for reader
---
.../src/main/java/org/apache/felix/cm/json/ConfigurationReader.java | 3 ++-
.../java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java | 4 ++--
.../org/apache/felix/cm/json/impl/ConfigurationReaderImplTest.java | 2 +-
.../main/java/org/apache/felix/configurator/impl/Configurator.java | 2 +-
.../main/java/org/apache/felix/configurator/impl/json/JSONUtil.java | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/cm.json/src/main/java/org/apache/felix/cm/json/ConfigurationReader.java b/cm.json/src/main/java/org/apache/felix/cm/json/ConfigurationReader.java
index 7bf5b96..c75a683 100644
--- a/cm.json/src/main/java/org/apache/felix/cm/json/ConfigurationReader.java
+++ b/cm.json/src/main/java/org/apache/felix/cm/json/ConfigurationReader.java
@@ -73,9 +73,10 @@ public interface ConfigurationReader {
* By default a configuration resource is not treated as a bundle resource.
* Additional rules apply for a resource outside of a bundle.
*
+ * @param flag Enable or disable verification as bundle resource
* @return This builder
*/
- Builder verifyAsBundleResource();
+ Builder verifyAsBundleResource(boolean flag);
/**
* Set an identifier. If set all ignored error messages and most exceptions will
diff --git a/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java b/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
index b3b73b2..467290f 100644
--- a/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
+++ b/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
@@ -55,8 +55,8 @@ public class ConfigurationReaderImpl
private ConfiguratorPropertyHandler propertyHandler;
@Override
- public Builder verifyAsBundleResource() {
- this.verifyAsBundleResource = true;
+ public Builder verifyAsBundleResource(final boolean flag) {
+ this.verifyAsBundleResource = flag;
return this;
}
diff --git a/cm.json/src/test/java/org/apache/felix/cm/json/impl/ConfigurationReaderImplTest.java b/cm.json/src/test/java/org/apache/felix/cm/json/impl/ConfigurationReaderImplTest.java
index 606db74..75efcb4 100644
--- a/cm.json/src/test/java/org/apache/felix/cm/json/impl/ConfigurationReaderImplTest.java
+++ b/cm.json/src/test/java/org/apache/felix/cm/json/impl/ConfigurationReaderImplTest.java
@@ -77,7 +77,7 @@ public class ConfigurationReaderImplTest {
@Test
public void testReadBundleConfigurationResource() throws IOException {
final ConfigurationReaderImpl cfgReader = new ConfigurationReaderImpl();
- cfgReader.verifyAsBundleResource();
+ cfgReader.verifyAsBundleResource(true);
final Map<String, Hashtable<String, Object>> configs;
try (final InputStream jsonStream = this.getClass().getResourceAsStream("/configs/bundle.json");
final Reader jsonReader = new InputStreamReader(jsonStream, StandardCharsets.UTF_8)) {
diff --git a/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java b/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
index 9936d11..b7bab7c 100644
--- a/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
+++ b/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
@@ -258,7 +258,7 @@ public class Configurator {
final BinaryManager converter = new BinaryManager(null, report);
final List<ConfigurationFile> allFiles = new ArrayList<>();
for(final Map.Entry<String, String> entry : files.entrySet()) {
- final ConfigurationFile file = org.apache.felix.configurator.impl.json.JSONUtil.readJSON(converter, entry.getKey(), null, -1, entry.getValue(), report);
+ final ConfigurationFile file = JSONUtil.readJSON(converter, entry.getKey(), null, -1, entry.getValue(), report);
if ( file != null ) {
allFiles.add(file);
}
diff --git a/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java b/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
index d415b87..b3b7fe7 100644
--- a/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
+++ b/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
@@ -152,7 +152,7 @@ public class JSONUtil {
final Map<String, ConfigPolicy> policyMap = new HashMap<>();
final ConfigurationReader cfgReader = Configurations.buildReader()
- .verifyAsBundleResource()
+ .verifyAsBundleResource(url != null)
.withIdentifier(identifier)
.withBinaryHandler( binaryManager )
.withConfiguratorPropertyHandler( (pid, key, value) -> {