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



##########
File path: 
modules/spring-cache-ext/src/main/java/org/apache/ignite/cache/spring/IgniteClientSpringCacheManager.java
##########
@@ -150,44 +146,27 @@ public IgniteClientSpringCacheManager 
setClientConfiguration(ClientConfiguration
         return this;
     }
 
-    /** Gets Ignite cache configurations. */
-    public Collection<ClientCacheConfiguration> getCacheConfigurations() {
-        return ccfgs == null ? Collections.emptyList() : ccfgs.values();
+    /** Gets dynamic Ignite cache configuration template. */
+    public ClientCacheConfiguration getDynamicCacheConfiguration() {
+        return dynamicCacheCfg == null ? null : dynamicCacheCfg.setName(null); 
// To avoid copying the dynamic cache configuration each time as we only change 
its name.
     }
 
     /**
-     * Sets the Ignite cache configurations that will be used to start the 
Ignite cache with the name requested by
-     * the Spring Cache Framework if one does not exist. If configuration with 
the requested name
-     * is not found among the configurations specified by this method, the 
default configuration with the requested
-     * name will be used.
+     * Sets the Ignite cache configurations template that will be used to 
start the Ignite cache with the name
+     * requested by the Spring Cache Framework if one does not exist. Note 
that provided cache name will be erased and
+     * replaced with requested one.
      */
-    public IgniteClientSpringCacheManager 
setCacheConfigurations(ClientCacheConfiguration... cfgs) {
-        ccfgs = new HashMap<>();
-
-        for (ClientCacheConfiguration cfg : cfgs) {
-            String name = cfg.getName();
-
-            if (name == null)
-                throw new IllegalArgumentException("Cache name must not be 
null.");
-
-            ClientCacheConfiguration prev = ccfgs.putIfAbsent(name, cfg);
-
-            if (prev != null) {
-                throw new IllegalArgumentException("Multiple cache 
configurations with the same name are specified " +
-                    "[name=" + name + "]. Each cache configuration must have a 
unique name.");
-            }
-        }
+    public IgniteClientSpringCacheManager 
setDynamicCacheConfiguration(ClientCacheConfiguration dynamicCacheCfg) {
+        this.dynamicCacheCfg = dynamicCacheCfg;
 
         return this;
     }
 
     /** {@inheritDoc} */
     @Override protected SpringCache createCache(String name) {

Review comment:
       Leaving it unsynchronized anyway is too dangerous. I did not think about 
that. Thank you. Done.

##########
File path: 
modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteClientSpringCacheManagerTest.java
##########
@@ -0,0 +1,220 @@
+/*
+ * 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.spring;
+
+import org.apache.ignite.Ignition;
+import org.apache.ignite.client.ClientCacheConfiguration;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.junit.Test;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
+import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static 
org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT;
+
+/** Tests Spring Cache manager implementation that uses thin client to connect 
to the Ignite cluster. */
+public class IgniteClientSpringCacheManagerTest extends 
GridSpringCacheManagerAbstractTest {

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:
[email protected]


Reply via email to