This is an automated email from the ASF dual-hosted git repository. anatole pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tamaya-sandbox.git
commit 3f00ff159782d2e720e7b15122dc0854a2ee0406 Author: Anatole Tresch <[email protected]> AuthorDate: Tue Dec 11 11:01:57 2018 +0100 Added basic working config documentation features, including html support. --- .../org/apache/tamaya/doc/ConfigDocumenter.java | 14 ++- .../apache/tamaya/doc/DocumentedConfiguration.java | 4 +- .../apache/tamaya/doc/annot/ConfigAreaSpec.java | 4 +- .../tamaya/doc/annot/ConfigPropertySpec.java | 2 +- .../java/org/apache/tamaya/validation/Finding.java | 54 ----------- .../apache/tamaya/validation/ValidationResult.java | 29 ------ .../main/resources/META-INF/configmodel.properties | 35 +++++++ ....tamaya.validation.spi.ConfigDocumentationMBean | 19 ++++ ...g.apache.tamaya.validation.spi.ModelProviderSpi | 22 +++++ .../test/resources/META-INF/configmodel.properties | 96 ++++++++++++++++++ .../META-INF/javaconfiguration.properties | 22 +++++ .../org.apache.tamaya.model.spi.ModelProviderSpi | 19 ++++ .../src/test/resources/examples/configmodel.ini | 76 +++++++++++++++ .../src/test/resources/examples/configmodel.json | 108 +++++++++++++++++++++ .../test/resources/examples/configmodel.properties | 96 ++++++++++++++++++ .../src/test/resources/examples/configmodel.xml | 97 ++++++++++++++++++ .../src/test/resources/examples/configmodel.yaml | 106 ++++++++++++++++++++ 17 files changed, 714 insertions(+), 89 deletions(-) diff --git a/documentation/src/main/java/org/apache/tamaya/doc/ConfigDocumenter.java b/documentation/src/main/java/org/apache/tamaya/doc/ConfigDocumenter.java index 6c00d16..c726101 100644 --- a/documentation/src/main/java/org/apache/tamaya/doc/ConfigDocumenter.java +++ b/documentation/src/main/java/org/apache/tamaya/doc/ConfigDocumenter.java @@ -19,6 +19,7 @@ package org.apache.tamaya.doc; import org.apache.tamaya.doc.annot.*; +import org.apache.tamaya.spi.ServiceContextManager; import org.reflections.Reflections; import org.reflections.scanners.FieldAnnotationsScanner; import org.reflections.scanners.MethodAnnotationsScanner; @@ -39,10 +40,21 @@ import java.util.List; /** * Class to read and store the current configuration documentation. */ -public final class ConfigDocumenter { +public class ConfigDocumenter { private DocumentedConfiguration docs = new DocumentedConfiguration(); + + public static ConfigDocumenter getInstance(){ + return ServiceContextManager.getServiceContext() + .getService(ConfigDocumenter.class, ConfigDocumenter::new); + } + + public static ConfigDocumenter getInstance(ClassLoader classLoader){ + return ServiceContextManager.getServiceContext(classLoader) + .getService(ConfigDocumenter.class, ConfigDocumenter::new); + } + /** * Read documentation from the given classes. * @param clazzes the classes to read, not null. diff --git a/documentation/src/main/java/org/apache/tamaya/doc/DocumentedConfiguration.java b/documentation/src/main/java/org/apache/tamaya/doc/DocumentedConfiguration.java index 2596d84..62aa446 100644 --- a/documentation/src/main/java/org/apache/tamaya/doc/DocumentedConfiguration.java +++ b/documentation/src/main/java/org/apache/tamaya/doc/DocumentedConfiguration.java @@ -60,7 +60,7 @@ public final class DocumentedConfiguration { /** * Get the current configuration name. - * @return the name, or '<undefined>'. + * @return the name, or {@code <undefined>}. */ public String getName() { if(name==null){ @@ -71,7 +71,7 @@ public final class DocumentedConfiguration { /** * Get the current configuration version. - * @return the version, or '<undefined>'. + * @return the version, or {@code <undefined>}. */ public String getVersion() { if(version==null){ diff --git a/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigAreaSpec.java b/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigAreaSpec.java index 589cc6c..27c27fa 100644 --- a/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigAreaSpec.java +++ b/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigAreaSpec.java @@ -60,14 +60,14 @@ public @interface ConfigAreaSpec { PropertyValue.ValueType areaType() default PropertyValue.ValueType.MAP; /** - * The minimal cardinality required. A cardinality > 0 means that the corresponding area must be present + * The minimal cardinality required. A cardinality > 0 means that the corresponding area must be present * in your configuration. This can be ensured/checked by a configuration validation system. * @return the minimal cardinality. */ int min() default 0; /** - * The maximal cardinality allowed. A cardinality > 0 means that the corresponding area must not be present + * The maximal cardinality allowed. A cardinality > 0 means that the corresponding area must not be present * in your configuration more than the configured times. This can be ensured/checked by a configuration validation * system. * @return the maximal cardinality. diff --git a/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigPropertySpec.java b/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigPropertySpec.java index 0e77e05..49ee6df 100644 --- a/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigPropertySpec.java +++ b/documentation/src/main/java/org/apache/tamaya/doc/annot/ConfigPropertySpec.java @@ -32,7 +32,7 @@ public @interface ConfigPropertySpec { /** * The property name. The full property key is a combination of the parent - * @return + * @return the name of the property, taken from the default resolution, if empty. */ String name() default ""; diff --git a/documentation/src/main/java/org/apache/tamaya/validation/Finding.java b/documentation/src/main/java/org/apache/tamaya/validation/Finding.java deleted file mode 100644 index d75c677..0000000 --- a/documentation/src/main/java/org/apache/tamaya/validation/Finding.java +++ /dev/null @@ -1,54 +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 createObject 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.validation; - -/** - * Enum type describing the different validation results supported. - */ -public enum Finding { - /** - * The validated item is valid - */ - VALID, - /** - * The validated item is deprecated. - */ - DEPRECATED, - /** - * The validated item is correct, but the createValue is worth a warning. - */ - WARNING, - /** - * A required parameter or section is missing. - */ - MISSING, - /** - * The validated item has an invalid createValue. - */ - 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(); - } -} diff --git a/documentation/src/main/java/org/apache/tamaya/validation/ValidationResult.java b/documentation/src/main/java/org/apache/tamaya/validation/ValidationResult.java deleted file mode 100644 index 6ff8a4c..0000000 --- a/documentation/src/main/java/org/apache/tamaya/validation/ValidationResult.java +++ /dev/null @@ -1,29 +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 createObject 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.validation; - -import java.util.Collection; -import java.util.Collections; - -public class ValidationResult { - - public Collection<ValidationCheck> getRules(){ - return Collections.emptyList(); - } -} diff --git a/documentation/src/main/resources/META-INF/configmodel.properties b/documentation/src/main/resources/META-INF/configmodel.properties new file mode 100644 index 0000000..3381a09 --- /dev/null +++ b/documentation/src/main/resources/META-INF/configmodel.properties @@ -0,0 +1,35 @@ +# +# 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 diff --git a/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean b/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean new file mode 100644 index 0000000..576695e --- /dev/null +++ b/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean @@ -0,0 +1,19 @@ +# +# 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.validation.internal.ConfigDocumentationBean \ No newline at end of file diff --git a/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi b/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi new file mode 100644 index 0000000..2788871 --- /dev/null +++ b/documentation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi @@ -0,0 +1,22 @@ +# +# 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.validation.internal.ConfiguredPropertiesModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredInlineModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredResourcesModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredTypeEventsModelProvider \ No newline at end of file diff --git a/documentation/src/test/resources/META-INF/configmodel.properties b/documentation/src/test/resources/META-INF/configmodel.properties new file mode 100644 index 0000000..7152615 --- /dev/null +++ b/documentation/src/test/resources/META-INF/configmodel.properties @@ -0,0 +1,96 @@ +# +# 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 createObject 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 createObject 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 + + + + diff --git a/documentation/src/test/resources/META-INF/javaconfiguration.properties b/documentation/src/test/resources/META-INF/javaconfiguration.properties new file mode 100644 index 0000000..b0b8c22 --- /dev/null +++ b/documentation/src/test/resources/META-INF/javaconfiguration.properties @@ -0,0 +1,22 @@ +# +# 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 diff --git a/documentation/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi b/documentation/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi new file mode 100644 index 0000000..9b29fda --- /dev/null +++ b/documentation/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi @@ -0,0 +1,19 @@ +# +# 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 diff --git a/documentation/src/test/resources/examples/configmodel.ini b/documentation/src/test/resources/examples/configmodel.ini new file mode 100644 index 0000000..0e10cc1 --- /dev/null +++ b/documentation/src/test/resources/examples/configmodel.ini @@ -0,0 +1,76 @@ +# +# 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 + + + + diff --git a/documentation/src/test/resources/examples/configmodel.json b/documentation/src/test/resources/examples/configmodel.json new file mode 100644 index 0000000..c6e5076 --- /dev/null +++ b/documentation/src/test/resources/examples/configmodel.json @@ -0,0 +1,108 @@ +/* +* 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 createObject a configuration metamodel expressed via YAML(tm). +// Structure is shown through indentation (one or more spaces). +// Sequence items are denoted by a dash, +// key createValue 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 createObject 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" + } + } +} + + diff --git a/documentation/src/test/resources/examples/configmodel.properties b/documentation/src/test/resources/examples/configmodel.properties new file mode 100644 index 0000000..a15798e --- /dev/null +++ b/documentation/src/test/resources/examples/configmodel.properties @@ -0,0 +1,96 @@ +# +# 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 createObject 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 createObject 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 + + + + diff --git a/documentation/src/test/resources/examples/configmodel.xml b/documentation/src/test/resources/examples/configmodel.xml new file mode 100644 index 0000000..412f85f --- /dev/null +++ b/documentation/src/test/resources/examples/configmodel.xml @@ -0,0 +1,97 @@ +<!-- +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 createObject 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 createObject a configuration metamodel expressed via YAML(tm). +# Structure is shown through indentation (one or more spaces). +# Sequence items are denoted by a dash, +# key createValue 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 createObject 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> diff --git a/documentation/src/test/resources/examples/configmodel.yaml b/documentation/src/test/resources/examples/configmodel.yaml new file mode 100644 index 0000000..eae9bec --- /dev/null +++ b/documentation/src/test/resources/examples/configmodel.yaml @@ -0,0 +1,106 @@ +# +# 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 createObject a configuration metamodel expressed via YAML(tm). +# Structure is shown through indentation (one or more spaces). +# Sequence items are denoted by a dash, +# key createValue 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 createObject 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' +} + +
