tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [1/2] incubator-tamaya git commit: [TAMAYA-203] Re-added the minimal example of Tamayas usage.
Date Thu, 24 Nov 2016 20:21:11 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 4bce88abf -> cf12cc1bc


[TAMAYA-203] Re-added the minimal example of Tamayas usage.


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

Branch: refs/heads/master
Commit: cf12cc1bcf10621912a4b0c97a2c552c48d29c49
Parents: dcd3e69
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Thu Nov 24 21:20:11 2016 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Thu Nov 24 21:20:57 2016 +0100

----------------------------------------------------------------------
 examples/01-minimal/pom.xml                     | 54 +++++++++++++
 .../apache/tamaya/examples/minimal/Main.java    | 84 ++++++++++++++++++++
 .../tamaya/examples/minimal/package-info.java   | 24 ++++++
 .../META-INF/javaconfiguration.properties       | 26 ++++++
 examples/pom.xml                                | 45 +++++++++++
 pom.xml                                         |  1 +
 6 files changed, 234 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/examples/01-minimal/pom.xml
----------------------------------------------------------------------
diff --git a/examples/01-minimal/pom.xml b/examples/01-minimal/pom.xml
new file mode 100644
index 0000000..e137377
--- /dev/null
+++ b/examples/01-minimal/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<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.examples</groupId>
+        <artifactId>examples</artifactId>
+        <version>0.3-incubating-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.tamaya.examples</groupId>
+    <artifactId>01-minimal</artifactId>
+    <version>0.3-incubating-SNAPSHOT</version>
+
+    <name>Apache Tamaya Minimal Examples</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
new file mode 100644
index 0000000..b999cb9
--- /dev/null
+++ b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
@@ -0,0 +1,84 @@
+/*
+ * 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.examples.minimal;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+import static java.lang.String.format;
+
+/**
+ * Minimal example showing how to use Tamaya in the simplest possible way.
+ *
+ * <p>
+ *  Without any additional configuration Tamaya allows you access via
+ *  {@link ConfigurationProvider#getConfiguration} all configuration values.
+ *  Accessable are all system environment properties, all system properties,
+ *  and all properties which are found in {@code /META-INF/javaconfiguration.properties}
+ *  or {@code /META-INF/javaconfiguration.xml}.
+ * </p>
+ *
+ * @see org.apache.tamaya.core.propertysource.EnvironmentPropertySource
+ * @see org.apache.tamaya.core.propertysource.SystemPropertySource
+ */
+public class Main {
+    /*
+     * Turns off all logging.
+     */
+    static {
+        LogManager.getLogManager().reset();
+        Logger globalLogger = Logger.getLogger(java.util.logging.Logger.GLOBAL_LOGGER_NAME);
+        globalLogger.setLevel(java.util.logging.Level.OFF);
+    }
+
+    private Main() {
+    }
+
+    public static void main(String[] args) {
+        Configuration cfg = ConfigurationProvider.getConfiguration();
+
+        System.out.println("****************************************************");
+        System.out.println("Minimal Example");
+        System.out.println("****************************************************");
+        System.out.println();
+        System.out.println("Example Metadata:");
+        System.out.println("\tType        :  " + cfg.get("example.type"));
+        System.out.println("\tName        :  " + cfg.get("example.name"));
+        System.out.println("\tDescription :  " + cfg.get("example.description"));
+        System.out.println("\tVersion     :  " + cfg.get("example.version"));
+        System.out.println("\tAuthor      :  " + cfg.get("example.author"));
+        System.out.println();
+
+        dump(cfg.getProperties(), System.out);
+    }
+
+    private static void dump(Map<String, String> properties, PrintStream stream) {
+        stream.println("FULL DUMP:\n\n");
+
+        for (Map.Entry<String, String> en : new TreeMap<>(properties).entrySet())
{
+            stream.println(format("\t%s = %s", en.getKey(), en.getValue()));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/package-info.java
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/package-info.java
b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/package-info.java
new file mode 100644
index 0000000..9e424cd
--- /dev/null
+++ b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Example to show the simplest ways to use Tamaya with
+ * the standard configuration file.
+ */
+package org.apache.tamaya.examples.minimal;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/examples/01-minimal/src/main/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/resources/META-INF/javaconfiguration.properties
b/examples/01-minimal/src/main/resources/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..361aebc
--- /dev/null
+++ b/examples/01-minimal/src/main/resources/META-INF/javaconfiguration.properties
@@ -0,0 +1,26 @@
+#
+# 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.type=standalone
+example.name=Minimal
+example.description=A minimal example only using API and RI.
+example.version=1
+example.author=anatole@apache.org
+
+example.number=350322222222222222222222222222222222222222222222222222222222222222222
+example.testEnum=V2

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 0000000..6c06676
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<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</groupId>
+        <artifactId>tamaya-all</artifactId>
+        <version>0.3-incubating-SNAPSHOT</version>
+    </parent>
+
+
+    <groupId>org.apache.tamaya.examples</groupId>
+    <artifactId>examples</artifactId>
+    <version>0.3-incubating-SNAPSHOT</version>
+
+    <name>Apache Tamaya Core Examples</name>
+
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>01-minimal</module>
+    </modules>
+
+    
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cf12cc1b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e0765db..56eac1c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -212,6 +212,7 @@ under the License.
         <module>buildconfigurations</module>
         <module>code</module>
         <module>docs</module>
+        <module>examples</module>
         <module>distribution</module>
     </modules>
 


Mime
View raw message