alex-plekhanov commented on a change in pull request #46:
URL: https://github.com/apache/ignite-extensions/pull/46#discussion_r583646398
##########
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:
I'm not sure if this method can be invoked concurrently, but if it can,
it's better to make it synchronized since there can be a race between name
modification and cache creation.
##########
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.
Review comment:
The line is too long.
----------------------------------------------------------------
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]