You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:47:23 UTC

[GitHub] [ignite-extensions] ololo3000 commented on a change in pull request #26: IGNITE-13519 Adds Spring Data thin client support.

ololo3000 commented on a change in pull request #26:
URL: https://github.com/apache/ignite-extensions/pull/26#discussion_r516110159



##########
File path: modules/spring-data-2.2-ext/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteCacheProxy.java
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.springdata22.repository.support;
+
+import java.util.Map;
+import java.util.Set;
+import javax.cache.Cache;
+import javax.cache.expiry.ExpiryPolicy;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.Query;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.client.ClientCache;
+
+/** Reperesents Ignite cache operations required by Spring Data. */
+public interface IgniteCacheProxy<K, V> extends Iterable<Cache.Entry<K, V>> {

Review comment:
       Done. Proxy classes were moved to ignite-spring-data-connector module.

##########
File path: modules/spring-data-2.2-ext/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
##########
@@ -89,29 +96,37 @@ public IgniteRepositoryFactory(ApplicationContext ctx) {
     }
 
     /** */
-    private Ignite igniteForRepoConfig(RepositoryConfig config) {
+    private IgniteProxy igniteForRepoConfig(RepositoryConfig config) {
         try {
-            String igniteInstanceName = evaluateExpression(config.igniteInstance());
-            return (Ignite)ctx.getBean(igniteInstanceName);
+            Object igniteInstanceBean = ctx.getBean(evaluateExpression(config.igniteInstance()));
+
+            if (igniteInstanceBean instanceof Ignite)
+                return new IgniteProxyImpl((Ignite)igniteInstanceBean);
+            else if (igniteInstanceBean instanceof IgniteClient)
+                return new IgniteClientProxy((IgniteClient)igniteInstanceBean);
+
+            throw new IllegalStateException("Invalid repository configuration. The Spring Bean corresponding to the" +
+                " \"igniteInstance\" property of repository configuration must be one of the following types:" +
+                " \"org.apache.ignite.Ignite\", \"org.apache.ignite.client.IgniteClient\"");
         }
         catch (BeansException ex) {
             try {
                 String igniteConfigName = evaluateExpression(config.igniteCfg());
                 IgniteConfiguration cfg = (IgniteConfiguration)ctx.getBean(igniteConfigName);
                 try {
                     // first try to attach to existing ignite instance
-                    return Ignition.ignite(cfg.getIgniteInstanceName());
+                    return new IgniteProxyImpl(Ignition.ignite(cfg.getIgniteInstanceName()));
                 }
                 catch (Exception ignored) {
                     // nop
                 }
-                return Ignition.start(cfg);
+                return new IgniteProxyImpl(Ignition.start(cfg));

Review comment:
       Done.

##########
File path: modules/spring-data-2.2-ext/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteCacheProxy.java
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.springdata22.repository.support;
+
+import java.util.Map;
+import java.util.Set;
+import javax.cache.Cache;
+import javax.cache.expiry.ExpiryPolicy;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.Query;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.client.ClientCache;
+
+/** Reperesents Ignite cache operations required by Spring Data. */
+public interface IgniteCacheProxy<K, V> extends Iterable<Cache.Entry<K, V>> {

Review comment:
       Done. Proxy classes were moved to ignite-spring-data-proxy module.

##########
File path: modules/spring-data-2.2-ext/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
##########
@@ -237,7 +260,14 @@ private IgniteCache getRepositoryCache(Class<?> repoIf) {
                     + ".config.Query annotation.");
             }
 
-            return new IgniteRepositoryQuery(ignite, metadata, IgniteQueryGenerator.generateSql(mtd, metadata), mtd,
+            IgniteQuery qry = IgniteQueryGenerator.generateSql(mtd, metadata);
+
+            if (qry.isTextQuery() && isThinClient) {

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org