You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/08/01 00:40:28 UTC

incubator-tamaya git commit: Initial partial draft of a model component for documenting, validating of configuration during runtime.

Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 3c79a69c7 -> c4822f3e7


Initial partial draft of a model component for documenting, validating of configuration during runtime.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c4822f3e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c4822f3e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c4822f3e

Branch: refs/heads/master
Commit: c4822f3e7e0b3066a88d05b304ea78c46698ef07
Parents: 3c79a69
Author: anatole <at...@gmail.com>
Authored: Sat Aug 1 00:40:04 2015 +0200
Committer: anatole <at...@gmail.com>
Committed: Sat Aug 1 00:40:04 2015 +0200

----------------------------------------------------------------------
 sandbox/model/pom.xml                           | 50 ++++++++++
 .../src/test/resources/examples/configmodel.ini | 56 +++++++++++
 .../test/resources/examples/configmodel.json    | 98 ++++++++++++++++++++
 .../src/test/resources/examples/configmodel.xml | 68 ++++++++++++++
 .../test/resources/examples/configmodel.yaml    | 70 ++++++++++++++
 5 files changed, 342 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4822f3e/sandbox/model/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/model/pom.xml b/sandbox/model/pom.xml
new file mode 100644
index 0000000..0b2b502
--- /dev/null
+++ b/sandbox/model/pom.xml
@@ -0,0 +1,50 @@
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy current the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.tamaya.ext</groupId>
+        <artifactId>tamaya-sandbox</artifactId>
+        <version>0.1-incubating-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.tamaya.ext.model</groupId>
+    <artifactId>tamaya-model</artifactId>
+    <name>Apache Tamaya Extension Modules: Configuration Model Infrastructure</name>
+    <description>This extension module provides functionality to describe, document and
+        validate configuration during runtime.
+    </description>
+    <packaging>jar</packaging>
+
+    <scm>
+        <connection>
+            scm:git://git.apache.org/incubator-tamaya.git
+        </connection>
+        <developerConnection>
+            scm:git://git.apache.org/incubator-tamaya.git
+        </developerConnection>
+        <url>
+            https://git-wip-us.apache.org/repos/asf?p=incubator-tamaya.git
+        </url>
+    </scm>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4822f3e/sandbox/model/src/test/resources/examples/configmodel.ini
----------------------------------------------------------------------
diff --git a/sandbox/model/src/test/resources/examples/configmodel.ini b/sandbox/model/src/test/resources/examples/configmodel.ini
new file mode 100644
index 0000000..1171228
--- /dev/null
+++ b/sandbox/model/src/test/resources/examples/configmodel.ini
@@ -0,0 +1,56 @@
+####################################################################################
+# Example of a configuration metamodel expressed via ini(tm).
+####################################################################################
+
+####################################################################################
+# Metamodel information
+####################################################################################
+[__meta-model]
+name = testmodel,
+provider = ConfigModel Extension,
+version = 1.0,
+release-date = 2001-01-23,
+author = Anatole Tresch,
+# model-format    = alternate format reader type
+comments : = Late afternoon is best.\
+           Backup contact is Nancy.
+
+####################################################################################
+# Description of Configuration Sections (minimal, can be extended by other modules).
+# By default its interpreted as a section !
+####################################################################################
+[a]
+# Paramname Type         Validations   Description
+params2 = String,      required,     "a required parameter"
+paramInt = Integer,                   "an optional parameter (default)"
+
+[a.b.c]
+__desc = Just a test section
+
+[a.b.c.aRequiredSection]
+__validations = required
+__desc = 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]
+# Paramname   Type         Validations   Description
+param0 = String,                    "a minmally documented String parameter"
+# A minmal String parameter
+param00 = String
+# description is optional
+param1 = String,      required
+intParam = Integer,                   "an optional parameter (default)"
+
+[a.b.c.aRequiredSection.nonempty-subsection]
+__validations = required
+
+[a.b.c.aRequiredSection.optional-subsection]
+
+[a.b.c.aValidatedSection]
+__desc = "A validated section."
+__validations = org.apache.tamaya.model.TestValidator?max=3
+
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4822f3e/sandbox/model/src/test/resources/examples/configmodel.json
----------------------------------------------------------------------
diff --git a/sandbox/model/src/test/resources/examples/configmodel.json b/sandbox/model/src/test/resources/examples/configmodel.json
new file mode 100644
index 0000000..b5e3043
--- /dev/null
+++ b/sandbox/model/src/test/resources/examples/configmodel.json
@@ -0,0 +1,98 @@
+//##################################################################################
+// Example of a configuration metamodel expressed via YAML(tm).
+//  Structure is shown through indentation (one or more spaces).
+//  Sequence items are denoted by a dash,
+//  key value pairs within a map are separated by a colon.
+//##################################################################################
+
+//##################################################################################
+// Metamodel information
+//##################################################################################
+{
+  "__meta-model": {
+    "name": "testmodel",
+    "provider": "ConfigModel Extension",
+    "version": "1.0",
+    "release-date": "2001-01-23",
+    "author": "Anatole Tresch",
+    // "modelformat": "alternate format reader type"
+    "comments": "Late afternoon is best. Backup contact is Nancy."
+  },
+  //##################################################################################
+  // Description of Configuration Sections (minimal, can be extended by other modules).
+  //##################################################################################
+  "a": {
+    // Paramname Type         Validations    Description
+    "params2": [
+      "String",
+      "required",
+      "a required parameter"
+    ],
+    "paramInt": [
+      "Integer",
+      "an optional parameter (default)"
+    ],
+    "sections": [
+      "b.c"
+      :
+      {
+        "__desc": "Just a test section."
+      }
+    ],
+  },
+  "a.b.c.aRequiredSection": {
+    "__validations": "required",
+    "__desc": "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": {
+    // Paramname   Type         Validations   Description
+    "param0": [
+      "String",
+      "a minmally documented String parameter"
+    ],
+    // A minmally defined String parameter
+    "param00": [
+      "String"
+    ],
+    "param1": [
+      "String",
+      "required",
+      "a required parameter"
+    ],
+    "intParam": [
+      "Integer",
+      "an optional parameter (default)"
+    ]
+  },
+  "a.b.c.aRequiredSection.nonempty-subsection": {
+    "__validations": "required"
+  },
+  "a.b.c.aRequiredSection.optional-subsection": {},
+  "a.b.c.aRequiredSection.aValidatedSection": {
+    "__desc": "A validated section.",
+    "__validations": [
+      "org.apache.tamaya.model.validation.MaxItemValidator?max=3"
+    ]
+  }
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4822f3e/sandbox/model/src/test/resources/examples/configmodel.xml
----------------------------------------------------------------------
diff --git a/sandbox/model/src/test/resources/examples/configmodel.xml b/sandbox/model/src/test/resources/examples/configmodel.xml
new file mode 100644
index 0000000..5bdcb44
--- /dev/null
+++ b/sandbox/model/src/test/resources/examples/configmodel.xml
@@ -0,0 +1,68 @@
+<!--################################################################################
+# Example of a configuration metamodel expressed via YAML(tm).
+#   Structure is shown through indentation (one or more spaces).
+#   Sequence items are denoted by a dash,
+#   key value pairs within a map are separated by a colon.
+#################################################################################-->
+
+<!--################################################################################
+# Metamodel information
+#################################################################################-->
+
+<model>
+    <meta-model>
+        <name>testmodel</name>
+        <provider>ConfigModel Extension</provider>
+        <version>1.0</version>
+        <release-date>2001-01-23</release-date>
+        <author>Anatole Tresch</author>
+        <!-- model-format>alternate format reader type</model-format -->
+        <comments>Late afternoon is best.
+            Backup contact is Nancy.
+        </comments>
+    </meta-model>
+
+    <!--################################################################################
+    # Description of Configuration Sections (minimal, can be extended by other modules).
+    #################################################################################-->
+    <section name="a">
+        <param name="params2" type="String" validators="required">a required parameter</param>
+        <param name="paramInt" type="Integer" validators="required">an optional parameter (default)</param>
+        <section name="b.c">
+            <desc>Just a test section.</desc>
+        </section>
+    </section>
+    <section name="a.b.c.aRequiredSection" validators="required">
+        <desc>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.
+        </desc>
+    </section>
+</model>
+        <!--
+                a.b.c.aRequiredSection.subsection: {
+                # Paramname   Type         Validations   Description
+                param0:    'String',                   'a minmally documented String parameter}',
+                param00:   'String',                                 # A minmally defined String parameter
+                param1:    'String',     'required',   'a required parameter',
+                intParam:  'Integer',                  'an optional parameter (default)'
+                }
+                ...
+
+                ---
+                a.b.c.aRequiredSection.nonempty-subsection: {
+                __validations: 'required'
+                }
+                ...
+
+                ---
+                a.b.c.aRequiredSection.optional-subsection: {}
+                ...
+
+                ---
+                a.b.c.aRequiredSection.aValidatedSection: {
+                __desc: 'A validated section.',
+                __validations: 'org.apache.tamaya.model.validation.MaxItemValidator?max=3'
+                }
+        -->
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4822f3e/sandbox/model/src/test/resources/examples/configmodel.yaml
----------------------------------------------------------------------
diff --git a/sandbox/model/src/test/resources/examples/configmodel.yaml b/sandbox/model/src/test/resources/examples/configmodel.yaml
new file mode 100644
index 0000000..30b0e58
--- /dev/null
+++ b/sandbox/model/src/test/resources/examples/configmodel.yaml
@@ -0,0 +1,70 @@
+####################################################################################
+# Example of a configuration metamodel expressed via YAML(tm).
+#   Structure is shown through indentation (one or more spaces).
+#   Sequence items are denoted by a dash,
+#   key value pairs within a map are separated by a colon.
+####################################################################################
+
+####################################################################################
+# Metamodel information
+####################################################################################
+__meta-model: {
+  name           :  'testmodel',
+  provider       :  'ConfigModel Extension',
+  version        :  '1.0',
+  release-date   :  2001-01-23,
+  author         :  'Anatole Tresch',
+  # model-format: 'alternate format reader type'
+  comments: >
+    Late afternoon is best.
+    Backup contact is Nancy.
+}
+
+####################################################################################
+# Description of Configuration Sections (minimal, can be extended by other modules).
+####################################################################################
+---
+a: {
+# Paramname Type         Validations    Description
+  params2:  'String',    'required',   'a required parameter',
+  paramInt: 'Integer',                 'an optional parameter (default)',
+}
+---
+a.b.c: {
+  __desc:  'Just a test section.'
+}
+---
+a.b.c.aRequiredSection: {
+  __validations: 'required',
+  __desc: |
+             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: {
+# Paramname   Type         Validations   Description
+  param0:    'String',                   'a minmally documented String parameter}',
+  param00:   'String',                                 # A minmally defined String parameter
+  param1:    'String',     'required',   'a required parameter',
+  intParam:  'Integer',                  'an optional parameter (default)'
+}
+...
+
+---
+a.b.c.aRequiredSection.nonempty-subsection: {
+  __validations: 'required'
+}
+...
+
+---
+a.b.c.aRequiredSection.optional-subsection: {}
+...
+
+---
+a.b.c.aRequiredSection.aValidatedSection: {
+  __desc: 'A validated section.',
+  __validations: 'org.apache.tamaya.model.validation.MaxItemValidator?max=3'
+}
+
+