From 5781911058b753c1a583ac298a4fb0509262b28a Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 30 Aug 2019 17:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 ++++++ .../plugin/db/redis/RedisConnectionImpl.java | 4 ++-- .../fr/plugin/db/redis/core/DataWrapper.java | 7 +++--- .../redis/core/RedisDatabaseConnection.java | 16 +++++--------- .../fr/plugin/db/redis/core/RedisPool.java | 8 +++---- .../db/redis/core/RedisScriptTableData.java | 19 +++++++--------- .../plugin/db/redis/core/RedisTableData.java | 22 ++++++------------- .../db/redis/core/RedisTableDataModel.java | 14 +++++------- .../db/redis/core/order/OrderValue.java | 3 +-- .../core/order/impl/FormulaOrderValue.java | 15 +++++-------- .../core/order/impl/NumberOrderValue.java | 4 ++-- .../core/pool/RedisConnectionPoolConfig.java | 3 +-- .../core/pool/RedisConnectionProxyConfig.java | 3 +-- .../db/redis/core/visit/AbstractVisitor.java | 8 +++---- .../plugin/db/redis/core/visit/Visitor.java | 8 +++---- .../db/redis/core/visit/VisitorFactory.java | 17 ++++++++++---- .../db/redis/core/visit/impl/GetVisitor.java | 5 +++-- .../redis/core/visit/impl/HashGetVisitor.java | 3 ++- .../core/visit/impl/HashKeysVisitor.java | 6 ++--- .../core/visit/impl/HashMGetVisitor.java | 3 ++- .../db/redis/core/visit/impl/HashVisitor.java | 6 ++--- .../db/redis/core/visit/impl/KeysVisitor.java | 6 ++--- .../db/redis/core/visit/impl/ListVisitor.java | 6 ++--- .../db/redis/core/visit/impl/MGetVisitor.java | 8 +++---- .../db/redis/core/visit/impl/SetVisitor.java | 6 ++--- .../redis/core/visit/impl/ZRangeVisitor.java | 6 ++--- .../redis/help/client/RedisNashornClient.java | 3 +-- .../fr/plugin/db/redis/util/RedisUtils.java | 8 +++---- 28 files changed, 109 insertions(+), 115 deletions(-) diff --git a/pom.xml b/pom.xml index 6e911ce..e4bb588 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,13 @@ designer-base 10.0 + + com.fanruan.api + finekit + 1.0 + system + ${project.basedir}/lib/finekit-10.0-20190830.jar.jar + diff --git a/src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java b/src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java index e5fe036..4bbdcb8 100755 --- a/src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java +++ b/src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java @@ -1,12 +1,12 @@ package com.fr.plugin.db.redis; -import com.fr.data.impl.Connection; import com.fanruan.api.design.ui.container.BasicBeanPane; +import com.fr.data.impl.Connection; import com.fr.design.fun.impl.AbstractConnectionProvider; import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.plugin.db.redis.ui.RedisConnectionPane; -public class RedisConnectionImpl extends AbstractConnectionProvider { +public class RedisConnectionImpl extends AbstractConnectionProvider { @Override public int currentAPILevel() { diff --git a/src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java b/src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java index 95694f5..52ca809 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java +++ b/src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java @@ -1,12 +1,11 @@ package com.fr.plugin.db.redis.core; -import com.fanruan.api.util.GeneralKit; import com.fanruan.api.log.LogKit; -import com.fanruan.api.util.IOKit; +import com.fanruan.api.runtime.EnvKit; import com.fanruan.api.script.ScriptKit; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.util.IOKit; import com.fanruan.api.util.StringKit; -import com.fr.workspace.WorkContext; -import com.fanruan.api.runtime.EnvKit; import javax.script.ScriptEngine; import javax.script.ScriptException; diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java index 672973b..5b229c5 100755 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java @@ -1,22 +1,18 @@ package com.fr.plugin.db.redis.core; -import cpm.fanruan.api.conf.HolderKit; -import com.fanruan.api.conf.impl.ColConf; -import com.fr.data.impl.AbstractDatabaseConnection; -import com.fr.data.impl.Connection; +import com.fanruan.api.conf.HolderKit; import com.fanruan.api.i18n.I18nKit; -import com.fr.plugin.db.redis.core.emb.Redis; import com.fanruan.api.security.SecurityKit; import com.fanruan.api.util.ArrayKit; -import com.fanruan.api.util.TypeKit; import com.fanruan.api.util.StringKit; +import com.fanruan.api.util.TypeKit; +import com.fr.config.holder.Conf; +import com.fr.data.impl.AbstractDatabaseConnection; +import com.fr.data.impl.Connection; +import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.third.redis.clients.jedis.Jedis; -import com.fr.config.holder.Conf; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Set; diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java b/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java index 5004b06..a519ea0 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java @@ -1,8 +1,9 @@ package com.fr.plugin.db.redis.core; +import com.fanruan.api.log.LogKit; +import com.fanruan.api.util.StringKit; import com.fr.config.Configuration; import com.fr.config.holder.ConfigChangeListener; -import com.fanruan.api.log.LogKit; import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.impl.ProxyRedis; import com.fr.plugin.db.redis.core.emb.impl.SimpleRedis; @@ -11,10 +12,9 @@ import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig; import com.fr.ssh.jsch.JSch; import com.fr.ssh.jsch.JSchException; import com.fr.ssh.jsch.Session; -import com.fanruan.api.util.StringKit; import com.fr.third.redis.clients.jedis.Jedis; -import com.fanruan.api.redis.pool.JedisPool; -import com.fanruan.api.redis.pool.JedisPoolConfig; +import com.fr.third.redis.clients.jedis.JedisPool; +import com.fr.third.redis.clients.jedis.JedisPoolConfig; import com.fr.transaction.ValidateProxy; import java.util.Map; diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java index 26d9702..c2e4f9b 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java @@ -1,28 +1,25 @@ package com.fr.plugin.db.redis.core; -import com.fr.stable.ParameterProvider; -import com.fr.base.TableData; import com.fanruan.api.conf.HolderKit; +import com.fanruan.api.data.ConnectionKit; +import com.fanruan.api.log.LogKit; +import com.fanruan.api.util.StringKit; +import com.fanruan.api.xml.XmlKit; +import com.fr.base.TableData; +import com.fr.config.holder.Conf; import com.fr.config.holder.factory.XmlHolders; import com.fr.data.AbstractParameterTableData; -import com.fanruan.api.xml.XmlKit; import com.fr.data.impl.Connection; -import com.fanruan.api.database.nameDatabase.NameReference; -import com.fanruan.api.data.ConnectionKit; import com.fr.general.data.DataModel; -import com.fanruan.api.xml.XmlKit; import com.fr.intelli.record.Focus; -import com.fanruan.api.log.LogKit; import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.record.analyzer.EnableMetrics; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; -import com.fanruan.api.util.StringKit; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.config.holder.Conf; /** * @author richie @@ -75,7 +72,7 @@ public class RedisScriptTableData extends AbstractParameterTableData { @Focus(id = RedisConstants.PLUGIN_ID, text = "Plugin-Redis_Script_Table_Data") public DataModel createDataModel(Calculator calculator, int rowCount) { long start = System.currentTimeMillis(); - Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator)); + ParameterProvider[] ps = getParameters(calculator); Connection connection = database.get(); if (connection instanceof NameReference) { String name = ((NameReference) connection).getName(); @@ -86,7 +83,7 @@ public class RedisScriptTableData extends AbstractParameterTableData { orderValue == null ? 0 : orderValue.toIndex(calculator, ps), RedisUtils.calculateQuery(script.get(), ps), rowCount); - FineLoggerFactory.getLogger().info("Build data model spend time {} ms.", System.currentTimeMillis() - start); + LogKit.info("Build data model spend time {} ms.", System.currentTimeMillis() - start); return model; } } diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java index 02b9f1d..29d5bf4 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java @@ -1,34 +1,26 @@ package com.fr.plugin.db.redis.core; -import com.fr.stable.ParameterProvider; -import com.fr.base.TableData; import com.fanruan.api.conf.HolderKit; +import com.fanruan.api.data.ConnectionKit; +import com.fanruan.api.log.LogKit; +import com.fanruan.api.util.StringKit; +import com.fanruan.api.xml.XmlKit; +import com.fr.base.TableData; +import com.fr.config.holder.Conf; import com.fr.config.holder.factory.XmlHolders; import com.fr.data.AbstractParameterTableData; -import com.fanruan.api.xml.XmlKit; import com.fr.data.impl.Connection; -import com.fanruan.api.database.nameDatabase.NameReference; -import com.fanruan.api.data.ConnectionKit; import com.fr.general.data.DataModel; -import com.fanruan.api.xml.XmlKit; import com.fr.intelli.record.Focus; import com.fr.intelli.record.Original; -import com.fanruan.api.log.LogKit; import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.record.analyzer.EnableMetrics; import com.fr.script.Calculator; -import com.fanruan.api.util.ArrayKit; -import com.fanruan.api.util.StringKit; import com.fr.stable.ParameterProvider; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.config.holder.Conf; - - -import java.util.HashMap; -import java.util.Map; @EnableMetrics @@ -85,7 +77,7 @@ public class RedisTableData extends AbstractParameterTableData { @Focus(id = RedisConstants.PLUGIN_ID, text = "Plugin-Redis_DB", source = Original.PLUGIN) public DataModel createDataModel(Calculator calculator, int rowCount) { long start = System.currentTimeMillis(); - Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator)); + ParameterProvider[] ps = getParameters(calculator); Connection connection = database.get(); if (connection instanceof NameReference) { String name = ((NameReference) connection).getName(); diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java b/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java index 1f4a306..06a99e2 100755 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java @@ -1,15 +1,13 @@ package com.fr.plugin.db.redis.core; -import com.fr.stable.ParameterProvider; -import com.fr.data.AbstractDataModel; import com.fanruan.api.log.LogKit; import com.fanruan.api.runtime.PluginKit; +import com.fanruan.api.util.StringKit; +import com.fr.data.AbstractDataModel; import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.visit.VisitorFactory; -import com.fr.plugin.db.redis.util.RedisUtils; -import com.fr.script.Calculator; -import com.fanruan.api.util.StringKit; -import com.fr.third.redis.clients.jedis.Jedis; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import java.util.List; @@ -17,7 +15,7 @@ public class RedisTableDataModel extends AbstractDataModel { private String[] columnNames; private List> data; - public RedisTableDataModel(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) { + public RedisTableDataModel(CalculatorProvider calculator, ParameterProvider[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) { if (PluginKit.isCurrentPluginAvailable()) { initRedisData(calculator, ps, mc, dbIndex, query, script, rowCount); } else { @@ -25,7 +23,7 @@ public class RedisTableDataModel extends AbstractDataModel { } } - private synchronized void initRedisData(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) { + private synchronized void initRedisData(CalculatorProvider calculator, ParameterProvider[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) { if (StringKit.isEmpty(query)) { return; } diff --git a/src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java b/src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java index 14064b7..d40737d 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java +++ b/src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java @@ -1,6 +1,5 @@ package com.fr.plugin.db.redis.core.order; -import com.fr.stable.ParameterProvider; import com.fanruan.api.conf.BaseUniqueKey; import com.fanruan.api.util.GeneralKit; import com.fr.script.Calculator; @@ -17,7 +16,7 @@ public abstract class OrderValue extends BaseUniqueKey implements XMLable { public abstract Object getValue(); - public abstract int toIndex(Calculator cal, Parameter[] ps); + public abstract int toIndex(Calculator cal, ParameterProvider[] ps); public ParameterProvider[] analyze4Parameters() { return new ParameterProvider[0]; diff --git a/src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java b/src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java index c6056ed..14e2e01 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java +++ b/src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java @@ -1,17 +1,14 @@ package com.fr.plugin.db.redis.core.order.impl; -import com.fr.base.BaseFormula; import com.fanruan.api.cal.FormulaKit; -import com.fr.stable.ParameterProvider; import com.fanruan.api.cal.ParameterKit; -import com.fanruan.api.util.GeneralKit; import com.fanruan.api.log.LogKit; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.util.StringKit; +import com.fr.base.BaseFormula; import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; -import com.fanruan.api.util.StringKit; -import com.fanruan.api.cal.ParameterKit; -import com.fanruan.api.util.err.UtilEvalError; import com.fr.stable.script.NameSpace; import com.fr.stable.xml.XMLableReader; @@ -37,12 +34,12 @@ public class FormulaOrderValue extends OrderValue { } @Override - public int toIndex(Calculator cal, Parameter[] ps) { - NameSpace nameSpace = ParameterKit.createParameterProvider(ps); + public int toIndex(Calculator cal, ParameterProvider[] ps) { + NameSpace nameSpace = ParameterKit.createParameterMapNameSpace(ps); cal.pushNameSpace(nameSpace); try { return GeneralKit.objectToNumber(formula.eval(cal)).intValue(); - } catch (UtilEvalError u) { + } catch (Exception u) { LogKit.error(u.getMessage(), u); } finally { cal.removeNameSpace(nameSpace); diff --git a/src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java b/src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java index 0b655b0..f03846a 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java +++ b/src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.order.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; import com.fr.stable.xml.XMLableReader; public class NumberOrderValue extends OrderValue { @@ -24,7 +24,7 @@ public class NumberOrderValue extends OrderValue { } @Override - public int toIndex(Calculator cal, Parameter[] ps) { + public int toIndex(Calculator cal, ParameterProvider[] ps) { return getValue(); } diff --git a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java index bcabc7c..36d4f74 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java +++ b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java @@ -1,6 +1,5 @@ package com.fr.plugin.db.redis.core.pool; -import com.fr.config.ConfigContext; import com.fanruan.api.conf.BaseConfiguration; import com.fanruan.api.conf.HolderKit; import com.fr.config.holder.Conf; @@ -17,7 +16,7 @@ public class RedisConnectionPoolConfig extends BaseConfiguration { public static RedisConnectionPoolConfig getInstance() { if (instance == null) { - instance = ConfigContext.getConfigInstance(RedisConnectionPoolConfig.class); + instance = getConfigInstance(RedisConnectionPoolConfig.class); } return instance; } diff --git a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java index 1800ebd..5eb5509 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java +++ b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java @@ -1,6 +1,5 @@ package com.fr.plugin.db.redis.core.pool; -import com.fr.config.ConfigContext; import com.fanruan.api.conf.BaseConfiguration; import com.fanruan.api.conf.HolderKit; import com.fanruan.api.security.SecurityKit; @@ -18,7 +17,7 @@ public class RedisConnectionProxyConfig extends BaseConfiguration { public static RedisConnectionProxyConfig getInstance() { if (instance == null) { - instance = ConfigContext.getConfigInstance(RedisConnectionProxyConfig.class); + instance = getConfigInstance(RedisConnectionProxyConfig.class); } return instance; } diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java index a628046..a7082dd 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java @@ -1,10 +1,10 @@ package com.fr.plugin.db.redis.core.visit; -import com.fr.stable.ParameterProvider; +import com.fanruan.api.util.StringKit; import com.fr.plugin.db.redis.core.DataWrapper; import com.fr.plugin.db.redis.core.RedisConstants; -import com.fr.script.Calculator; -import com.fanruan.api.util.StringKit; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; /** @@ -13,7 +13,7 @@ import com.fr.third.redis.clients.jedis.Jedis; public abstract class AbstractVisitor implements Visitor { @Override - public DataWrapper buildData(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public DataWrapper buildData(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { return DataWrapper.create(getContent(calculator, ps, client, query, rowCount), RedisConstants.DEFAULT_COLUMN_NAMES); } diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java index 9e471d8..8ab1ef8 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.visit; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.DataWrapper; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.List; @@ -14,9 +14,9 @@ public interface Visitor { String TOKEN_SPACE = "\\s+"; - List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception; + List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception; - DataWrapper buildData(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception; + DataWrapper buildData(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception; boolean match(String query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java b/src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java index 3a8710e..e7c170a 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java @@ -1,9 +1,18 @@ package com.fr.plugin.db.redis.core.visit; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.DataWrapper; -import com.fr.plugin.db.redis.core.visit.impl.*; -import com.fr.script.Calculator; +import com.fr.plugin.db.redis.core.visit.impl.GetVisitor; +import com.fr.plugin.db.redis.core.visit.impl.HashGetVisitor; +import com.fr.plugin.db.redis.core.visit.impl.HashKeysVisitor; +import com.fr.plugin.db.redis.core.visit.impl.HashMGetVisitor; +import com.fr.plugin.db.redis.core.visit.impl.HashVisitor; +import com.fr.plugin.db.redis.core.visit.impl.KeysVisitor; +import com.fr.plugin.db.redis.core.visit.impl.ListVisitor; +import com.fr.plugin.db.redis.core.visit.impl.MGetVisitor; +import com.fr.plugin.db.redis.core.visit.impl.SetVisitor; +import com.fr.plugin.db.redis.core.visit.impl.ZRangeVisitor; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -29,7 +38,7 @@ public class VisitorFactory { visitors.add(new KeysVisitor()); } - public static DataWrapper getKeyValueResult(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public static DataWrapper getKeyValueResult(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { Visitor visitor = getMatchedVisitor(query); if (visitor == null) { return DataWrapper.EMPTY; diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java index 5d7b67a..33e5d12 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java @@ -1,8 +1,9 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -10,7 +11,7 @@ import java.util.List; public class GetVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java index 367d961..f6b7e8d 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java @@ -3,6 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl; import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.script.Calculator; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -10,7 +11,7 @@ import java.util.List; public class HashGetVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 3) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java index 8cc815d..b58e383 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -11,7 +11,7 @@ import java.util.Set; public class HashKeysVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java index 83fc8dd..65c9f88 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java @@ -3,6 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl; import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.script.Calculator; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -10,7 +11,7 @@ import java.util.List; public class HashMGetVisitor extends AbstractVisitor{ @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 3) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java index 8fef35c..0f50786 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -14,7 +14,7 @@ import java.util.Map; */ public class HashVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java index ac8c265..4999d36 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -11,7 +11,7 @@ import java.util.Set; public class KeysVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java index 7b13510..b7b7c87 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java @@ -1,9 +1,9 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.base.TableData; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -14,7 +14,7 @@ import java.util.List; */ public class ListVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 4) { diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java index ea16cd8..8206ecb 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java @@ -1,9 +1,9 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; -import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; import com.fanruan.api.util.ArrayKit; +import com.fr.plugin.db.redis.core.visit.AbstractVisitor; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -14,7 +14,7 @@ import java.util.List; */ public class MGetVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java index 6b31c68..57867db 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java @@ -1,8 +1,8 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.util.ArrayList; @@ -15,7 +15,7 @@ import java.util.Set; public class SetVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 2) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java index 4309f90..ade180e 100644 --- a/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java +++ b/src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java @@ -1,9 +1,9 @@ package com.fr.plugin.db.redis.core.visit.impl; -import com.fr.stable.ParameterProvider; import com.fr.base.TableData; import com.fr.plugin.db.redis.core.visit.AbstractVisitor; -import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.stable.script.CalculatorProvider; import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Tuple; @@ -16,7 +16,7 @@ import java.util.Set; */ public class ZRangeVisitor extends AbstractVisitor { @Override - public List> getContent(Calculator calculator, Parameter[] ps, Jedis client, String query, int rowCount) throws Exception { + public List> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception { String[] arr = query.trim().split(TOKEN_SPACE); if (arr.length < 4) { throw new IllegalArgumentException("Illegal query:" + query); diff --git a/src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java b/src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java index 94d6632..50aec29 100644 --- a/src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java +++ b/src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java @@ -1,7 +1,7 @@ package com.fr.plugin.db.redis.help.client; -import com.fr.base.TableData; import com.fanruan.api.log.LogKit; +import com.fr.base.TableData; import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.help.Console; import com.fr.plugin.db.redis.help.ScriptBridge; @@ -11,7 +11,6 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java b/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java index 035a66b..854e487 100644 --- a/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java +++ b/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java @@ -1,10 +1,10 @@ package com.fr.plugin.db.redis.util; import com.eclipsesource.v8.V8Object; -import com.fr.stable.ParameterProvider; +import com.fanruan.api.util.ArrayKit; import com.fanruan.api.util.RenderKit; import com.fr.plugin.db.redis.help.ScriptBridge; -import com.fanruan.api.util.ArrayKit; +import com.fr.stable.ParameterProvider; import com.fr.third.redis.clients.jedis.Jedis; import java.lang.reflect.Method; @@ -26,12 +26,12 @@ public class RedisUtils { jedis.close(); } - public static String calculateQuery(String query, Parameter[] ps) { + public static String calculateQuery(String query, ParameterProvider[] ps) { if (ArrayKit.isEmpty(ps)) { return query; } Map map = new HashMap(); - for (Parameter p : ps) { + for (ParameterProvider p : ps) { map.put(p.getName(), p.getValue()); } try {