Repository: incubator-tamaya-extensions Updated Branches: refs/heads/master 016f57f44 -> 5d867b007
[TAMAYA-206] Re-added first example of the extensions to the project. 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/5d867b00 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/5d867b00 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/5d867b00 Branch: refs/heads/master Commit: 5d867b00710d176c151b12180172be6a2734c9e5 Parents: 016f57f Author: Oliver B. Fischer <[email protected]> Authored: Tue Jan 3 01:55:05 2017 +0100 Committer: Oliver B. Fischer <[email protected]> Committed: Tue Jan 3 01:55:57 2017 +0100 ---------------------------------------------------------------------- examples/01-resources-example/pom.xml | 56 +++++++++++++++ .../tamaya/ext/examples/resources/Main.java | 73 ++++++++++++++++++++ .../resources/MyPathPropertySourceProvider.java | 39 +++++++++++ .../ext/examples/resources/package-info.java | 23 ++++++ .../META-INF/MyOtherConfigProperties.properties | 21 ++++++ .../META-INF/javaconfiguration.properties | 25 +++++++ ...org.apache.tamaya.spi.PropertySourceProvider | 19 +++++ .../src/main/resources/subs/a.properties | 19 +++++ .../src/main/resources/subs/b.properties | 19 +++++ .../src/main/resources/subs/c.properties | 19 +++++ examples/pom.xml | 44 ++++++++++++ pom.xml | 1 + 12 files changed, 358 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/pom.xml ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/pom.xml b/examples/01-resources-example/pom.xml new file mode 100644 index 0000000..2076e3c --- /dev/null +++ b/examples/01-resources-example/pom.xml @@ -0,0 +1,56 @@ +<?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.ext.examples</groupId> + <artifactId>examples</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + </parent> + + <groupId>org.apache.tamaya.ext.examples</groupId> + <artifactId>01-resources-example</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + + <name>Apache Tamaya Resource Location Example</name> + <description>This project contains a simple example using the resource location module.</description> + + <dependencies> + <dependency> + <groupId>org.apache.tamaya</groupId> + <artifactId>tamaya-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-resources</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/Main.java ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/Main.java b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/Main.java new file mode 100644 index 0000000..db5cc3e --- /dev/null +++ b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/Main.java @@ -0,0 +1,73 @@ +/* + * 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.ext.examples.resources; + +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; + +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("Example for an property sources using a "); + System.out.println("descriptive resource path."); + 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(); + System.out.println("\tPath : " + cfg.get("Path")); + System.out.println("\taProp : " + cfg.get("aProp")); + 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-extensions/blob/5d867b00/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java new file mode 100644 index 0000000..b961121 --- /dev/null +++ b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java @@ -0,0 +1,39 @@ +/* + * 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.ext.examples.resources; + +import org.apache.tamaya.core.propertysource.SimplePropertySource; +import org.apache.tamaya.resource.AbstractPathPropertySourceProvider; +import org.apache.tamaya.spi.PropertySource; + +import java.net.URL; +import java.util.Arrays; +import java.util.Collection; + +public class MyPathPropertySourceProvider extends AbstractPathPropertySourceProvider { + + public MyPathPropertySourceProvider(){ + super("cfgOther/**/*.properties", "META-INF/MyOtherConfigProperties.*"); + } + + @Override + protected Collection<PropertySource> getPropertySources(URL url) { + return Arrays.asList(new PropertySource[]{new SimplePropertySource(url)}); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/package-info.java ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/package-info.java b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/package-info.java new file mode 100644 index 0000000..297b3d4 --- /dev/null +++ b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/package-info.java @@ -0,0 +1,23 @@ +/* + * 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 for an property sources using a descriptive resource path. + */ +package org.apache.tamaya.ext.examples.resources; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/META-INF/MyOtherConfigProperties.properties ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/META-INF/MyOtherConfigProperties.properties b/examples/01-resources-example/src/main/resources/META-INF/MyOtherConfigProperties.properties new file mode 100644 index 0000000..408a6e9 --- /dev/null +++ b/examples/01-resources-example/src/main/resources/META-INF/MyOtherConfigProperties.properties @@ -0,0 +1,21 @@ +# +# 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.description=A simple example now also loading its own files... + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/META-INF/javaconfiguration.properties ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/META-INF/javaconfiguration.properties b/examples/01-resources-example/src/main/resources/META-INF/javaconfiguration.properties new file mode 100644 index 0000000..a846e52 --- /dev/null +++ b/examples/01-resources-example/src/main/resources/META-INF/javaconfiguration.properties @@ -0,0 +1,25 @@ +# +# 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=simple-propertysource +example.description=A minimal example using an self written property source. +example.version=1 [email protected] + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/examples/01-resources-example/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider new file mode 100644 index 0000000..c0a9448 --- /dev/null +++ b/examples/01-resources-example/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider @@ -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.ext.examples.resources.MyPathPropertySourceProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/subs/a.properties ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/subs/a.properties b/examples/01-resources-example/src/main/resources/subs/a.properties new file mode 100644 index 0000000..069f8f1 --- /dev/null +++ b/examples/01-resources-example/src/main/resources/subs/a.properties @@ -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. +# +a=found A! \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/subs/b.properties ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/subs/b.properties b/examples/01-resources-example/src/main/resources/subs/b.properties new file mode 100644 index 0000000..9c2775b --- /dev/null +++ b/examples/01-resources-example/src/main/resources/subs/b.properties @@ -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. +# +b=found B! \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/01-resources-example/src/main/resources/subs/c.properties ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/resources/subs/c.properties b/examples/01-resources-example/src/main/resources/subs/c.properties new file mode 100644 index 0000000..7a2d8ee --- /dev/null +++ b/examples/01-resources-example/src/main/resources/subs/c.properties @@ -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. +# +c=found C! \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml new file mode 100644 index 0000000..d311f74 --- /dev/null +++ b/examples/pom.xml @@ -0,0 +1,44 @@ +<?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.ext</groupId> + <artifactId>tamaya-extensions-all</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + </parent> + + <groupId>org.apache.tamaya.ext.examples</groupId> + <artifactId>examples</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + + <name>Apache Tamaya Extensions Examples</name> + + <packaging>pom</packaging> + + <modules> + <module>01-resources-example</module> + </modules> + + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d867b00/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 097f22f..ebf83b4 100644 --- a/pom.xml +++ b/pom.xml @@ -204,6 +204,7 @@ under the License. </developers> <modules> + <module>examples</module> <module>modules</module> <module>distribution</module> </modules>
