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/16 22:03:17 UTC
[07/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-156:
Implemented usage tracking.
TAMAYA-156: Implemented usage tracking.
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/5a22c680
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/5a22c680
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/5a22c680
Branch: refs/heads/master
Commit: 5a22c6805674a52a34639967d362fd73e5839bd5
Parents: f1ea158
Author: anatole <an...@apache.org>
Authored: Sat Apr 30 18:40:29 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Sat Apr 30 18:40:58 2016 +0200
----------------------------------------------------------------------
.../org/apache/tamaya/model/ConfigModel.java | 12 +-
.../apache/tamaya/model/ConfigModelManager.java | 107 ++++++----
.../org/apache/tamaya/model/ModelTarget.java | 37 ++++
.../java/org/apache/tamaya/model/ModelType.java | 49 -----
.../org/apache/tamaya/model/Validation.java | 202 ++++++++++++++++++
.../apache/tamaya/model/ValidationResult.java | 182 ++---------------
.../apache/tamaya/model/ValidationState.java | 59 ------
.../model/internal/ConfigDocumentationBean.java | 22 +-
.../ConfiguredPropertiesModelProviderSpi.java | 5 +-
.../tamaya/model/spi/AbstractConfigModel.java | 82 ++++++++
.../apache/tamaya/model/spi/AbstractModel.java | 89 --------
.../tamaya/model/spi/AreaConfigModel.java | 204 -------------------
.../model/spi/ConfigDocumentationMBean.java | 8 +-
.../tamaya/model/spi/ConfigModelGroup.java | 110 ----------
.../tamaya/model/spi/ConfigModelReader.java | 61 +++---
.../org/apache/tamaya/model/spi/GroupModel.java | 103 ++++++++++
.../apache/tamaya/model/spi/ParameterModel.java | 32 +--
.../apache/tamaya/model/spi/SectionModel.java | 192 +++++++++++++++++
.../tamaya/model/TestConfigModelProvider.java | 38 +++-
.../internal/ConfigDocumentationBeanTest.java | 10 +-
20 files changed, 798 insertions(+), 806 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ConfigModel.java b/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
index d03e691..77c3fb0 100644
--- a/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
+++ b/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
@@ -31,7 +31,7 @@ public interface ConfigModel {
* Get the type of item that is modelled.
* @return the modelled type, never null.
*/
- ModelType getType();
+ ModelTarget getType();
/**
* Get the item's name, it should minimally describe the validation. Examples are:
@@ -53,12 +53,6 @@ public interface ConfigModel {
boolean isRequired();
/**
- * Get the provider of this validation.
- * @return the provider.
- */
- String getProvider();
-
- /**
* Get an description of the item, using the default locale. The description is basically optional
* though it is higly recommended to provide a description, so the validation issues is well
* resolvable.
@@ -71,8 +65,8 @@ public interface ConfigModel {
* Validates the item and all its children against the given configuration.
*
* @param config the configuration to be validated against, not null.
- * @return the validation results, never null.
+ * @return the validation result, or null, if not applicable.
*/
- Collection<ValidationResult> validate(Configuration config);
+ Collection<Validation> validate(Configuration config);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java b/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
index 03e6361..d0a5a01 100644
--- a/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
+++ b/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
@@ -22,20 +22,14 @@ import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.model.spi.ConfigDocumentationMBean;
import org.apache.tamaya.model.spi.ModelProviderSpi;
+import org.apache.tamaya.model.spi.UsageTrackerSpi;
import org.apache.tamaya.spi.ServiceContextManager;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -47,6 +41,9 @@ public final class ConfigModelManager {
/** The logger used. */
private final static Logger LOG = Logger.getLogger(ConfigModelManager.class.getName());
+ private static UsageTrackerSpi usageTracker = ServiceContextManager
+ .getServiceContext().getService(UsageTrackerSpi.class);
+
/**
* Singleton constructor.
*/
@@ -54,36 +51,47 @@ public final class ConfigModelManager {
}
/**
- * Get the validations defined.
- *
- * @return the sections defined, never null.
+ * Access the usage statistics for the recorded uses of configuration.
*/
- public static Collection<ConfigModel> getModels() {
- List<ConfigModel> result = new ArrayList<>();
- for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
- result.addAll(model.getConfigModels());
+ public static String getUsageInfo(){
+ return Objects.requireNonNull(usageTracker, "No UsageTrackerSpi component available.").getUsageInfo();
+ }
+
+ /**
+ * Access the usage statistics for the recorded uses of configuration.
+ */
+ public static String getConfigInfoText(){
+ StringBuilder b = new StringBuilder();
+ List<ConfigModel> models = new ArrayList<>(getModels());
+ Collections.sort(models, new Comparator<ConfigModel>() {
+ @Override
+ public int compare(ConfigModel k1, ConfigModel k2) {
+ return k2.getName().compareTo(k2.getName());
+ }
+ });
+ for(ConfigModel model:models){
+ b.append(model.getName()).append('(').append(model.getType())
+ .append("):\n ").append(
+ model.getDescription()).append("mandatory=").append(model.isRequired());
+ b.append('\n');
}
- return result;
+ return b.toString();
}
/**
- * Find the validations by checking the validation's name using the given regular expression.
- * @param type the target ModelType, not null.
- * @param namePattern the regular expression to use, not null.
+ * Get the validations defined.
+ *
* @return the sections defined, never null.
*/
- public static Collection<ConfigModel> findModels(ModelType type, String namePattern) {
+ public static Collection<ConfigModel> getModels() {
List<ConfigModel> result = new ArrayList<>();
for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
- for(ConfigModel configModel : model.getConfigModels()) {
- if(configModel.getName().matches(namePattern) && configModel.getType()==type) {
- result.add(configModel);
- }
- }
+ result.addAll(model.getConfigModels());
}
return result;
}
+
/**
* Find the validations by matching the validation's name against the given model type.
*
@@ -106,14 +114,24 @@ public final class ConfigModelManager {
/**
* Find the validations by checking the validation's name using the given regular expression.
* @param namePattern the regular expression to use, not null.
+ * @param targets the target types only to be returned (optional).
* @return the sections defined, never null.
*/
- public static Collection<ConfigModel> findModels(String namePattern) {
+ public static Collection<ConfigModel> findModels(String namePattern, ModelTarget... targets) {
List<ConfigModel> result = new ArrayList<>();
for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
for(ConfigModel configModel : model.getConfigModels()) {
if(configModel.getName().matches(namePattern)) {
- result.add(configModel);
+ if(targets.length>0){
+ for(ModelTarget tgt:targets){
+ if(configModel.getType().equals(tgt)){
+ result.add(configModel);
+ break;
+ }
+ }
+ }else {
+ result.add(configModel);
+ }
}
}
}
@@ -125,7 +143,7 @@ public final class ConfigModelManager {
*
* @return the validation results, never null.
*/
- public static Collection<ValidationResult> validate() {
+ public static Collection<Validation> validate() {
return validate(false);
}
@@ -134,7 +152,7 @@ public final class ConfigModelManager {
* @param showUndefined show any unknown parameters.
* @return the validation results, never null.
*/
- public static Collection<ValidationResult> validate(boolean showUndefined) {
+ public static Collection<Validation> validate(boolean showUndefined) {
return validate(ConfigurationProvider.getConfiguration(), showUndefined);
}
@@ -144,7 +162,7 @@ public final class ConfigModelManager {
* @param config the configuration to be validated against, not null.
* @return the validation results, never null.
*/
- public static Collection<ValidationResult> validate(Configuration config) {
+ public static Collection<Validation> validate(Configuration config) {
return validate(config, false);
}
@@ -155,8 +173,8 @@ public final class ConfigModelManager {
* @param showUndefined allows filtering for undefined configuration elements.
* @return the validation results, never null.
*/
- public static Collection<ValidationResult> validate(Configuration config, boolean showUndefined) {
- List<ValidationResult> result = new ArrayList<>();
+ public static Collection<Validation> validate(Configuration config, boolean showUndefined) {
+ List<Validation> result = new ArrayList<>();
for (ConfigModel defConf : getModels()) {
result.addAll(defConf.validate(config));
}
@@ -164,7 +182,7 @@ public final class ConfigModelManager {
Map<String,String> map = new HashMap<>(config.getProperties());
Set<String> areas = extractTransitiveAreas(map.keySet());
for (ConfigModel defConf : getModels()) {
- if(ModelType.Section.equals(defConf.getType())){
+ if(ModelTarget.Section.equals(defConf.getType())){
for (Iterator<String> iter = areas.iterator();iter.hasNext();){
String area = iter.next();
if(area.matches(defConf.getName())){
@@ -172,28 +190,36 @@ public final class ConfigModelManager {
}
}
}
- if(ModelType.Parameter.equals(defConf.getType())){
+ if(ModelTarget.Parameter.equals(defConf.getType())){
map.remove(defConf.getName());
}
}
outer:for(Map.Entry<String,String> entry:map.entrySet()){
for (ConfigModel defConf : getModels()) {
- if(ModelType.Section.equals(defConf.getType())){
+ if(ModelTarget.Section.equals(defConf.getType())){
if(defConf.getName().endsWith(".*") && entry.getKey().matches(defConf.getName())){
// Ignore parameters that are part of transitive section.
continue outer;
}
}
}
- result.add(ValidationResult.ofUndefined(entry.getKey(), ModelType.Parameter, null));
+ result.add(Validation.ofUndefined(entry.getKey(), ModelTarget.Parameter));
}
for(String area:areas){
- result.add(ValidationResult.ofUndefined(area, ModelType.Section, null));
+ result.add(Validation.ofUndefined(area, ModelTarget.Section));
}
}
return result;
}
+ /**
+ * Get the list of package, which are not evaluated for tracking configuration access and usage statistics.
+ * @return the set of ignored package names.
+ */
+ public static Set<String> getIgnoredPackages(){
+ return usageTracker.getIgnoredPackages();
+ }
+
private static java.util.Set<java.lang.String> extractTransitiveAreas(Set<String> keys) {
Set<String> transitiveClosure = new HashSet<>();
for(String key:keys){
@@ -242,4 +268,11 @@ public final class ConfigModelManager {
}
}
+ /**
+ * Get the recorded usage references of configuration.
+ * @return the recorded usge references, never null.
+ */
+ public static Collection<Usage> getUsages() {
+ return usageTracker.getUsages();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ModelTarget.java b/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
new file mode 100644
index 0000000..a8b687b
--- /dev/null
+++ b/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * This enumeration defines the types of supported validations.
+ */
+public enum ModelTarget {
+ /**
+ * A configuration section.
+ */
+ Section,
+ /**
+ * A configuration paramter.
+ */
+ Parameter,
+ /**
+ * ConfigModel that is a container of other validations.
+ */
+ Group,
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ModelType.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ModelType.java b/model/src/main/java/org/apache/tamaya/model/ModelType.java
deleted file mode 100644
index aaf22f7..0000000
--- a/model/src/main/java/org/apache/tamaya/model/ModelType.java
+++ /dev/null
@@ -1,49 +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;
-
-/**
- * This enumeration defines the types of supported validations.
- */
-public enum ModelType {
- /**
- * A configuration section.
- */
- Section,
- /**
- * A configuration paramter.
- */
- Parameter,
- /**
- * ConfigModel to ensure a certain configuration filter is installed.
- */
- Filter,
- /**
- * ConfigModel to ensure a certain combination policy is active.
- */
- CombinationPolicy,
- /**
- * ConfigModel that is a container of other validations.
- */
- Group,
- /**
- * ConfigModel to simply check availability for a class on the current classpath.
- */
- LoadableClass
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/Validation.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/Validation.java b/model/src/main/java/org/apache/tamaya/model/Validation.java
new file mode 100644
index 0000000..1bcaf9f
--- /dev/null
+++ b/model/src/main/java/org/apache/tamaya/model/Validation.java
@@ -0,0 +1,202 @@
+/*
+ * 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.model.spi.AbstractConfigModel;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+
+/**
+ * Models a partial configuration configModel result.
+ */
+public final class Validation {
+ /**
+ * the config section.
+ */
+ private final ConfigModel configModel;
+ /**
+ * The configModel result.
+ */
+ private final ValidationResult result;
+ /**
+ * The configModel message.
+ */
+ private final String message;
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @return a new validation result containing valid parts of the given model.
+ */
+ public static Validation ofValid(ConfigModel configModel) {
+ return new Validation(configModel, ValidationResult.VALID, null);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @return a new validation result containing missing parts of the given model.
+ */
+ public static Validation ofMissing(ConfigModel configModel) {
+ return new Validation(configModel, ValidationResult.MISSING, null);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @param message Additional message to be shown (optional).
+ * @return a new validation result containing missing parts of the given model with a message.
+ */
+ public static Validation ofMissing(ConfigModel configModel, String message) {
+ return new Validation(configModel, ValidationResult.MISSING, message);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @param error error message to add.
+ * @return a new validation result containing erroneous parts of the given model with the given error message.
+ */
+ public static Validation ofError(ConfigModel configModel, String error) {
+ return new Validation(configModel, ValidationResult.ERROR, error);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @param warning warning message to add.
+ * @return a new validation result containing warning parts of the given model with the given warning message.
+ */
+ public static Validation ofWarning(ConfigModel configModel, String warning) {
+ return new Validation(configModel, ValidationResult.WARNING, warning);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @param alternativeUsage allows setting a message to indicate non-deprecated replacement, maybe null.
+ * @return a new validation result containing deprecated parts of the given model with an optional message.
+ */
+ public static Validation ofDeprecated(ConfigModel configModel, String alternativeUsage) {
+ return new Validation(configModel, ValidationResult.DEPRECATED, alternativeUsage != null ? "Use instead: " + alternativeUsage : null);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param configModel the configModel item, not null.
+ * @return a new validation result containing deprecated parts of the given model.
+ */
+ public static Validation ofDeprecated(ConfigModel configModel) {
+ return new Validation(configModel, ValidationResult.DEPRECATED, null);
+ }
+
+ /**
+ * Creates a new ValidationResult.
+ *
+ * @param key the name/model key
+ * @param type model type
+ * @return a corresponding configModel item
+ */
+ public static Validation ofUndefined(final String key, final ModelTarget type) {
+ return new Validation(new AbstractConfigModel(key, false, "Undefined key: " + key) {
+
+ @Override
+ public ModelTarget getType() {
+ return type;
+ }
+
+ @Override
+ public Collection<Validation> validate(Configuration config) {
+ return Collections.emptyList();
+ }
+ }, ValidationResult.UNDEFINED, null);
+ }
+
+
+ /**
+ * Constructor.
+ *
+ * @param configModel the configModel item, not null.
+ * @param result the configModel result, not null.
+ * @param message the detail message.
+ * @return new validation result.
+ */
+ public static Validation of(ConfigModel configModel, ValidationResult result, String message) {
+ return new Validation(configModel, result, message);
+ }
+
+
+ /**
+ * Constructor.
+ *
+ * @param configModel the configModel item, not null.
+ * @param result the configModel result, not null.
+ * @param message the detail message.
+ */
+ private Validation(ConfigModel configModel, ValidationResult result, String message) {
+ this.message = message;
+ this.configModel = Objects.requireNonNull(configModel);
+ this.result = Objects.requireNonNull(result);
+ }
+
+ /**
+ * Get the configModel section.
+ *
+ * @return the section, never null.
+ */
+ public ConfigModel getConfigModel() {
+ return configModel;
+ }
+
+ /**
+ * Get the configModel result.
+ *
+ * @return the result, never null.
+ */
+ public ValidationResult getResult() {
+ return result;
+ }
+
+ /**
+ * Get the detail message.
+ *
+ * @return the detail message, or null.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public String toString() {
+ if (message != null) {
+ return result + ": " + configModel.getName() + " (" + configModel.getType() + ") -> " + message + '\n';
+ }
+ return result + ": " + configModel.getName() + " (" + configModel.getType() + ")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ValidationResult.java b/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
index bb6dedb..d719f37 100644
--- a/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
+++ b/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
@@ -18,186 +18,42 @@
*/
package org.apache.tamaya.model;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.spi.AbstractModel;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-
/**
- * Models a partial configuration configModel result.
+ * Enum type describing the different validation results supported.
*/
-public final class ValidationResult {
- /**
- * the config section.
- */
- private final ConfigModel configModel;
- /**
- * The configModel result.
- */
- private final ValidationState result;
- /**
- * The configModel message.
- */
- private final String message;
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing valid parts of the given model.
- */
- public static ValidationResult ofValid(ConfigModel configModel) {
- return new ValidationResult(configModel, ValidationState.VALID, null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing missing parts of the given model.
- */
- public static ValidationResult ofMissing(ConfigModel configModel) {
- return new ValidationResult(configModel, ValidationState.MISSING, null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param message Additional message to be shown (optional).
- * @return a new validation result containing missing parts of the given model with a message.
- */
- public static ValidationResult ofMissing(ConfigModel configModel, String message) {
- return new ValidationResult(configModel, ValidationState.MISSING, message);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param error error message to add.
- * @return a new validation result containing erroneous parts of the given model with the given error message.
- */
- public static ValidationResult ofError(ConfigModel configModel, String error) {
- return new ValidationResult(configModel, ValidationState.ERROR, error);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param warning warning message to add.
- * @return a new validation result containing warning parts of the given model with the given warning message.
- */
- public static ValidationResult ofWarning(ConfigModel configModel, String warning) {
- return new ValidationResult(configModel, ValidationState.WARNING, warning);
- }
-
+public enum ValidationResult {
/**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param alternativeUsage allows setting a message to indicate non-deprecated replacement, maybe null.
- * @return a new validation result containing deprecated parts of the given model with an optional message.
+ * The validated item is valid
*/
- public static ValidationResult ofDeprecated(ConfigModel configModel, String alternativeUsage) {
- return new ValidationResult(configModel, ValidationState.DEPRECATED, alternativeUsage != null ? "Use instead: " + alternativeUsage : null);
- }
-
+ VALID,
/**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing deprecated parts of the given model.
+ * The validated item is deprecated.
*/
- public static ValidationResult ofDeprecated(ConfigModel configModel) {
- return new ValidationResult(configModel, ValidationState.DEPRECATED, null);
- }
-
+ DEPRECATED,
/**
- * Creates a new ValidationResult.
- *
- * @param key the name/model key
- * @param type model type
- * @param provider model provider name
- * @return a corresponding configModel item
+ * The validated item is correct, but the value is worth a warning.
*/
- public static ValidationResult ofUndefined(final String key, final ModelType type, final String provider) {
- return new ValidationResult(new AbstractModel(key, false, "Undefined key: " + key, provider) {
-
- @Override
- public ModelType getType() {
- return type;
- }
-
- @Override
- public Collection<ValidationResult> validate(Configuration config) {
- return Collections.emptySet();
- }
- }, ValidationState.UNDEFINED, null);
- }
-
-
+ WARNING,
/**
- * Constructor.
- *
- * @param configModel the configModel item, not null.
- * @param result the configModel result, not null.
- * @param message the detail message.
- * @return new validation result.
+ * The given section or parameter is not a defined/validated item. It may be still valid, but typically,
+ * when validation is fully implemented, such a parameter or section should be removed.
*/
- public static ValidationResult of(ConfigModel configModel, ValidationState result, String message) {
- return new ValidationResult(configModel, result, message);
- }
-
-
+ UNDEFINED,
/**
- * Constructor.
- *
- * @param configModel the configModel item, not null.
- * @param result the configModel result, not null.
- * @param message the detail message.
+ * A required parameter or section is missing.
*/
- private ValidationResult(ConfigModel configModel, ValidationState result, String message) {
- this.message = message;
- this.configModel = Objects.requireNonNull(configModel);
- this.result = Objects.requireNonNull(result);
- }
-
+ MISSING,
/**
- * Get the configModel section.
- *
- * @return the section, never null.
+ * The validated item has an invalid value.
*/
- public ConfigModel getConfigModel() {
- return configModel;
- }
+ ERROR;
/**
- * Get the configModel result.
+ * Method to quickly evaluate if the current state is an error state.
*
- * @return the result, never null.
+ * @return true, if the state is not ERROR or MISSING.
*/
- public ValidationState getResult() {
- return result;
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message, or null.
- */
- public String getMessage() {
- return message;
- }
-
- @Override
- public String toString() {
- if (message != null) {
- return result + ": " + configModel.getName() + " (" + configModel.getType() + ") -> " + message + '\n';
- }
- return result + ": " + configModel.getName() + " (" + configModel.getType() + ")";
+ boolean isError() {
+ return this.ordinal() == MISSING.ordinal() || this.ordinal() == ERROR.ordinal();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/ValidationState.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/ValidationState.java b/model/src/main/java/org/apache/tamaya/model/ValidationState.java
deleted file mode 100644
index 0170085..0000000
--- a/model/src/main/java/org/apache/tamaya/model/ValidationState.java
+++ /dev/null
@@ -1,59 +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;
-
-/**
- * Enum type describing the different validation results supported.
- */
-public enum ValidationState {
- /**
- * The validated item is valid
- */
- VALID,
- /**
- * The validated item is deprecated.
- */
- DEPRECATED,
- /**
- * The validated item is correct, but the value is worth a warning.
- */
- WARNING,
- /**
- * The given section or parameter is not a defined/validated item. It may be still valid, but typically,
- * when validation is fully implemented, such a parametr or section should be removed.
- */
- UNDEFINED,
- /**
- * A required parameter or section is missing.
- */
- MISSING,
- /**
- * The validated item has an invalid value.
- */
- ERROR;
-
- /**
- * Method to quickly evaluate if the current state is an error state.
- *
- * @return true, if the state is not ERROR or MISSING.
- */
- boolean isError() {
- return this.ordinal() == MISSING.ordinal() || this.ordinal() == ERROR.ordinal();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java b/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
index b86fcec..2d40ac0 100644
--- a/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
+++ b/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
@@ -22,8 +22,8 @@ import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.model.ConfigModel;
import org.apache.tamaya.model.ConfigModelManager;
-import org.apache.tamaya.model.ModelType;
-import org.apache.tamaya.model.ValidationResult;
+import org.apache.tamaya.model.ModelTarget;
+import org.apache.tamaya.model.Validation;
import org.apache.tamaya.model.spi.ConfigDocumentationMBean;
import javax.json.Json;
@@ -49,9 +49,9 @@ public class ConfigDocumentationBean implements ConfigDocumentationMBean{
private final JsonWriterFactory writerFactory;
- private static final Comparator<ValidationResult> COMPARATOR = new Comparator<ValidationResult>() {
+ private static final Comparator<Validation> COMPARATOR = new Comparator<Validation>() {
@Override
- public int compare(ValidationResult v1, ValidationResult v2) {
+ public int compare(Validation v1, Validation v2) {
int compare = VAL_COMPARATOR.compare(v1.getConfigModel(), v2.getConfigModel());
if(compare==0){
compare = v1.getResult().compareTo(v2.getResult());
@@ -105,10 +105,10 @@ public class ConfigDocumentationBean implements ConfigDocumentationMBean{
@Override
public String validate(boolean showUndefined) {
- List<ValidationResult> validations = new ArrayList<>(ConfigModelManager.validate(getConfig(), showUndefined));
+ List<Validation> validations = new ArrayList<>(ConfigModelManager.validate(getConfig(), showUndefined));
Collections.sort(validations, COMPARATOR);
JsonArrayBuilder builder = Json.createArrayBuilder();
- for(ValidationResult val:validations){
+ for(Validation val:validations){
builder.add(toJsonObject(val));
}
return formatJson(builder.build());
@@ -128,8 +128,8 @@ public class ConfigDocumentationBean implements ConfigDocumentationMBean{
}
@Override
- public String getConfigurationModel(ModelType type) {
- return findValidationModels(type, ".*");
+ public String getConfigurationModel(ModelTarget type) {
+ return findValidationModels(".*", type);
}
@Override
@@ -144,8 +144,8 @@ public class ConfigDocumentationBean implements ConfigDocumentationMBean{
}
@Override
- public String findValidationModels(ModelType type, String namePattern) {
- List<ConfigModel> configModels = new ArrayList<>(ConfigModelManager.findModels(type, namePattern));
+ public String findValidationModels(String namePattern, ModelTarget... type) {
+ List<ConfigModel> configModels = new ArrayList<>(ConfigModelManager.findModels(namePattern, type));
Collections.sort(configModels, VAL_COMPARATOR);
JsonArrayBuilder result = Json.createArrayBuilder();
for(ConfigModel val: configModels){
@@ -172,7 +172,7 @@ public class ConfigDocumentationBean implements ConfigDocumentationMBean{
return valJson.build();
}
- private JsonObject toJsonObject(ValidationResult val) {
+ private JsonObject toJsonObject(Validation val) {
JsonObjectBuilder valJson = Json.createObjectBuilder().add("type", val.getConfigModel().getType().toString())
.add("name", val.getConfigModel().getName());
if(val.getConfigModel().isRequired()){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java b/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
index 5bcf677..6585181 100644
--- a/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
+++ b/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
@@ -22,6 +22,8 @@ import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.model.ConfigModel;
import org.apache.tamaya.model.spi.ConfigModelReader;
import org.apache.tamaya.model.spi.ModelProviderSpi;
+import org.apache.tamaya.spisupport.BasePropertySource;
+import org.apache.tamaya.spisupport.MapPropertySource;
import java.io.InputStream;
import java.net.URL;
@@ -132,7 +134,8 @@ public class ConfiguredPropertiesModelProviderSpi implements ModelProviderSpi {
try (InputStream is = config.openStream()) {
Properties props = new Properties();
props.load(is);
- configModels.addAll(ConfigModelReader.loadValidations(props, config.toString()));
+ configModels.addAll(ConfigModelReader.loadValidations(
+ MapPropertySource.getMap(props), config.toString()));
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE,
"Error loading config metadata from " + config, e);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java b/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
new file mode 100644
index 0000000..6c1afb0
--- /dev/null
+++ b/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
@@ -0,0 +1,82 @@
+/*
+ * 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.model.ConfigModel;
+
+import java.util.Objects;
+
+/**
+ * Default configuration Model for a configuration area.
+ */
+public abstract class AbstractConfigModel implements ConfigModel, Comparable<ConfigModel> {
+
+ private final String name;
+ private final String description;
+ private boolean required = false;
+
+
+ protected AbstractConfigModel(String name, boolean required, String description) {
+ this.name = Objects.requireNonNull(name);
+ this.description = description;
+ this.required = required;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public boolean isRequired() {
+ return required;
+ }
+
+ @Override
+ public int compareTo(ConfigModel configModel) {
+ int compare = getType().compareTo(configModel.getType());
+ if (compare != 0) {
+ return compare;
+ }
+ return getName().compareTo(configModel.getName());
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ AbstractConfigModel that = (AbstractConfigModel) o;
+ return getType().equals(that.getType()) && name.equals(that.name);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return getType().hashCode() + name.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/AbstractModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/AbstractModel.java b/model/src/main/java/org/apache/tamaya/model/spi/AbstractModel.java
deleted file mode 100644
index ae49731..0000000
--- a/model/src/main/java/org/apache/tamaya/model/spi/AbstractModel.java
+++ /dev/null
@@ -1,89 +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.model.ConfigModel;
-
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration area.
- */
-public abstract class AbstractModel implements ConfigModel, Comparable<ConfigModel> {
-
- private final String name;
- private final String provider;
- private final String description;
- private boolean required = false;
-
-
- protected AbstractModel(String name, boolean required, String description, String provider) {
- this.name = Objects.requireNonNull(name);
- this.description = description;
- this.required = required;
- this.provider = provider;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getProvider() {
- return provider;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public boolean isRequired() {
- return required;
- }
-
- @Override
- public int compareTo(ConfigModel configModel) {
- int compare = getType().compareTo(configModel.getType());
- if (compare != 0) {
- return compare;
- }
- return getName().compareTo(configModel.getName());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- AbstractModel that = (AbstractModel) o;
- return getType().equals(that.getType()) && name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- return getType().hashCode() + name.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/AreaConfigModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/AreaConfigModel.java b/model/src/main/java/org/apache/tamaya/model/spi/AreaConfigModel.java
deleted file mode 100644
index 7daf8b3..0000000
--- a/model/src/main/java/org/apache/tamaya/model/spi/AreaConfigModel.java
+++ /dev/null
@@ -1,204 +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.ModelType;
-import org.apache.tamaya.model.ValidationResult;
-
-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 AreaConfigModel extends ConfigModelGroup {
-
- /**
- * Creates a new builder.
- * @param name the section name.
- * @return a new builder instance.
- */
- public static Builder builder(String name){
- return new Builder(name);
- }
-
- /**
- * Creates a section validation for the given section.
- * @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 name, boolean required){
- return new Builder(name).setRequired(required).build();
- }
-
- /**
- * Creates a section validation for the given section.
- * @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 name, boolean required, ConfigModel... configModels){
- return new Builder(name).setRequired(required).addValidations(configModels).build();
- }
-
- /**
- * Internal constructor.
- * @param builder the builder, not null.
- */
- protected AreaConfigModel(Builder builder) {
- super(builder.name, builder.provider, builder.childConfigModels);
- }
-
- @Override
- public ModelType getType(){
- return ModelType.Section;
- }
-
- @Override
- public Collection<ValidationResult> validate(Configuration config) {
- Map<String,String> map = config.getProperties();
- String lookupKey = getName() + '.';
- boolean present = false;
- for(String key:map.keySet()){
- if(key.startsWith(lookupKey)){
- present = true;
- break;
- }
- }
- List<ValidationResult> result = new ArrayList<>(1);
- if(isRequired() && !present) {
- result.add(ValidationResult.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 name. */
- private String name;
- /** The optional provider. */
- private String provider;
- /** 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 sectionName the section name, not null.
- */
- public Builder(String sectionName){
- 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 )optional) provider.
- * @param provider the provider.
- * @return the Builder for chaining.
- */
- public Builder setProvider(String provider){
- this.provider = provider;
- 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 AreaConfigModel(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java b/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
index c24b9f7..f5636dc 100644
--- a/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
+++ b/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.model.spi;
-import org.apache.tamaya.model.ModelType;
+import org.apache.tamaya.model.ModelTarget;
/**
* JMX Management bean for accessing current configuration information
@@ -34,7 +34,7 @@ public interface ConfigDocumentationMBean {
String getConfigurationModel();
- String getConfigurationModel(ModelType type);
+ String getConfigurationModel(ModelTarget type);
/**
* Find the validations by checking the validation's name using the given regular expression.
@@ -45,9 +45,9 @@ public interface ConfigDocumentationMBean {
/**
* Find the validations by checking the validation's name using the given regular expression.
- * @param type the target ModelType, not null.
+ * @param type the target ModelTypes (optional), not null.
* @param namePattern the regular expression to use, not null.
* @return the sections defined, never null.
*/
- String findValidationModels(ModelType type, String namePattern);
+ String findValidationModels(String namePattern, ModelTarget... type);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelGroup.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelGroup.java b/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelGroup.java
deleted file mode 100644
index 7e0dc3a..0000000
--- a/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelGroup.java
+++ /dev/null
@@ -1,110 +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.ModelType;
-import org.apache.tamaya.model.ValidationResult;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration area.
- */
-public class ConfigModelGroup implements ConfigModel {
-
- private final String name;
- private boolean required;
- private final String provider;
- private List<ConfigModel> childConfigModels = new ArrayList<>();
-
- public ConfigModelGroup(String name, String provider, ConfigModel... configModels){
- this(name, provider, Arrays.asList(configModels));
- }
-
- public ConfigModelGroup(String name, String provider, Collection<ConfigModel> configModels){
- this.name = Objects.requireNonNull(name);
- this.provider = provider;
- this.childConfigModels.addAll(configModels);
- this.childConfigModels = Collections.unmodifiableList(childConfigModels);
- for(ConfigModel val: configModels) {
- if(val.isRequired()){
- this.required = true;
- break;
- }
- }
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getProvider() {
- return provider;
- }
-
- @Override
- public boolean isRequired() {
- return required;
- }
-
- @Override
- public ModelType getType() {
- return ModelType.Group;
- }
-
- @Override
- public String getDescription() {
- if(childConfigModels.isEmpty()){
- return null;
- }
- StringBuilder b = new StringBuilder();
- for(ConfigModel val: childConfigModels){
- b.append(" >> ").append(val);
- }
- return b.toString();
- }
-
- public Collection<ConfigModel> getValidations(){
- return childConfigModels;
- }
-
- @Override
- public Collection<ValidationResult> validate(Configuration config) {
- List<ValidationResult> result = new ArrayList<>(1);
- for(ConfigModel child: childConfigModels){
- result.addAll(child.validate(config));
- }
- return result;
- }
-
- @Override
- public String toString(){
- return String.valueOf(getType()) + ", size: " + childConfigModels.size() + ": " + getDescription();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java b/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
index 717926a..db85722 100644
--- a/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
+++ b/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
@@ -45,51 +45,44 @@ public final class ConfigModelReader {
* Utility class only.
*/
private ConfigModelReader(){}
+///*
+// *//**
+// * Loads validations as configured in the given properties.
+// * @param props the properties to be read
+// * @param selector
+// * @return a collection of config validations.
+// *//*
+// public static Collection<ConfigModel> loadValidations(Map<String,String> props, String selector) {
+// Map<String,String> map = new HashMap<>();
+// for(Map.Entry<String, String> en: props.entrySet()){
+// if(!selector.matches(en.getKey())){
+// map.put(en.getKey().toString(), props.get(en.getKey().toString()));
+// }
+// }
+// return loadValidations(map);
+// }*/
/**
* Loads validations as configured in the given properties.
* @param props the properties to be read
- * @param defaultProviderName the default provider name used if no explicit provider name is configured.
- * @return a collection of config validations.
- */
- public static Collection<ConfigModel> loadValidations(Properties props,
- String defaultProviderName) {
- Map<String,String> map = new HashMap<>();
- for(Map.Entry<Object,Object> en: props.entrySet()){
- map.put(en.getKey().toString(), props.getProperty(en.getKey().toString()));
- }
- return loadValidations(map, defaultProviderName);
- }
-
- /**
- * Loads validations as configured in the given properties.
- * @param props the properties to be read
- * @param defaultProviderName the default provider name used if no explicit provider name is configured.
* @return a collection of config validations.
*/
- public static Collection<ConfigModel> loadValidations(Map<String,String> props,
- String defaultProviderName) {
+ public static Collection<ConfigModel> loadValidations(Map<String,String> props) {
String selector = props.get(META_INFO_SELECTOR_PARAM);
if(selector==null){
selector = DEFAULT_META_INFO_SELECTOR;
}
- return loadValidations(props, selector, defaultProviderName);
+ return loadValidations(props, selector);
}
/**
* Loads validations as configured in the given properties.
* @param props the properties to be read
* @param selector the selector (default is {model}), that identifies the model entries.
- * @param defaultProviderName the default provider name used if no explicit provider name is configured.
* @return a collection of config validations.
*/
- public static Collection<ConfigModel> loadValidations(Map<String,String> props, String selector,
- String defaultProviderName) {
+ public static Collection<ConfigModel> loadValidations(Map<String,String> props, String selector) {
List<ConfigModel> result = new ArrayList<>();
- String provider = props.get(selector + ".__provider");
- if (provider == null) {
- provider = defaultProviderName;
- }
Set<String> itemKeys = new HashSet<>();
for (Object key : props.keySet()) {
if (key.toString().endsWith(".class")) {
@@ -113,14 +106,14 @@ public final class ConfigModelReader {
String requiredVal = props.get(baseKey + ".required");
if ("Parameter".equalsIgnoreCase(clazz)) {
result.add(createParameterValidation(baseKey.substring(selector.length() + 1), description, type,
- requiredVal, regEx, validations, provider));
+ requiredVal, regEx, validations));
} else if ("Section".equalsIgnoreCase(clazz)) {
if(transitive){
result.add(createSectionValidation(baseKey.substring(selector.length() + 1)+".*", description, requiredVal,
- validations, provider));
+ validations));
} else {
result.add(createSectionValidation(baseKey.substring(selector.length() + 1), description, requiredVal,
- validations, provider));
+ validations));
}
}
}
@@ -138,10 +131,10 @@ public final class ConfigModelReader {
* @return the new validation for this parameter.
*/
private static ConfigModel createParameterValidation(String paramName, String description, String type, String reqVal,
- String regEx, String validations, String provider) {
+ String regEx, String validations) {
boolean required = "true".equalsIgnoreCase(reqVal);
ParameterModel.Builder builder = ParameterModel.builder(paramName).setRequired(required)
- .setDescription(description).setExpression(regEx).setType(type).setProvider(provider);
+ .setDescription(description).setExpression(regEx).setType(type);
// if (validations != null) {
// try {
// // TODO defined validator API
@@ -162,10 +155,10 @@ public final class ConfigModelReader {
* @return the new validation for this section.
*/
private static ConfigModel createSectionValidation(String sectionName, String description, String reqVal,
- String validations, String provider) {
+ String validations) {
boolean required = "true".equalsIgnoreCase(reqVal);
- AreaConfigModel.Builder builder = AreaConfigModel.builder(sectionName).setRequired(required)
- .setDescription(description).setProvider(provider);
+ SectionModel.Builder builder = SectionModel.builder(sectionName).setRequired(required)
+ .setDescription(description);
// if (validations != null) {
// try {
// // TODO defined validator API
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java b/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
new file mode 100644
index 0000000..b8ead01
--- /dev/null
+++ b/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
@@ -0,0 +1,103 @@
+/*
+ * 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.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Default configuration Model for a configuration area.
+ */
+public class GroupModel implements ConfigModel {
+
+ private final String name;
+ private boolean required;
+ private List<ConfigModel> childModels = new ArrayList<>();
+
+ public GroupModel(String name, ConfigModel... configModels){
+ this(name, Arrays.asList(configModels));
+ }
+
+ public GroupModel(String name, Collection<ConfigModel> configModels){
+ this.name = Objects.requireNonNull(name);
+ this.childModels.addAll(configModels);
+ this.childModels = Collections.unmodifiableList(childModels);
+ for(ConfigModel val: configModels) {
+ if(val.isRequired()){
+ this.required = true;
+ break;
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean isRequired() {
+ return required;
+ }
+
+ @Override
+ public ModelTarget getType() {
+ return ModelTarget.Group;
+ }
+
+ @Override
+ public String getDescription() {
+ if(childModels.isEmpty()){
+ return null;
+ }
+ StringBuilder b = new StringBuilder();
+ for(ConfigModel val: childModels){
+ b.append(" >> ").append(val);
+ }
+ return b.toString();
+ }
+
+ public Collection<ConfigModel> getValidations(){
+ return childModels;
+ }
+
+ @Override
+ public Collection<Validation> validate(Configuration config) {
+ List<Validation> result = new ArrayList<>(1);
+ for(ConfigModel child: childModels){
+ result.addAll(child.validate(config));
+ }
+ return result;
+ }
+
+ @Override
+ public String toString(){
+ return String.valueOf(getType()) + ", size: " + childModels.size() + ": " + getDescription();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java b/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
index 43d7174..dfe5c56 100644
--- a/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
+++ b/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
@@ -20,8 +20,8 @@ package org.apache.tamaya.model.spi;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ModelType;
-import org.apache.tamaya.model.ValidationResult;
+import org.apache.tamaya.model.ModelTarget;
+import org.apache.tamaya.model.Validation;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,7 +33,7 @@ import java.util.logging.Logger;
/**
* Default configuration Model for a configuration parameter.
*/
-public class ParameterModel extends AbstractModel {
+public class ParameterModel extends AbstractConfigModel {
/** Optional regular expression for validating the value. */
private final String regEx;
/** The target type into which the value must be convertible. */
@@ -44,14 +44,14 @@ public class ParameterModel extends AbstractModel {
* @param builder the builder, not null.
*/
protected ParameterModel(Builder builder) {
- super(builder.name, builder.required, builder.description, builder.provider);
+ super(builder.name, builder.required, builder.description);
this.regEx = builder.regEx;
this.type = builder.type;
}
@Override
- public ModelType getType() {
- return ModelType.Parameter;
+ public ModelTarget getType() {
+ return ModelTarget.Parameter;
}
/**
@@ -64,15 +64,15 @@ public class ParameterModel extends AbstractModel {
}
@Override
- public Collection<ValidationResult> validate(Configuration config) {
- List<ValidationResult> result = new ArrayList<>(1);
+ public Collection<Validation> validate(Configuration config) {
+ List<Validation> result = new ArrayList<>(1);
String configValue = config.get(getName());
if (configValue == null && isRequired()) {
- result.add(ValidationResult.ofMissing(this));
+ result.add(Validation.ofMissing(this));
}
if (configValue != null && regEx != null) {
if (!configValue.matches(regEx)) {
- result.add(ValidationResult.ofError(this, "Config value not matching expression: " + regEx + ", was " +
+ result.add(Validation.ofError(this, "Config value not matching expression: " + regEx + ", was " +
configValue));
}
}
@@ -140,8 +140,6 @@ public class ParameterModel extends AbstractModel {
private Class<?> type;
/** The fully qualified parameter name. */
private String name;
- /** The optional provider. */
- private String provider;
/** The optional validation expression. */
private String regEx;
/** The optional description. */
@@ -216,16 +214,6 @@ public class ParameterModel extends AbstractModel {
}
/**
- * Set the provider.
- * @param provider the provider.
- * @return the Builder for chaining
- */
- public Builder setProvider(String provider) {
- this.provider = provider;
- return this;
- }
-
- /**
* Creates a new ConfigModel with the given parameters.
* @return a new ConfigModel , never null.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
----------------------------------------------------------------------
diff --git a/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java b/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
new file mode 100644
index 0000000..9f55a2b
--- /dev/null
+++ b/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
@@ -0,0 +1,192 @@
+/*
+ * 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 name the section name.
+ * @return a new builder instance.
+ */
+ public static Builder builder(String name){
+ return new Builder(name);
+ }
+
+ /**
+ * Creates a section validation for the given section.
+ * @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 name, boolean required){
+ return new Builder(name).setRequired(required).build();
+ }
+
+ /**
+ * Creates a section validation for the given section.
+ * @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 name, boolean required, ConfigModel... configModels){
+ return new Builder(name).setRequired(required).addValidations(configModels).build();
+ }
+
+ /**
+ * Internal constructor.
+ * @param builder the builder, not null.
+ */
+ protected SectionModel(Builder builder) {
+ super(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(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 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 sectionName the section name, not null.
+ */
+ public Builder(String sectionName){
+ 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-extensions/blob/5a22c680/model/src/test/java/org/apache/tamaya/model/TestConfigModelProvider.java
----------------------------------------------------------------------
diff --git a/model/src/test/java/org/apache/tamaya/model/TestConfigModelProvider.java b/model/src/test/java/org/apache/tamaya/model/TestConfigModelProvider.java
index f1f09a1..2c7e753 100644
--- a/model/src/test/java/org/apache/tamaya/model/TestConfigModelProvider.java
+++ b/model/src/test/java/org/apache/tamaya/model/TestConfigModelProvider.java
@@ -18,16 +18,22 @@
*/
package org.apache.tamaya.model;
-import org.apache.tamaya.model.spi.AreaConfigModel;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.model.spi.SectionModel;
import org.apache.tamaya.model.spi.ParameterModel;
-import org.apache.tamaya.model.spi.ConfigModelGroup;
+import org.apache.tamaya.model.spi.GroupModel;
import org.apache.tamaya.model.spi.ModelProviderSpi;
+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.assertNotNull;
+
/**
* Created by Anatole on 09.08.2015.
*/
@@ -36,7 +42,7 @@ public class TestConfigModelProvider implements ModelProviderSpi {
private List<ConfigModel> configModels = new ArrayList<>(1);
public TestConfigModelProvider(){
- configModels.add(new TestConfigConfigModel());
+ configModels.add(new TestConfigModel());
configModels = Collections.unmodifiableList(configModels);
}
@@ -44,14 +50,14 @@ public class TestConfigModelProvider implements ModelProviderSpi {
return configModels;
}
- private static final class TestConfigConfigModel extends ConfigModelGroup {
+ private static final class TestConfigModel extends GroupModel {
- public TestConfigConfigModel(){
- super("TestConfig", "test", new AreaConfigModel.Builder("a.test.existing").setRequired(true).build(),
+ public TestConfigModel(){
+ super("TestConfig", new SectionModel.Builder("a.test.existing").setRequired(true).build(),
ParameterModel.of("a.test.existing.aParam", true),
ParameterModel.of("a.test.existing.optionalParam"),
ParameterModel.of("a.test.existing.aABCParam", false, "[ABC].*"),
- new AreaConfigModel.Builder("a.test.notexisting").setRequired(true).build(),
+ new SectionModel.Builder("a.test.notexisting").setRequired(true).build(),
ParameterModel.of("a.test.notexisting.aParam", true),
ParameterModel.of("a.test.notexisting.optionalParam"),
ParameterModel.of("a.test.existing.aABCParam2", false, "[ABC].*"));
@@ -62,4 +68,22 @@ public class TestConfigModelProvider implements ModelProviderSpi {
}
}
+
+ @Test
+ public void testUsage(){
+ TestConfigAccessor.readConfiguration();
+ Configuration config = ConfigurationProvider.getConfiguration();
+ String info = ConfigModelManager.getUsageInfo();
+ assertNotNull(info);
+ System.out.println(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 = ConfigModelManager.getUsageInfo();
+ System.out.println(info);
+ assertNotNull(info);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5a22c680/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
----------------------------------------------------------------------
diff --git a/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java b/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
index 0f344d6..d60e902 100644
--- a/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
+++ b/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.model.internal;
-import org.apache.tamaya.model.ModelType;
+import org.apache.tamaya.model.ModelTarget;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
@@ -73,7 +73,7 @@ public class ConfigDocumentationBeanTest {
@Test
public void testGetConfigurationModel_WithSection() throws Exception {
- String results = mbean.getConfigurationModel(ModelType.Parameter);
+ String results = mbean.getConfigurationModel(ModelTarget.Parameter);
assertNotNull(results);
assertFalse(results.trim().isEmpty());
assertTrue(results.contains("\"type\":\"Parameter\""));
@@ -92,15 +92,11 @@ public class ConfigDocumentationBeanTest {
@Test
public void testFindValidationModels() throws Exception {
- String results = mbean.findValidationModels(ModelType.Section, "a");
+ String results = mbean.findValidationModels("a", ModelTarget.Section);
assertNotNull(results);
assertFalse(results.trim().isEmpty());
assertFalse(results.contains("\"type\":\"Parameter\""));
assertTrue(results.contains("\"type\":\"Section\""));
- results = mbean.findValidationModels(ModelType.CombinationPolicy, "a");
- assertFalse(results.trim().isEmpty());
- assertFalse(results.contains("\"type\":\"Parameter\""));
- assertFalse(results.contains("\"type\":\"Section\""));
System.out.println(results);
}