TAMAYA-236: improve ordinal handling.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/065f5726 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/065f5726 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/065f5726 Branch: refs/heads/master Commit: 065f5726b45736e739224a9a59025334c1139c71 Parents: 26038c4 Author: anatole <[email protected]> Authored: Thu Feb 23 01:01:37 2017 +0100 Committer: anatole <[email protected]> Committed: Mon Feb 27 00:05:00 2017 +0100 ---------------------------------------------------------------------- .../commons/CommonsConfigPropertySource.java | 3 - .../hazelcast/HazelcastPropertySource.java | 4 +- .../ConfigDirPropertySourceProvider.java | 3 +- .../FileProprtyStoreProviderSpi.java | 85 ------------------- .../HazelcastProprtyStoreProviderSpi.java | 87 -------------------- .../MetainfConfigPropertySourceProvider.java | 3 +- .../tamaya/remote/BaseRemotePropertySource.java | 3 +- 7 files changed, 6 insertions(+), 182 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/apache-commons/src/main/java/org/apache/tamaya/commons/CommonsConfigPropertySource.java ---------------------------------------------------------------------- diff --git a/apache-commons/src/main/java/org/apache/tamaya/commons/CommonsConfigPropertySource.java b/apache-commons/src/main/java/org/apache/tamaya/commons/CommonsConfigPropertySource.java index 4aa47ad..8e8ea2f 100644 --- a/apache-commons/src/main/java/org/apache/tamaya/commons/CommonsConfigPropertySource.java +++ b/apache-commons/src/main/java/org/apache/tamaya/commons/CommonsConfigPropertySource.java @@ -18,8 +18,6 @@ */ package org.apache.tamaya.commons; -//X TODO Move out into separate commons-config integration module... - import org.apache.commons.configuration.Configuration; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; @@ -54,7 +52,6 @@ public class CommonsConfigPropertySource implements PropertySource { } } - @Override public int getOrdinal() { return ordinal; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java ---------------------------------------------------------------------- diff --git a/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java b/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java index facd642..bce24fa 100644 --- a/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java +++ b/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java @@ -24,7 +24,6 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IList; import com.hazelcast.core.IMap; import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.mutableconfig.Refreshable; import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; import org.apache.tamaya.spi.PropertyValue; import org.apache.tamaya.spisupport.BasePropertySource; @@ -56,7 +55,7 @@ import java.util.logging.Logger; * instance of pass a Hazelcast configuration instance. */ public class HazelcastPropertySource extends BasePropertySource -implements Refreshable, MutablePropertySource{ +implements MutablePropertySource{ private static final Logger LOG = Logger.getLogger(HazelcastPropertySource.class.getName()); private Map<String, String> configMap = new HashMap<>(); @@ -128,7 +127,6 @@ implements Refreshable, MutablePropertySource{ return true; } - @Override public void refresh() { IMap<String,String> config = hazelcastInstance.getMap(mapReference); Map<String, String> configMap = new HashMap<>(config); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java index fc38c73..19a7dfb 100644 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java +++ b/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java @@ -34,7 +34,8 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by Anatole on 20.03.2015. + * A property provider implementation that tries to read all files in a directory as + * configuration. */ public class ConfigDirPropertySourceProvider extends AbstractPathPropertySourceProvider { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/propertysources/src/main/java/org/apache/tamaya/propertysources/FileProprtyStoreProviderSpi.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/FileProprtyStoreProviderSpi.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/FileProprtyStoreProviderSpi.java deleted file mode 100644 index ea661e5..0000000 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/FileProprtyStoreProviderSpi.java +++ /dev/null @@ -1,85 +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 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.propertysources; -// -//import com.hazelcast.config.Config; -//import com.hazelcast.config.GroupConfig; -//import com.hazelcast.core.Hazelcast; -//import com.hazelcast.core.HazelcastInstance; -//import org.apache.tamaya.spi.ServiceContextManager; -//import org.apache.tamaya.store.PropertyStore; -//import org.apache.tamaya.store.spi.PropertyStoreProviderSpi; -// -//import java.util.Map; -//import java.util.ServiceLoader; -//import java.util.concurrent.ConcurrentHashMap; -//import java.util.logging.Level; -//import java.util.logging.Logger; -// -///** -// * SPI implmentation for a providing Hazelcast based PropertyStores. -// */ -//public class FileProprtyStoreProviderSpi implements PropertyStoreProviderSpi { -// private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.file.configClass"; -// private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.file.groupName"; -// -// private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName()); -// -// private File file; -// private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>(); -// -// public HazelcastProprtyStoreProviderSpi() { -// String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP); -// Config config = null; -// if(customConfig!=null){ -// try { -// config = (Config)Class.forName(customConfig).newInstance(); -// LOG.info("Successfully created custom store config for HazelCast store: " + customConfig); -// } catch (Exception e) { -// LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e); -// } -// } -// if(config==null){ -// config = ServiceContextManager.getServiceContext().getService(Config.class); -// } -// if(config==null) { -// config = new Config(); -// GroupConfig gc = new GroupConfig(); -// String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya"); -// gc.setName(groupName); -// config.setGroupConfig(gc); -// } -// LOG.info("Starting HazelCast storage with config: " + config); -// store = Hazelcast.getOrCreateHazelcastInstance(config); -// } -// -// @Override -// public PropertyStore getPropertyStore(String storeId) { -// HazelcastProprtyStore propertyStore = stores.get(storeId); -// if(propertyStore==null){ -// LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "..."); -// propertyStore = new HazelcastProprtyStore(store, storeId); -// this.stores.put(storeId, propertyStore); -// } -// return propertyStore; -// } -// -// -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/propertysources/src/main/java/org/apache/tamaya/propertysources/HazelcastProprtyStoreProviderSpi.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/HazelcastProprtyStoreProviderSpi.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/HazelcastProprtyStoreProviderSpi.java deleted file mode 100644 index cdfcb77..0000000 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/HazelcastProprtyStoreProviderSpi.java +++ /dev/null @@ -1,87 +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 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.propertysources; -// -//import com.hazelcast.config.Config; -//import com.hazelcast.config.GroupConfig; -//import com.hazelcast.core.Hazelcast; -//import com.hazelcast.core.HazelcastInstance; -//import org.apache.tamaya.spi.ServiceContextManager; -//import org.apache.tamaya.store.PropertyStore; -//import org.apache.tamaya.store.spi.PropertyStoreProviderSpi; -// -//import java.util.Map; -//import java.util.ServiceLoader; -//import java.util.concurrent.ConcurrentHashMap; -//import java.util.logging.Level; -//import java.util.logging.Logger; -// -///** -// * SPI implmentation for a providing Hazelcast based PropertyStores. -// */ -//public class HazelcastProprtyStoreProviderSpi implements PropertyStoreProviderSpi { -// private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.hazelcast.configClass"; -// private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.hazelcast.groupName"; -// -// -// -// private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName()); -// -// private HazelcastInstance store; -// private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>(); -// -// public HazelcastProprtyStoreProviderSpi() { -// String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP); -// Config config = null; -// if(customConfig!=null){ -// try { -// config = (Config)Class.forName(customConfig).newInstance(); -// LOG.info("Successfully created custom store config for HazelCast store: " + customConfig); -// } catch (Exception e) { -// LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e); -// } -// } -// if(config==null){ -// config = ServiceContextManager.getServiceContext().getService(Config.class); -// } -// if(config==null) { -// config = new Config(); -// GroupConfig gc = new GroupConfig(); -// String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya"); -// gc.setName(groupName); -// config.setGroupConfig(gc); -// } -// LOG.info("Starting HazelCast storage with config: " + config); -// store = Hazelcast.getOrCreateHazelcastInstance(config); -// } -// -// @Override -// public PropertyStore getPropertyStore(String storeId) { -// HazelcastProprtyStore propertyStore = stores.get(storeId); -// if(propertyStore==null){ -// LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "..."); -// propertyStore = new HazelcastProprtyStore(store, storeId); -// this.stores.put(storeId, propertyStore); -// } -// return propertyStore; -// } -// -// -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java index d86f3fd..fe5759f 100644 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java +++ b/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java @@ -34,7 +34,8 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Created by Anatole on 20.03.2015. + * Property source provider that reads all resources from {@code META-INF/config/**} + * into configuration sources.. */ public class MetainfConfigPropertySourceProvider extends AbstractPathPropertySourceProvider { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/065f5726/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java ---------------------------------------------------------------------- diff --git a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java index 0fd1c67..19bebb5 100644 --- a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java +++ b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java @@ -65,7 +65,7 @@ public abstract class BaseRemotePropertySource implements PropertySource{ ConfigurationFormat format = getConfigurationFormat(); for(URL url:getAccessURLs()) { try(InputStream is = url.openStream()) { - ConfigurationData data = format.readConfiguration(url.toExternalForm(), is); + ConfigurationData data = format.readConfiguration(url); if(data!=null){ Map<String,String> newProperties = mapConfigurationData(data); // the configs served by the tamaya server module has a 'data' root section containing the @@ -124,7 +124,6 @@ public abstract class BaseRemotePropertySource implements PropertySource{ return PropertyValue.of(key,getProperties().get(key),getName()); } - @Override public int getOrdinal(){ PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); if(configuredOrdinal!=null){
