tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [18/50] [abbrv] incubator-tamaya-sandbox git commit: Fixed further issues from quality gates.
Date Tue, 06 Sep 2016 17:18:14 GMT
Fixed further issues from quality gates.


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/56f3d99f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/56f3d99f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/56f3d99f

Branch: refs/heads/master
Commit: 56f3d99f496588c4c1886002d30eeaedc802b674
Parents: 33dc999
Author: anatole <anatole@apache.org>
Authored: Sun Jan 10 02:14:41 2016 +0100
Committer: anatole <anatole@apache.org>
Committed: Sun Jan 10 02:14:41 2016 +0100

----------------------------------------------------------------------
 .../META-INF/javaconfiguration.properties       | 27 ++++---
 .../internal/FileProprtyStoreProviderSpi.java   | 85 ++++++++++++++++++++
 2 files changed, 99 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/56f3d99f/collections/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/collections/src/test/resources/META-INF/javaconfiguration.properties b/collections/src/test/resources/META-INF/javaconfiguration.properties
index 5cae030..9848617 100644
--- a/collections/src/test/resources/META-INF/javaconfiguration.properties
+++ b/collections/src/test/resources/META-INF/javaconfiguration.properties
@@ -16,35 +16,36 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+# Similar to etcd all keys starting with a _ are hidden by default (only directly accessible).
 
 # Examples for collection syntax
 
 list=a,b,c
-list.{collection-type}=List
+_list.collection-type=List
 #list.{collection-combinationPolicy}=MyLeftAppendingCombinationPolicy
 
 arrayList=d;e;f
-arrayList.{collection-type}=java.util.ArrayList
-arrayList.{collection-separator}=;
-#arrayList.{collection-valueParser}=myParserClass
+_arrayList.collection-type=java.util.ArrayList
+_arrayList.collection-separator=;
+#_arrayList.collection-valueParser=myParserClass
 
 linkedList=g,h,i
-linkedList.{collection-type}=java.util.LinkedList
+_linkedList.collection-type=java.util.LinkedList
 
 set=a,b,b
-set.{collection-type}=java.util.Set
-set.{eval-combinationPolicy}=WarnOnDuplicates
+_set.collection-type=java.util.Set
+_set.eval-combinationPolicy=WarnOnDuplicates
 
 sortedSet=a,c,b
-sortedSet.{collection-type}=java.util.TreeSet
+_sortedSet.collection-type=java.util.TreeSet
 
 map=1:a,2:b,3:c
-map.{collection-type}=Map
-#map.{collection-keyParser}=myParserClass
-#map.{collection-valueParser}=myParserClass
+_map.collection-type=Map
+#_map.collection-keyParser=myParserClass
+#_map.collection-valueParser=myParserClass
 
 sortedMap=|3:c||1:a||2:b|
-sortedMap.{collection-type}=java.util.TreeMap
+_sortedMap.collection-type=java.util.TreeMap
 
 concurrentMap=|3:c||1:a||2:b|
-concurrentMap.{collection-type}=java.util.ConcurrentHashMap
\ No newline at end of file
+_concurrentMap.collection-type=java.util.ConcurrentHashMap
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/56f3d99f/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
b/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
new file mode 100644
index 0000000..3ea768a
--- /dev/null
+++ b/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
@@ -0,0 +1,85 @@
+/*
+ * 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.store.internal;
+
+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;
+    }
+
+
+
+}


Mime
View raw message