Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 b0dbe85ad -> fcfe5019d


# IGNITE-32 WIP: Store implementation: move functionality to base class.


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

Branch: refs/heads/ignite-32
Commit: fcfe5019d2518817bc596c6a73fae90758eabc78
Parents: b0dbe85
Author: AKuznetsov <[email protected]>
Authored: Tue Jan 13 12:48:04 2015 +0700
Committer: AKuznetsov <[email protected]>
Committed: Tue Jan 13 12:48:04 2015 +0700

----------------------------------------------------------------------
 .../grid/cache/store/auto/H2PojoCacheStore.java | 30 +------------
 .../grid/cache/store/auto/PojoCacheStore.java   | 47 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fcfe5019/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
 
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
index e439fa7..7198e8a 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
@@ -9,17 +9,14 @@
 
 package org.gridgain.grid.cache.store.auto;
 
-import org.apache.ignite.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.cache.store.*;
 import org.gridgain.grid.util.typedef.internal.*;
 
 import java.util.*;
 
 /**
- * {@link GridCacheStore} implementation stores objects in H2 database using 
mapping description.
+  * Store implementation for H2 database.
  */
-public class H2PojoCacheStore extends AutoCacheStore<Object, Object> {
+public class H2PojoCacheStore extends PojoCacheStore {
     /** {@inheritDoc} */
     @Override protected String putQuery(String tblName, Collection<String> 
keyCols, Collection<String> uniqCols) {
         return String.format("MERGE INTO %s (%s) KEY (%s) VALUES(%s)", 
tblName, mkString(uniqCols, ","),
@@ -27,29 +24,6 @@ public class H2PojoCacheStore extends AutoCacheStore<Object, 
Object> {
     }
 
     /** {@inheritDoc} */
-    @Override protected void buildTypeCache() throws IgniteCheckedException {
-        typesCache = U.newHashMap(typeMetadata.size());
-
-        for (GridCacheQueryTypeMetadata type : typeMetadata) {
-            Collection<String> excludeValCols = new 
LinkedHashSet<>(databaseColumns(type.getValueDescriptors()));
-
-            
excludeValCols.retainAll(databaseColumns(type.getKeyDescriptors()));
-
-            PojoJdbcMapper keyMapper = new PojoJdbcMapper(type.getKeyType(), 
type.getKeyDescriptors(),
-                Collections.<String>emptyList());
-
-            PojoJdbcMapper valMapper = new PojoJdbcMapper(type.getType(), 
type.getValueDescriptors(), excludeValCols);
-
-            typesCache.put(keyMapper.cls, new TypeCache(type, keyMapper, 
valMapper));
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object typeKey(Object key) {
-        return key.getClass();
-    }
-
-    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(H2PojoCacheStore.class, this, "passwd", passwd != 
null ? "*" : null);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fcfe5019/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoCacheStore.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoCacheStore.java
 
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoCacheStore.java
new file mode 100644
index 0000000..a349cb9
--- /dev/null
+++ 
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoCacheStore.java
@@ -0,0 +1,47 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.cache.store.auto;
+
+import org.apache.ignite.*;
+import org.gridgain.grid.cache.query.*;
+import org.gridgain.grid.cache.store.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.util.*;
+
+/**
+ * Base class for {@link GridCacheStore} that implementation backed by JDBC 
and POJO via reflection.
+ *
+ * This implementation stores objects in underlying database using java beans 
mapping description via reflection.
+ */
+public abstract class PojoCacheStore extends AutoCacheStore<Object, Object> {
+    /** {@inheritDoc} */
+    @Override protected void buildTypeCache() throws IgniteCheckedException {
+        typesCache = U.newHashMap(typeMetadata.size());
+
+        for (GridCacheQueryTypeMetadata type : typeMetadata) {
+            Collection<String> excludeValCols = new 
LinkedHashSet<>(databaseColumns(type.getValueDescriptors()));
+
+            
excludeValCols.retainAll(databaseColumns(type.getKeyDescriptors()));
+
+            PojoJdbcMapper keyMapper = new PojoJdbcMapper(type.getKeyType(), 
type.getKeyDescriptors(),
+                Collections.<String>emptyList());
+
+            PojoJdbcMapper valMapper = new PojoJdbcMapper(type.getType(), 
type.getValueDescriptors(), excludeValCols);
+
+            typesCache.put(keyMapper.cls, new TypeCache(type, keyMapper, 
valMapper));
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object typeKey(Object key) {
+        return key.getClass();
+    }
+}

Reply via email to