You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/15 17:26:24 UTC
[07/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
deleted file mode 100644
index de0b398..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model.spi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ModelTarget;
-import org.apache.tamaya.model.Validation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration section.
- */
-public class SectionModel extends GroupModel {
-
- /**
- * Creates a new builder.
- * @param owner owner, not null.
- * @param name the section name.
- * @return a new builder instance.
- */
- public static Builder builder(String owner, String name){
- return new Builder(owner, name);
- }
-
- /**
- * Creates a section validation for the given section.
- * @param owner owner, not null.
- * @param name the fully qualified section name
- * @param required flag, if the section is required to be present.
- * @return the ConfigModel instance
- */
- public static ConfigModel of(String owner, String name, boolean required){
- return new Builder(owner, name).setRequired(required).build();
- }
-
- /**
- * Creates a section validation for the given section.
- * @param owner owner, not null.
- * @param name the fully qualified section name
- * @param required flag, if the section is required to be present.
- * @param configModels additional configModels
- * @return a new builder, never null.
- */
- public static ConfigModel of(String owner, String name, boolean required, ConfigModel... configModels){
- return new Builder(owner, name).setRequired(required).addValidations(configModels).build();
- }
-
- /**
- * Internal constructor.
- * @param builder the builder, not null.
- */
- protected SectionModel(Builder builder) {
- super(builder.owner, builder.name, builder.childConfigModels);
- }
-
- @Override
- public ModelTarget getType(){
- return ModelTarget.Section;
- }
-
- @Override
- public Collection<Validation> validate(Configuration config) {
- Map<String,String> map = config.getProperties();
- String lookupKey = getName() + '.';
- boolean present = false;
- for(String key:map.keySet()){
- if(key.startsWith("_")){
- continue;
- }
- if(key.startsWith(lookupKey)){
- present = true;
- break;
- }
- }
- List<Validation> result = new ArrayList<>(1);
- if(isRequired() && !present) {
- result.add(Validation.ofMissing(this));
- }
- result.addAll(super.validate(config));
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append(getType()).append(": ").append(getName());
- if(isRequired()) {
- b.append(", required: " ).append(isRequired());
- }
- for(ConfigModel val:getValidations()){
- b.append(", ").append(val.toString());
- }
- return b.toString();
- }
-
- /**
- * Builder for setting up a AreaConfigModel instance.
- */
- public static class Builder{
- /** The section owner. */
- private String owner;
- /** The section name. */
- private String name;
- /** The optional description. */
- private String description;
- /** The required flag. */
- private boolean required;
- /** The (optional) custom validations.*/
- private final List<ConfigModel> childConfigModels = new ArrayList<>();
-
- /**
- * Creates a new Builder.
- * @param owner owner, not null.
- * @param sectionName the section name, not null.
- */
- public Builder(String owner, String sectionName){
- this.owner = Objects.requireNonNull(owner);
- this.name = Objects.requireNonNull(sectionName);
- }
-
- /**
- * Add configModels.
- * @param configModels the configModels, not null.
- * @return the Builder for chaining.
- */
- public Builder addValidations(ConfigModel... configModels){
- this.childConfigModels.addAll(Arrays.asList(configModels));
- return this;
- }
-
- /**
- * Add configModels.
- * @param configModels the configModels, not null.
- * @return the Builder for chaining.
- */
- public Builder addValidations(Collection<ConfigModel> configModels){
- this.childConfigModels.addAll(configModels);
- return this;
- }
-
- /**
- * Sets the required flag.
- * @param required zhe flag.
- * @return the Builder for chaining.
- */
- public Builder setRequired(boolean required){
- this.required = required;
- return this;
- }
-
- /**
- * Set the )optional) description.
- * @param description the description.
- * @return the Builder for chaining.
- */
- public Builder setDescription(String description){
- this.description = description;
- return this;
- }
-
- /**
- * Set the section name
- * @param name the section name, not null.
- * @return the Builder for chaining.
- */
- public Builder setName(String name){
- this.name = Objects.requireNonNull(name);
- return this;
- }
-
- /**
- * Build a new ConfigModel instance.
- * @return the new ConfigModel instance, not null.
- */
- public ConfigModel build(){
- return new SectionModel(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/configmodel.properties b/modules/model/src/main/resources/META-INF/configmodel.properties
deleted file mode 100644
index 3381a09..0000000
--- a/modules/model/src/main/resources/META-INF/configmodel.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# Contains definitions for default system property areas.
-_awt.model.target=Section
-_awt.model.transitive=true
-_file.model.target=Section
-_file.model.transitive=true
-_java.model.target=Section
-_java.model.transitive=true
-_line.model.target=Section
-_line.model.transitive=true
-_os.model.target=Section
-_os.model.transitive=true
-_path.model.target=Section
-_path.model.transitive=true
-_sun.model.target=Section
-_sun.model.transitive=true
-_user.model.target=Section
-_user.model.transitive=true
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index e8b12e9..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.ConfiguredTypeEventsModelPopulator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
deleted file mode 100644
index 05c3d02..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.ConfigDocumentationBean
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
deleted file mode 100644
index 92299da..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.DefaultConfigUsageStats
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
deleted file mode 100644
index b394c17..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.ConfiguredPropertiesModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredInlineModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredResourcesModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredTypeEventsModelProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
deleted file mode 100644
index 04cec4a..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.UsageTrackerFilter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java b/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
deleted file mode 100644
index d45376d..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model;
-
-import org.apache.tamaya.model.spi.SectionModel;
-import org.apache.tamaya.model.spi.ParameterModel;
-import org.apache.tamaya.model.spi.GroupModel;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Created by Anatole on 09.08.2015.
- */
-public class ConfigModelProviderTest implements ModelProviderSpi {
-
- private List<ConfigModel> configModels = new ArrayList<>(1);
-
- public ConfigModelProviderTest(){
- configModels.add(new TestConfigModel());
- configModels = Collections.unmodifiableList(configModels);
- }
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-
- private static final class TestConfigModel extends GroupModel {
-
- public TestConfigModel(){
- super("TestConfigModel", "TestConfig", new SectionModel.Builder("TestConfigModel",
- "a.test.existing").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.existing.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.existing.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"),
- new SectionModel.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*"));
- }
- @Override
- public String getName() {
- return "TestConfigConfigModel";
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java b/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
deleted file mode 100644
index 5059786..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.spi.GroupModel;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-import org.apache.tamaya.model.spi.ParameterModel;
-import org.apache.tamaya.model.spi.SectionModel;
-import org.junit.Test;
-import test.model.TestConfigAccessor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 09.08.2015.
- */
-public class ConfigUsageStatsTest implements ModelProviderSpi {
-
- private List<ConfigModel> configModels = new ArrayList<>(1);
-
- public ConfigUsageStatsTest(){
- configModels.add(new TestConfigModel());
- configModels = Collections.unmodifiableList(configModels);
- }
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-
- private static final class TestConfigModel extends GroupModel {
-
- public TestConfigModel(){
- super("TestConfigModel", "TestConfig", new SectionModel.Builder("TestConfigModel",
- "a.test.existing").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.existing.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.existing.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"),
- new SectionModel.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*"));
- }
- @Override
- public String getName() {
- return "TestConfigConfigModel";
- }
-
- }
-
- @Test
- public void testUsageWhenEnabled(){
- ConfigUsageStats.enableUsageTracking(true);
- TestConfigAccessor.readConfiguration();
- Configuration config = ConfigurationProvider.getConfiguration();
- String info = ConfigUsageStats.getUsageInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
- config = TestConfigAccessor.readConfiguration();
- config.getProperties();
- TestConfigAccessor.readProperty(config, "java.locale");
- TestConfigAccessor.readProperty(config, "java.version");
- TestConfigAccessor.readProperty(config, "java.version");
- config.get("java.version");
- info = ConfigUsageStats.getUsageInfo();
- System.out.println(info);
- assertTrue(info.contains("java.version"));
- assertNotNull(info);
- ConfigUsageStats.enableUsageTracking(false);
- }
-
- @Test
- public void testUsageWhenDisabled(){
- ConfigUsageStats.enableUsageTracking(false);
- ConfigUsageStats.clearUsageStats();
- TestConfigAccessor.readConfiguration();
- Configuration config = ConfigurationProvider.getConfiguration();
- String info = ConfigUsageStats.getUsageInfo();
- assertNotNull(info);
- assertFalse(info.contains("java.version"));
- config = TestConfigAccessor.readConfiguration();
- config.getProperties();
- TestConfigAccessor.readProperty(config, "java.locale");
- TestConfigAccessor.readProperty(config, "java.version");
- TestConfigAccessor.readProperty(config, "java.version");
- config.get("java.version");
- info = ConfigUsageStats.getUsageInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
- ConfigUsageStats.enableUsageTracking(false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java b/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
deleted file mode 100644
index de4f76f..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model;
-
-import org.junit.Test;
-
-/**
- * Created by Anatole on 10.08.2015.
- */
-public class ValidationTests {
-
- @Test
- public void testDefaults(){
- System.err.println(ConfigModelManager.validate());
- }
-
- @Test
- public void testAllValidations(){
- System.err.println(ConfigModelManager.getModels());
- }
-
- @Test
- public void testConfigInfo(){
- System.err.println(ConfigModelManager.getConfigInfoText());
- }
-
- @Test
- public void testAllValidationsInclUndefined(){
- System.err.println("Including UNDEFINED: \n" + ConfigModelManager.validate(true));
- }
-
- @Test
- public void testModels(){
- System.err.println("MODELS: " +ConfigModelManager.getModels());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java b/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
deleted file mode 100644
index e791417..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model.internal;
-
-import org.apache.tamaya.model.ModelTarget;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by Anatole on 19.08.2015.
- */
-public class ConfigDocumentationBeanTest {
-
- private final ConfigDocumentationBean mbean = new ConfigDocumentationBean();
-
- @Test
- public void testValidate_NoUnknowns() throws Exception {
- String results = mbean.validate(false);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"result\":\"MISSING\""));
- assertFalse(results.contains("\"description\":\"Undefined key: "));
- assertFalse(results.contains(" \"result\":\"UNDEFINED\""));
- }
-
- @Test
- public void testValidate_WithUnknowns() throws Exception {
- String results = mbean.validate(true);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- // test transitive excludes of default sys properties
- assertFalse(results.contains("\"name\":\"java"));
- assertFalse(results.contains("\"name\":\"sun."));
- assertFalse(results.contains("\"name\":\"file."));
- // test others
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- assertTrue(results.contains("\"result\":\"MISSING\""));
- assertTrue(results.contains("\"description\":\"Undefined key: "));
- assertTrue(results.contains(" \"result\":\"UNDEFINED\""));
- }
-
- @Test
- public void testGetConfigurationModel() throws Exception {
- String results = mbean.getConfigurationModel();
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"name\":\"MyNumber\""));
- assertTrue(results.contains("\"name\":\"a.b.c\""));
- assertTrue(results.contains("\"required\":true"));
- }
-
- @Test
- public void testGetConfigurationModel_WithSection() throws Exception {
- String results = mbean.getConfigurationModel(ModelTarget.Parameter);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertFalse(results.contains("\"target\":\"Section\""));
- assertTrue(results.contains("\"required\":true"));
- }
-
- @Test
- public void testFindConfigurationModels() throws Exception {
- String results = mbean.findConfigurationModels("a");
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertFalse(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- }
-
- @Test
- public void testFindValidationModels() throws Exception {
- String results = mbean.findValidationModels("a", ModelTarget.Section);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertFalse(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- System.out.println(results);
- }
-
- @Test
- public void testToString() throws Exception {
- String toString = mbean.toString();
- System.out.println(toString);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/test/model/TestConfigAccessor.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/test/model/TestConfigAccessor.java b/modules/model/src/test/java/test/model/TestConfigAccessor.java
deleted file mode 100644
index 498d2b6..0000000
--- a/modules/model/src/test/java/test/model/TestConfigAccessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package test.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.util.Map;
-
-/**
- * Created by atsticks on 30.04.16.
- */
-public final class TestConfigAccessor {
-
- private TestConfigAccessor(){}
-
- public static Map<String,String> readAllProperties(){
- return ConfigurationProvider.getConfiguration()
- .getProperties();
- }
-
- public static Configuration readConfiguration(){
- return ConfigurationProvider.getConfiguration();
- }
-
- public static String readProperty(Configuration config, String key){
- return config.get(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/configmodel.properties b/modules/model/src/test/resources/META-INF/configmodel.properties
deleted file mode 100644
index a7956dc..0000000
--- a/modules/model/src/test/resources/META-INF/configmodel.properties
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via properties.
-####################################################################################
-
-# Metamodel information
-_model.provider=ConfigModel Extension
-
-# reusable parameter definition, referenceable as MyNumber
-_MyNumber.model.target=Parameter
-_MyNumber.model.type=Integer
-_MyNumber.model.description=a (reusable) number type parameter (optional)
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-
-# a (section)
-_a.model.target=Section
-_a.params2.model.target=Parameter
-_a.params2.model.type=String
-_a.params2.model.required=true
-_a.params2.model.description=a required parameter
-
-_a.paramInt.model.target=Parameter
-_a.paramInt.model.type=ref:MyNumber
-_a.paramInt.model.description=an optional parameter (default)
-
-_a._number.model.target=Parameter
-_a._number.model.type=Integer
-_a._number.model.deprecated=true
-_a._number.model.mappedTo=a.paramInt
-
-# a.b.c (section)
-_a.b.c.model.target=Section
-_a.b.c.model.description=Just a test section
-
-# a.b.c.aRequiredSection (section)
-_a.b.c.aRequiredSection.model.target=Section
-_a.b.c.aRequiredSection.model.required=true
-_a.b.c.aRequiredSection.model.description=A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.model.target=Section
-
-_a.b.c.aRequiredSection.subsection.param0.model.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param0.type=String
-_a.b.c.aRequiredSection.subsection.param0.model.description=a minmally documented String parameter
-# A minmal String parameter
-_a.b.c.aRequiredSection.subsection.param00.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param00.model.type=String
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.param1.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param1.model.type = String
-_a.b.c.aRequiredSection.subsection.param1.model.required = true
-_a.b.c.aRequiredSection.subsection.intParam.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.intParam.model.type = Integer
-_a.b.c.aRequiredSection.subsection.intParam.model.description=an optional parameter (default)
-
-# a.b.c.aRequiredSection.nonempty-subsection (section)
-_a.b.c.aRequiredSection.nonempty-subsection.model.target=Section
-_a.b.c.aRequiredSection.nonempty-subsection.model.required=true
-
-# a.b.c.aRequiredSection.optional-subsection (section)
-_a.b.c.aRequiredSection.optional-subsection.model.target=Section
-
-# a.b.c.aValidatedSection (section)
-_a.b.c.aValidatedSection.model.target=Section
-_a.b.c.aValidatedSection.model.description=A validated section.
-_a.b.c.aValidatedSection.model.validator=org.apache.tamaya.model.TestValidator
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/javaconfiguration.properties b/modules/model/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index b0b8c22..0000000
--- a/modules/model/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-a.test.existing.aParam=existingValue
-a.test.existing.optionalParam=optionalValue
-a.test.existing.aABCParam=ABCparam
-a.test.existing.aABCParam2=MMM
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi b/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
deleted file mode 100644
index 9b29fda..0000000
--- a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.ConfigModelProviderTest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.ini
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.ini b/modules/model/src/test/resources/examples/configmodel.ini
deleted file mode 100644
index 0e10cc1..0000000
--- a/modules/model/src/test/resources/examples/configmodel.ini
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via ini(tm).
-####################################################################################
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-[_a.model]
-class = Section
-params2.type = String
-params2.required = true
-params2.description = "a required parameter"
-paramInt.ref = MyNumber
-paramInt.description = "an optional parameter (default)"
-_number.type = Integer
-_number.deprecated = true
-_number.mappedTo = "a.paramInt"
-
-[_a.b.c.model]
-class = Section
-description = Just a test section
-
-[_a.b.c.aRequiredSection.model]
-class = Section
-required = true
-description = A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-[_a.b.c.aRequiredSection.subsection.model]
-class = Section
-param0.type = String
-param0.description = "a minmally documented String parameter"
-# A minmal String parameter
-param00.type = String
-# description is optional
-param1.type = String
-param1.required = true
-intParam.type = Integer
-intParam.description = "an optional parameter (default)"
-
-[_a.b.c.aRequiredSection.nonempty-subsection.model]
-class = Section
-required = true
-
-[_a.b.c.aRequiredSection.optional-subsection.model]
-class = Section
-
-[_a.b.c.aValidatedSection.model]
-class = Section
-description = "A configModel section."
-configModels = org.apache.tamaya.model.TestValidator?max=3
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.json
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.json b/modules/model/src/test/resources/examples/configmodel.json
deleted file mode 100644
index 529f26e..0000000
--- a/modules/model/src/test/resources/examples/configmodel.json
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy current the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-//##################################################################################
-// Example of a configuration metamodel expressed via YAML(tm).
-// Structure is shown through indentation (one or more spaces).
-// Sequence items are denoted by a dash,
-// key value pairs within a map are separated by a colon.
-//##################################################################################
-
-//##################################################################################
-// Metamodel information
-//##################################################################################
-{
- "_model": {
- "provider": "ConfigModel Extension",
- // reusable parameter definition
- },
- "_MyNumber.model": {
- "class": "Parameter",
- "type": "Integer",
- "template": true,
- "description": "an (reusable) number type parameter (optional)"
- },
- //##################################################################################
- // Description of Configuration Sections (minimal, can be extended by other modules).
- //##################################################################################
- "_a.model": {
- "class": "Section",
- // required, default is parameter!
- },
- "_a.params2.model": {
- "required": true,
- "description": "a required parameter"
- },
- "_a.paramInt.model": {
- // references a shared parameter definition.
- "ref": "MyNumber",
- "description": "an optional parameter (default)"
- },
- "_a.number.model": {
- "type": "Integer",
- "deprecated": true,
- // references a deprecated parameter, now mapped to 'a.paramInt'.
- "mappedto": "a.paramInt"
- },
- "_a.b.c.model": {
- "class": "Section",
- "description": "Just a test section."
- // a subsection, directly configured as child element.
- },
- "_a.b.c.aRequiredSection.model": {
- "class": "Section",
- "required": true,
- "description": "A section containing required parameters is called a required section."
- },
- // a subsection, configured in its own section.
- "_a.b.c.aRequiredSection.subsection.model": {
- "class": "Section"
- }
- "_a.b.c.param0-model": {
- "type": "String",
- "description": "a minimally documented String parameter"
- },
- // A minimally defined String parameter
- "_a.b.c.param00": {},
- "_a.b.c.param1": {
- "type": "String",
- "required": true,
- "description": "a required parameter"
- },
- "_a.b.c.intParam": {
- "type": "Integer",
- "required": true,
- "description": "an optional parameter (default)"
- },
- "_a.b.c.aRequiredSection.nonempty-subsection.model": {
- "class": "Section",
- "required": true
- },
- "_a.b.c.aRequiredSection.optional-subsection.model": {
- "class": "Section"
- },
- "_a.b.c.aRequiredSection.aValidatedSection.model": {
- "class": "Section",
- "description": "A validated section.",
- "validations": "org.apache.tamaya.model.validation.MaxItemValidator?max=3"
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.properties b/modules/model/src/test/resources/examples/configmodel.properties
deleted file mode 100644
index b61695b..0000000
--- a/modules/model/src/test/resources/examples/configmodel.properties
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via properties.
-####################################################################################
-
-# Metamodel information
-_model.provider=ConfigModel Extension
-
-# reusable parameter definition, referenceable as MyNumber
-_MyNumber.model.class=Parameter
-_MyNumber.model.type=Integer
-_MyNumber.model.description=a (reusable) number type parameter (optional)
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-
-# a (section)
-_a.model.class=Section
-_a.params2.model.class=Parameter
-_a.params2.model.type=String
-_a.params2.model.required=true
-_a.params2.model.description=a required parameter
-
-_a.paramInt.model.class=Parameter
-_a.paramInt.model.type=ref:MyNumber
-_a.paramInt.model.description=an optional parameter (default)
-
-_a._number.model.class=Parameter
-_a._number.model.type=Integer
-_a._number.model.deprecated=true
-_a._number.model.mappedTo=a.paramInt
-
-# a.b.c (section)
-_a.b.c.class=Section
-_a.b.c.description=Just a test section
-
-# a.b.c.aRequiredSection (section)
-_a.b.c.aRequiredSection.model.class=Section
-_a.b.c.aRequiredSection.model.required=true
-_a.b.c.aRequiredSection.model.description=A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.model.subsection.class=Section
-
-_a.b.c.aRequiredSection.subsection.param0.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param0.model.type=String
-_a.b.c.aRequiredSection.subsection.param0.model.description=a minmally documented String parameter
-# A minmal String parameter
-_a.b.c.aRequiredSection.subsection.param00.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param00.model.type=String
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.param1.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param1.model.type = String
-_a.b.c.aRequiredSection.subsection.param1.model.required = true
-_a.b.c.aRequiredSection.subsection.intParam.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.intParam.model.type = Integer
-_a.b.c.aRequiredSection.subsection.intParam.model.description=an optional parameter (default)
-
-# a.b.c.aRequiredSection.nonempty-subsection (section)
-_a.b.c.aRequiredSection.nonempty-subsection.model.class=Section
-_a.b.c.aRequiredSection.nonempty-subsection.model.required=true
-
-# a.b.c.aRequiredSection.optional-subsection (section)
-_a.b.c.aRequiredSection.optional-subsection.model.class=Section
-
-# a.b.c.aValidatedSection (section)
-_a.b.c.aValidatedSection.model.class=Section
-_a.b.c.aValidatedSection.model.description=A validated section.
-_a.b.c.aValidatedSection.model.configModels=org.apache.tamaya.model.TestValidator
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.xml
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.xml b/modules/model/src/test/resources/examples/configmodel.xml
deleted file mode 100644
index f23f783..0000000
--- a/modules/model/src/test/resources/examples/configmodel.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<!--################################################################################
-# Example of a configuration metamodel expressed via YAML(tm).
-# Structure is shown through indentation (one or more spaces).
-# Sequence items are denoted by a dash,
-# key value pairs within a map are separated by a colon.
-#################################################################################-->
-
-<!--################################################################################
-# Metamodel information
-#################################################################################-->
-
-<configuration>
- <section name="{model}" __provider="ConfigModel Extension" version="1.0" __release-date="2001-01-23"
- author="Anatole Tresch">
- <!-- model-format>alternate format reader type</model-format -->
- <__description>Late afternoon is best.
- Backup contact is Nancy.
- </__description>
-
- <!--################################################################################
- # Description of Configuration Sections (minimal, can be extended by other modules).
- #################################################################################-->
- <section name="a">
- <param name="params">
- <type>String</type>
- <required>true</required>
- <description>a required parameter</description>
- </param>
- <param name="paramInt">
- <ref>MyNumber</ref>
- <required>true</required>
- <description>an optional parameter (default)</description>
- </param>
- <param name="_number">
- <type>Integer</type>
- <deprecated>true</deprecated>
- <mappedto>a.paramInt</mappedto>
- </param>
- <section name="b.c">
- <description>Just a test section.</description>
- <section name="aRequiredSection">
- <description>A section containing required parameters is called a required section.
- Sections can also explicitly be defined to be required, but without
- specifying the paramteres to be contained.
- </description>
- </section>
- </section>
- </section>
-
- <section name="a.b.c.aRequiredSection.subsection">
- <param name="param0" type="String">a minmally documented String parameter</param>
- <!-- # A minmally defined String parameter -->
- <param name="param00">
- <type>String</type>
- </param>
- <param name="param1">
- <type>String</type>
- <required>true</required>
- <description>a required parameter</description>description>
- </param>
- <param name="intParam">
- <type>Integer</type>
- <description>an optional parameter (default)</description>
- </param>
- <section name="b.c">
- <description>Just a test section.</description>
- </section>
- </section>
- <section name="a.b.c.aRequiredSection.nonempty-subsection">
- <required>true</required>
- </section>
- <section name="a.b.c.aRequiredSection.optional-subsection"/>
- <section name="a.b.c.aRequiredSection.aValidatedSection">
- <configModels>org.apache.tamaya.model.configModel.MaxItemValidator?max=3"</configModels>
- <description>A configModel section.</description>
- </section>
- </section>
-</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.yaml
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.yaml b/modules/model/src/test/resources/examples/configmodel.yaml
deleted file mode 100644
index 041c801..0000000
--- a/modules/model/src/test/resources/examples/configmodel.yaml
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-##################################################################################
-# Example of a configuration metamodel expressed via YAML(tm).
-# Structure is shown through indentation (one or more spaces).
-# Sequence items are denoted by a dash,
-# key value pairs within a map are separated by a colon.
-####################################################################################
-
-####################################################################################
-# Metamodel information
-####################################################################################
-{model}: {
- __name : 'testmodel',
- __provider : 'ValidationProviderSpi Extension',
- __version : '1.0',
- __release-date : 2001-01-23,
- __author : 'Anatole Tresch',
- # model-format: 'alternate format reader type'
- __description: >
- Late afternoon is best.
- Backup contact is Nancy.
-}
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-####################################################################################
----
-{model}.a.params2: {
- type : 'String',
- required : true,
- description : 'a required parameter',
- paramInt: 'Integer', 'an optional parameter (default)',
-}
----
-{model}.a.paramInt: {
- type : 'Integer',
- description : 'an optional parameter (default)',
-}
----
-{model}.a.b.c: {
- description: 'Just a test section.'
-}
----
-{model}.a.b.c.aRequiredSection: {
- required: true,
- description: |
- A section containing required parameters is called a required section.
- Sections can also explicitly be defined to be required, but without
- specifying the paramteres to be contained.,
-}
----
-{model}.a.b.c.aRequiredSection.subsection: {
- param0: {
- type: 'String',
- description: 'a minmally documented String parameter}'
- }, ,
- param00:{
- type: 'String' # A minmally defined String parameter
- },
- param1: {
- tpye: 'String',
- required: true,
- description: 'a required parameter'
- },
- intParam: {
- type: 'Integer',
- description: 'an optional parameter (default)'
- }
-}
-...
-
----
-{model}.a.b.c.aRequiredSection.nonempty-subsection: {
- required: true
-}
-...
-
----
-{model}.a.b.c.aRequiredSection.optional-subsection: {}
-...
-
----
-{model}.a.b.c.aRequiredSection.aValidatedSection: {
- description: 'A configModel section.',
- configModels: 'org.apache.tamaya.model.configModel.MaxItemValidator?max=3'
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mutable-config/pom.xml b/modules/mutable-config/pom.xml
deleted file mode 100644
index 8f0204d..0000000
--- a/modules/mutable-config/pom.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy current the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-mutable-config</artifactId>
- <name>Apache Tamaya Modules - Mutable Configuration Support</name>
- <description>This module provides abstraction, if your scenario needs to actively change configuration entries
- and write changes back to some property sources, files etc.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.mutableconfig
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
deleted file mode 100644
index 5378166..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.Collection;
-
-/**
- * Policy that defines how changes are applied to the available
- * {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances, e.g.
- * <ul>
- * <li><b>ALL: </b>Changes are propagated to all {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource}
- * instances in order of significance. This means that a key added, updated or removed in each instance, if the key
- * is writable/removable.</li>
- * <li><b>SIGNIFICANT_ONLY: </b>A change (creation, update) is only applied, if
- * <ol>
- * <li>the value is not provided by a more significant read-only property source.</li>
- * <li>there is no more significant writable property source, which supports writing a g iven key.</li>
- * </ol>
- * In other words a added or updated value is written exactly once to the most significant
- * writable property source, which accepts a given key. Otherwise the change is discarded.</li>
- * <li><b>NONE: </b>Do not apply any changes.</li>
- * </ul>
- */
-public interface ChangePropagationPolicy {
-
- /**
- * Method being called when a multiple key/value pairs are added or updated.
- * @param propertySources the property sources, including readable property sources of the current configuration,
- * never null.
- * @param configChange the configuration change, not null.
- */
- void applyChange(ConfigChangeRequest configChange, Collection<PropertySource> propertySources);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
deleted file mode 100644
index 451769e..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-
-import java.util.Collection;
-import java.util.Map;
-
-
-/**
- * This interface extends the Configuration interface hereby adding methods to change configuration entries.
- * Hereby not all configuration entries are necessarily mutable, since some entries may be read from non
- * mutable areas of configuration. Of course, it is always possible to add a mutable shadow layer on top of all
- * property sources to persist/control any changes applied. The exact management and storage persistence algorithm
- * should be transparent.
- *
- * As a consequence clients should first check, using the corresponding methods, if entries can be added/updated or
- * removed.
- *
- * This class should only used in a single threaded context, though all methods inherited from {@link Configuration}
- * must be thread-safe. Methods handling configuration changes are expected to be used in a single threaded environment
- * only. For multi-threaded us create a new instance of {@link MutableConfiguration} for each thread.
- */
-public interface MutableConfiguration extends Configuration {
-
- /**
- * Storesd the changes. After a commit the change is not editable anymore. All changes applied will be written to
- * the corresponding configuration backend.
- *
- * NOTE that changes applied must not necessarily be visible in the current {@link Configuration} instance,
- * since visibility of changes also depends on the ordinals set on the {@link org.apache.tamaya.spi.PropertySource}s
- * configured.
- * @throws org.apache.tamaya.ConfigException if the request already has been committed or cancelled, or the commit fails.
- */
- void store();
-
- /**
- * Access the current configuration change context, built up on all the change context of the participating
- * {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances.
- * @return the colleted changes as one single config change for the current transaction, or null, if no transaction
- * is active.
- */
- ConfigChangeRequest getConfigChangeRequest();
-
- /**
- * Access the active {@link ChangePropagationPolicy}.This policy controls how configuration changes are written/published
- * to the known {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances of a {@link Configuration}.
- * @return he active {@link ChangePropagationPolicy}, never null.
- */
- ChangePropagationPolicy getChangePropagationPolicy();
-
- /**
- * Sets a property.
- *
- * @param key the property's key, not null.
- * @param value the property's value, not null.
- * @return the former property value, or null.
- * @throws org.apache.tamaya.ConfigException if the key/value cannot be added, or the request is read-only.
- */
- MutableConfiguration put(String key, String value);
-
- /**
- * Puts all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isWritable. If any of the passed keys is not writable during this initial
- * check, the operation should not perform any configuration changes and throw a
- * {@link org.apache.tamaya.ConfigException}. If errors occur afterwards, when the properties are effectively
- * written back to the backends, the errors should be collected and returned as part of the ConfigException
- * payload. Nevertheless the operation should in that case remove all entries as far as possible and abort the
- * writing operation.
- *
- * @param properties the properties tobe written, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given properties could not be written, or the request
- * is read-only.
- */
- MutableConfiguration putAll(Map<String, String> properties);
-
- /**
- * Removes all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
- * check, the operation should not perform any configuration changes and throw a
- * {@link org.apache.tamaya.ConfigException}. If errors
- * occur afterwards, when the properties are effectively written back to the backends, the errors should be
- * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
- * remove all entries as far as possible and abort the writing operation.
- *
- * @param keys the property's keys to be removedProperties, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given keys could not be removedProperties, or the
- * request is read-only.
- */
- MutableConfiguration remove(Collection<String> keys);
-
- /**
- * Removes all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
- * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
- * occur afterwards, when the properties are effectively written back to the backends, the errors should be
- * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
- * remove all entries as far as possible and abort the writing operation.
- *
- * @param keys the property's keys to be removedProperties, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given keys could not be removedProperties, or the request is read-only.
- */
- MutableConfiguration remove(String... keys);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
deleted file mode 100644
index c2cd20e..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Logger;
-
-
-/**
- * Accessor for creating {@link MutableConfiguration} instances to change configuration and commit changes.
- */
-public final class MutableConfigurationProvider {
-
- private static final Logger LOG = Logger.getLogger(MutableConfigurationProvider.class.getName());
- /**
- * URIs used by this query instance to identify the backends to use for write operations.
- */
- private static MutableConfigurationProviderSpi mutableConfigurationProviderSpi = loadSpi();
-
- /**
- * SPI loader method.
- * @throws ConfigException if loading fails.
- * @return the SPI, never null.
- */
- private static MutableConfigurationProviderSpi loadSpi() {
- try{
- return ServiceContextManager.getServiceContext().getService(
- MutableConfigurationProviderSpi.class) ;
- } catch(Exception e){
- throw new ConfigException("Failed to initialize MutableConfigurationProviderSpi - " +
- "mutable configuration support.");
- }
- }
-
-
- /** Singleton constructor. */
- private MutableConfigurationProvider(){}
-
- /**
- * Creates a new {@link MutableConfiguration} for the given default configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code autoCommit = false}.
- *
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(){
- return mutableConfigurationProviderSpi.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(), getApplyMostSignificantOnlyChangePolicy());
- }
-
- /**
- * Creates a new {@link MutableConfiguration} for the given default configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code autoCommit = false}.
- * @param changePropgationPolicy policy that defines how a change is written back and which property
- * sources are finally eligible for a write operation.
- * @return a new MutableConfiguration instance, with the given change policy active.
- */
- public static MutableConfiguration createMutableConfiguration(ChangePropagationPolicy changePropgationPolicy){
- return mutableConfigurationProviderSpi.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(), changePropgationPolicy);
- }
-
-
- /**
- * Creates a new {@link MutableConfiguration} for the given configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code MOST_SIGNIFICANT_ONLY_POLICY}
- * configuration writing policy.
- *
- * @param configuration the configuration to use to write the changes/config.
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(Configuration configuration){
- return createMutableConfiguration(configuration, MOST_SIGNIFICANT_ONLY_POLICY);
- }
-
- /**
- * Creates a new {@link MutableConfiguration} for the given configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code ALL_POLICY}
- * configuration writing policy.
- *
- * @param configuration the configuration to use to write the changes/config.
- * @param changePropagationPolicy the configuration writing policy.
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(Configuration configuration, ChangePropagationPolicy changePropagationPolicy){
- return mutableConfigurationProviderSpi.createMutableConfiguration(configuration, changePropagationPolicy);
- }
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- * This is also the default policy.
- * @return default all policy.
- */
- public static ChangePropagationPolicy getApplyAllChangePolicy(){
- return ALL_POLICY;
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplyMostSignificantOnlyChangePolicy(){
- return MOST_SIGNIFICANT_ONLY_POLICY;
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @param propertySourceNames the names of the mutable property sources to be considered for writing any changes to.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplySelectiveChangePolicy(String... propertySourceNames){
- return new SelectiveChangeApplyPolicy(propertySourceNames);
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplyNonePolicy(){
- return NONE_POLICY;
- }
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- */
- private static final ChangePropagationPolicy ALL_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- MutablePropertySource target = (MutablePropertySource)propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- }
- }
- }
-
- };
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- */
- private static final ChangePropagationPolicy MOST_SIGNIFICANT_ONLY_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- MutablePropertySource target = (MutablePropertySource)propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- break;
- }
- }
- }
-
- };
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- */
- private static final ChangePropagationPolicy NONE_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- LOG.warning("Cannot store changes '"+change+"': prohibited by change policy (read-only).");
- }
- };
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- */
- private static final class SelectiveChangeApplyPolicy implements ChangePropagationPolicy {
-
- private Set<String> propertySourceNames = new HashSet<>();
-
- SelectiveChangeApplyPolicy(String... propertySourceNames){
- this.propertySourceNames.addAll(Arrays.asList(propertySourceNames));
- }
-
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- if(this.propertySourceNames.contains(propertySource.getName())) {
- MutablePropertySource target = (MutablePropertySource) propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- break;
- }
- }
- }
- }
- };
-
-
-}