Return-Path: X-Original-To: apmail-tamaya-commits-archive@minotaur.apache.org Delivered-To: apmail-tamaya-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75BD210010 for ; Fri, 13 Feb 2015 23:49:38 +0000 (UTC) Received: (qmail 3297 invoked by uid 500); 13 Feb 2015 23:49:38 -0000 Delivered-To: apmail-tamaya-commits-archive@tamaya.apache.org Received: (qmail 3275 invoked by uid 500); 13 Feb 2015 23:49:38 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 3266 invoked by uid 99); 13 Feb 2015 23:49:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 23:49:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 13 Feb 2015 23:49:36 +0000 Received: (qmail 3242 invoked by uid 99); 13 Feb 2015 23:49:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 23:49:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 52D93E07F2; Fri, 13 Feb 2015 23:49:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anatole@apache.org To: commits@tamaya.incubator.apache.org Date: Fri, 13 Feb 2015 23:49:16 -0000 Message-Id: <3d29f0c909be4e63b2aec3623c077037@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-tamaya git commit: Added ConfiguratoinFOrmats singleton to formats module. Moved commons-config related aspects into separate integration module. X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-tamaya Updated Branches: refs/heads/master c15fb1c64 -> bd9970692 http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd997069/modules/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java ---------------------------------------------------------------------- diff --git a/modules/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java b/modules/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java new file mode 100644 index 0000000..2f80977 --- /dev/null +++ b/modules/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java @@ -0,0 +1,60 @@ +/* + * 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.integration.commons; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.HierarchicalINIConfiguration; +import org.apache.commons.configuration.SubnodeConfiguration; +import org.apache.tamaya.ConfigException; +import org.apache.tamaya.format.ConfigurationData; +import org.apache.tamaya.format.ConfigurationDataBuilder; +import org.apache.tamaya.format.ConfigurationFormat; + +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * Implements a ini file format based on the APache Commons + * {@link org.apache.commons.configuration.HierarchicalINIConfiguration}. + */ +public class IniConfigurationFormat implements ConfigurationFormat { + + @Override + public ConfigurationData readConfiguration(URL url) { + ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(url, this); + try { + HierarchicalINIConfiguration commonIniConfiguration = new HierarchicalINIConfiguration(url); + for(String section:commonIniConfiguration.getSections()){ + SubnodeConfiguration sectionConfig = commonIniConfiguration.getSection(section); + Map properties = new HashMap<>(); + Iterator keyIter = sectionConfig.getKeys(); + while(keyIter.hasNext()){ + String key = keyIter.next(); + properties.put(key, sectionConfig.getString(key)); + } + builder.addProperties(section, properties); + } + } catch (ConfigurationException e) { + throw new ConfigException("Failed to parse ini-file format from " + url, e); + } + return builder.build(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd997069/modules/integration/pom.xml ---------------------------------------------------------------------- diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml index efc019d..105e0ac 100644 --- a/modules/integration/pom.xml +++ b/modules/integration/pom.xml @@ -23,7 +23,7 @@ under the License. tamaya-extensions-all org.apache.tamaya.ext - 0.1-SNAPSHOT + 0.1-incubating-SNAPSHOT .. pom @@ -34,6 +34,7 @@ under the License. cdi se + commons \ No newline at end of file