ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [2/3] incubator-ignite git commit: ignite-45: fix for ignite-507
Date Fri, 20 Mar 2015 14:35:29 GMT
ignite-45: fix for ignite-507


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

Branch: refs/heads/ignite-45
Commit: 8bdc67adf238899a44f236cf2bf6b295421b1116
Parents: d85fe36
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Mar 20 17:35:08 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Mar 20 17:35:08 2015 +0300

----------------------------------------------------------------------
 .../store/CacheNodeWithStoreStartup.java        | 44 ++++++++++++--------
 1 file changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8bdc67ad/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java
b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java
index a35fa41..0edf591 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java
@@ -90,28 +90,38 @@ public class CacheNodeWithStoreStartup {
         // Set atomicity as transaction, since we are showing transactions in example.
         cacheCfg.setAtomicityMode(TRANSACTIONAL);
 
-        CacheStore<Long, Person> store;
+        cacheCfg.setCacheStoreFactory(new Factory<CacheStore<? super Long, ? super
Person>>() {
+            @Override public CacheStore<? super Long, ? super Person> create() {
+                CacheStore<Long, Person> store;
 
-        switch (STORE) {
-            case DUMMY:
-                store = new CacheDummyPersonStore();
-                break;
+                switch (STORE) {
+                    case DUMMY:
+                        store = new CacheDummyPersonStore();
+                        break;
 
-            case SIMPLE_JDBC:
-                store = new CacheJdbcPersonStore();
-                break;
+                    case SIMPLE_JDBC:
+                        store = new CacheJdbcPersonStore();
+                        break;
 
-            case HIBERNATE:
-                store = new CacheHibernatePersonStore();
-                break;
+                    case HIBERNATE:
+                        store = new CacheHibernatePersonStore();
+                        break;
 
-            default:
-                store = new CacheJdbcPojoPersonStore();
-                cacheCfg.setTypeMetadata(typeMetadata());
-                break;
-        }
+                    default:
+                        if (!STORE.equals(AUTO))
+                            throw new IllegalStateException("Unexpected store configured:
" + STORE);
+
+                        store = new CacheJdbcPojoPersonStore();
+                        break;
+                }
+
+                return store;
+            }
+        });
+
+        if (STORE.equals(AUTO))
+            cacheCfg.setTypeMetadata(typeMetadata());
 
-        cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(store));
         cacheCfg.setReadThrough(true);
         cacheCfg.setWriteThrough(true);
 


Mime
View raw message