ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [26/26] ignite git commit: IGNITE-2832 Fixed Review notes.
Date Fri, 13 May 2016 09:40:26 GMT
IGNITE-2832 Fixed Review notes.


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

Branch: refs/heads/ignite-2832
Commit: f6d730b99544995360b745f13e68cb10ffc22b38
Parents: c1b69a9
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri May 13 16:39:43 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri May 13 16:39:43 2016 +0700

----------------------------------------------------------------------
 .../java/org/apache/ignite/schema/Demo.java     | 23 +++----------
 .../ignite/schema/H2DataSourceFactory.java      | 35 ++++++++++++++++++++
 .../store/jdbc/CacheJdbcPojoStoreFactory.java   |  4 +++
 .../cache/store/jdbc/H2DataSourceFactory.java   | 17 ++++++++++
 .../src/test/config/jdbc-pojo-store-builtin.xml | 17 +++++++++-
 .../src/test/config/jdbc-pojo-store-obj.xml     | 17 +++++++++-
 .../store/jdbc/CachePojoStoreXmlSelfTest.java   | 17 ++++++++++
 .../cache/store/jdbc/H2DataSourceFactory.java   | 18 ----------
 8 files changed, 110 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/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 a8934cb..fa52a1d 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
@@ -24,10 +24,8 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory;
-import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.transactions.Transaction;
-import org.h2.jdbcx.JdbcConnectionPool;
 
 /**
  * This demo demonstrates the use of cache with {@link CacheJdbcPojoStore}
@@ -38,20 +36,6 @@ import org.h2.jdbcx.JdbcConnectionPool;
  */
 public class Demo {
     /**
-     * Constructs and returns a fully configured instance of a {@link CacheJdbcPojoStoreFactory}.
-     */
-    private static class H2DemoStoreFactory<K, V> extends CacheJdbcPojoStoreFactory<K,
V> {
-        /** {@inheritDoc} */
-        @Override public CacheJdbcPojoStore<K, V> create() {
-            setDialect(new H2Dialect());
-
-            setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/~/schema-import/demo",
"sa", ""));
-
-            return super.create();
-        }
-    }
-
-    /**
      * Executes demo.
      *
      * @param args Command line arguments, none required.
@@ -62,9 +46,12 @@ public class Demo {
 
         // Start Ignite node.
         try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            CacheJdbcPojoStoreFactory<PersonKey, Person> pojoStoreFactory = new CacheJdbcPojoStoreFactory<>();
+
+            pojoStoreFactory.setDataSourceFactory(new H2DataSourceFactory());
+
             // Configure cache store.
-            CacheConfiguration<PersonKey, Person> cfg =
-                CacheConfig.cache("PersonCache", new H2DemoStoreFactory<PersonKey, Person>());
+            CacheConfiguration<PersonKey, Person> cfg = CacheConfig.cache("PersonCache",
pojoStoreFactory);
 
             try (IgniteCache<PersonKey, Person> cache = ignite.getOrCreateCache(cfg))
{
                 // Preload cache from database.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/examples/schema-import/src/main/java/org/apache/ignite/schema/H2DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/examples/schema-import/src/main/java/org/apache/ignite/schema/H2DataSourceFactory.java
b/examples/schema-import/src/main/java/org/apache/ignite/schema/H2DataSourceFactory.java
new file mode 100644
index 0000000..6a4ea0a
--- /dev/null
+++ b/examples/schema-import/src/main/java/org/apache/ignite/schema/H2DataSourceFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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.ignite.schema;
+
+import javax.cache.configuration.Factory;
+import javax.sql.DataSource;
+import org.h2.jdbcx.JdbcConnectionPool;
+
+/**
+ * Datasource to use for store tests.
+ */
+public class H2DataSourceFactory implements Factory<DataSource> {
+    /** DB connection URL. */
+    private static final String DFLT_CONN_URL = "jdbc:h2:tcp://localhost/~/schema-import/demo";
+
+    /** {@inheritDoc} */
+    @Override public DataSource create() {
+        return JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
index d2d887e..0fca3ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
@@ -31,6 +31,10 @@ import org.apache.ignite.resources.SpringApplicationContextResource;
  * {@link Factory} implementation for {@link CacheJdbcPojoStore}.
  *
  * Use this factory to pass {@link CacheJdbcPojoStore} to {@link CacheConfiguration}.
+ * <p>
+ * Please note, that {@link CacheJdbcPojoStoreFactory#setDataSource(DataSource)} is deprecated
and
+ * {@link CacheJdbcPojoStoreFactory#setDataSourceFactory(Factory)} or
+ * {@link CacheJdbcPojoStoreFactory#setDataSourceBean(String)} should be used instead.
  *
  * <h2 class="header">Spring Example</h2>
  * <pre name="code" class="xml">

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
index d2feebb..e8f447a 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
@@ -1,3 +1,20 @@
+/*
+ * 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.ignite.cache.store.jdbc;
 
 import javax.cache.configuration.Factory;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml b/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
index c72c26d..3480ece 100644
--- a/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
+++ b/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
@@ -1,6 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- This configuration was generated by GridGain Web Console (04/25/2016 14:59) -->
+<!--
+  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.
+-->
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/config/jdbc-pojo-store-obj.xml b/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
index f628609..ee761d0 100644
--- a/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
+++ b/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
@@ -1,6 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- This configuration was generated by GridGain Web Console (04/25/2016 14:59) -->
+<!--
+  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.
+-->
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
index 19644d4..c712f88 100644
--- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
@@ -1,3 +1,20 @@
+/*
+ * 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.ignite.cache.store.jdbc;
 
 import java.net.URL;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f6d730b9/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
deleted file mode 100644
index d2feebb..0000000
--- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.ignite.cache.store.jdbc;
-
-import javax.cache.configuration.Factory;
-import javax.sql.DataSource;
-import org.h2.jdbcx.JdbcConnectionPool;
-
-/**
- * Datasource to use for store tests.
- */
-public class H2DataSourceFactory implements Factory<DataSource> {
-    /** DB connection URL. */
-    private static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
-
-    /** {@inheritDoc} */
-    @Override public DataSource create() {
-        return JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "");
-    }
-}


Mime
View raw message