![JAR search and dependency download from the Maven repository](/logo.png)
org.infinispan.server.tasks.admin.CacheGetOrCreateTask Maven / Gradle / Ivy
package org.infinispan.server.tasks.admin;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import org.infinispan.commons.api.CacheContainerAdmin;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.manager.EmbeddedCacheManager;
/**
* Admin operation to create a cache
* Parameters:
*
* - name the name of the cache to create
* - template the name of the template to use
* - configuration the XML configuration to use
* - flags any flags, e.g. PERMANENT
*
*
* @author Tristan Tarrant
* @since 9.2
*/
public class CacheGetOrCreateTask extends CacheCreateTask {
@Override
public String getTaskContextName() {
return "cache";
}
@Override
public String getTaskOperationName() {
return "getorcreate";
}
@Override
protected Void execute(EmbeddedCacheManager cacheManager, Map> parameters, EnumSet flags) {
String name = requireParameter(parameters, "name");
String template = getParameter(parameters, "template");
String configuration = getParameter(parameters, "configuration");
if (configuration != null) {
Configuration config = getConfigurationBuilder(name, configuration).build();
cacheManager.administration().withFlags(flags).getOrCreateCache(name, config);
} else {
cacheManager.administration().withFlags(flags).getOrCreateCache(name, template);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy