[
https://issues.apache.org/jira/browse/KARAF-6017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624537#comment-17624537
]
ASF GitHub Bot commented on KARAF-6017:
---------------------------------------
awrb commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005817727
##########
cache/commands/src/main/java/org/apache/karaf/cache/core/commands/Create.java:
##########
@@ -0,0 +1,39 @@
+package org.apache.karaf.cache.core.commands;
+
+import org.apache.karaf.cache.api.CacheService;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+import javax.cache.configuration.Configuration;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+
+@Service
+@Command(scope = "cache", name = "create", description = "")
+public class Create implements Action {
+
+ @Argument(index = 0, required = true)
+ String cacheName;
+ @Argument(index = 1, required = true)
+ String keyType;
+ @Argument(index = 2, required = true)
+ String valueType;
+ @Reference
+ private CacheService cacheService;
+
+ @Override
+ public Object execute() throws Exception {
+ Class keyClass = Class.forName(keyType);
+ Class valueClass = Class.forName(valueType);
+ Configuration<?, ?> configuration = new MutableConfiguration<>()
Review Comment:
This is just hard-coded for now but I'll extend this (add arguments to
specify the cache size, or the xml configuration path, probably make the
key/value type resolution smarter, so something like `cache:create myCache long
string <other args>` also works).
> Provide cache service
> ---------------------
>
> Key: KARAF-6017
> URL: https://issues.apache.org/jira/browse/KARAF-6017
> Project: Karaf
> Issue Type: New Feature
> Components: karaf
> Reporter: Jean-Baptiste Onofré
> Priority: Major
>
> Similar to the scheduler feature we have in Karaf (façading quartz), we could
> provide a cache service (façading ehcache).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)