ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [49/51] [abbrv] ignite git commit: IGNITE-2108 Fixed cache store examples.
Date Wed, 09 Dec 2015 11:24:31 GMT
IGNITE-2108 Fixed cache store examples.


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

Branch: refs/heads/ignite-843-rc2
Commit: e0ffc29593648391d7f45d7879451a687fca6e81
Parents: 5ea19a4
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Dec 9 17:52:02 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Dec 9 17:52:02 2015 +0700

----------------------------------------------------------------------
 .../java/org/apache/ignite/schema/Demo.java     |  6 ++-
 .../store/auto/CacheAutoStoreExample.java       | 49 ++++++++++----------
 2 files changed, 29 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e0ffc295/examples/schema-import/src/main/java/org/apache/ignite/schema/Demo.java
----------------------------------------------------------------------
diff --git a/examples/schema-import/src/main/java/org/apache/ignite/schema/Demo.java b/examples/schema-import/src/main/java/org/apache/ignite/schema/Demo.java
index a981f5a..a8934cb 100644
--- a/examples/schema-import/src/main/java/org/apache/ignite/schema/Demo.java
+++ b/examples/schema-import/src/main/java/org/apache/ignite/schema/Demo.java
@@ -41,11 +41,13 @@ public class Demo {
      * Constructs and returns a fully configured instance of a {@link CacheJdbcPojoStoreFactory}.
      */
     private static class H2DemoStoreFactory<K, V> extends CacheJdbcPojoStoreFactory<K,
V> {
-        /** Default constructor. */
-        H2DemoStoreFactory() {
+        /** {@inheritDoc} */
+        @Override public CacheJdbcPojoStore<K, V> create() {
             setDialect(new H2Dialect());
 
             setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/~/schema-import/demo",
"sa", ""));
+
+            return super.create();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e0ffc295/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
index 5498e57..7d21fce 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
@@ -65,30 +65,9 @@ public class CacheAutoStoreExample {
     private static final class CacheJdbcPojoStoreExampleFactory extends CacheJdbcPojoStoreFactory<Long,
Person> {
         /** {@inheritDoc} */
         @Override public CacheJdbcPojoStore<Long, Person> create() {
-            JdbcType jdbcType = new JdbcType();
+            setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb",
"sa", ""));
 
-            jdbcType.setCacheName(CACHE_NAME);
-            jdbcType.setDatabaseSchema("PUBLIC");
-            jdbcType.setDatabaseTable("PERSON");
-
-            jdbcType.setKeyType("java.lang.Long");
-            jdbcType.setKeyFields(new JdbcTypeField(Types.BIGINT, "ID", Long.class, "id"));
-
-            jdbcType.setValueType("org.apache.ignite.examples.model.Person");
-            jdbcType.setValueFields(
-                    new JdbcTypeField(Types.BIGINT, "ID", Long.class, "id"),
-                    new JdbcTypeField(Types.VARCHAR, "FIRST_NAME", String.class, "firstName"),
-                    new JdbcTypeField(Types.VARCHAR, "LAST_NAME", String.class, "lastName")
-            );
-
-            CacheJdbcPojoStore<Long, Person> store = new CacheJdbcPojoStore<>();
-
-            store.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb",
"sa", ""));
-            store.setDialect(new H2Dialect());
-
-            store.setTypes(jdbcType);
-
-            return store;
+            return super.create();
         }
     }
 
@@ -98,7 +77,29 @@ public class CacheAutoStoreExample {
     private static CacheConfiguration<Long, Person> cacheConfiguration() {
         CacheConfiguration<Long, Person> cfg = new CacheConfiguration<>(CACHE_NAME);
 
-        cfg.setCacheStoreFactory(new CacheJdbcPojoStoreExampleFactory());
+        CacheJdbcPojoStoreExampleFactory storeFactory = new CacheJdbcPojoStoreExampleFactory();
+
+        storeFactory.setDialect(new H2Dialect());
+
+        JdbcType jdbcType = new JdbcType();
+
+        jdbcType.setCacheName(CACHE_NAME);
+        jdbcType.setDatabaseSchema("PUBLIC");
+        jdbcType.setDatabaseTable("PERSON");
+
+        jdbcType.setKeyType("java.lang.Long");
+        jdbcType.setKeyFields(new JdbcTypeField(Types.BIGINT, "ID", Long.class, "id"));
+
+        jdbcType.setValueType("org.apache.ignite.examples.model.Person");
+        jdbcType.setValueFields(
+            new JdbcTypeField(Types.BIGINT, "ID", Long.class, "id"),
+            new JdbcTypeField(Types.VARCHAR, "FIRST_NAME", String.class, "firstName"),
+            new JdbcTypeField(Types.VARCHAR, "LAST_NAME", String.class, "lastName")
+        );
+
+        storeFactory.setTypes(jdbcType);
+
+        cfg.setCacheStoreFactory(storeFactory);
 
         // Set atomicity as transaction, since we are showing transactions in the example.
         cfg.setAtomicityMode(TRANSACTIONAL);


Mime
View raw message