Browse Source

Merge branch 'master' of zhaojunzhe/demo-tabledata-redis into master

paid
richie 5 years ago committed by Gogs
parent
commit
7060bee95e
  1. BIN
      lib/finekit-10.0-20190828.jar
  2. 24
      pom.xml
  3. 4
      src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java
  4. 4
      src/main/java/com/fr/plugin/db/redis/RedisScriptTableDataDefine.java
  5. 20
      src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java
  6. 44
      src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
  7. 22
      src/main/java/com/fr/plugin/db/redis/core/RedisNode.java
  8. 20
      src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
  9. 32
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
  10. 40
      src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
  11. 12
      src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java
  12. 10
      src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java
  13. 27
      src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java
  14. 2
      src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java
  15. 20
      src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
  16. 26
      src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java
  17. 6
      src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java
  18. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java
  19. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java
  20. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java
  21. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java
  22. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java
  23. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java
  24. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java
  25. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java
  26. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java
  27. 6
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java
  28. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java
  29. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java
  30. 7
      src/main/java/com/fr/plugin/db/redis/help/Console.java
  31. 9
      src/main/java/com/fr/plugin/db/redis/help/Files.java
  32. 7
      src/main/java/com/fr/plugin/db/redis/help/client/BaseRedisClient.java
  33. 18
      src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java
  34. 16
      src/main/java/com/fr/plugin/db/redis/help/client/RedisV8Client.java
  35. 43
      src/main/java/com/fr/plugin/db/redis/ui/RedisBaseTableDataPane.java
  36. 47
      src/main/java/com/fr/plugin/db/redis/ui/RedisConnectionPane.java
  37. 42
      src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java
  38. 43
      src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java
  39. 30
      src/main/java/com/fr/plugin/db/redis/ui/RedisScriptPane.java
  40. 6
      src/main/java/com/fr/plugin/db/redis/ui/RedisScriptTableDataPane.java
  41. 10
      src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java
  42. 36
      src/main/java/com/fr/plugin/db/redis/ui/pool/RedisConnectionPoolConfigPane.java
  43. 45
      src/main/java/com/fr/plugin/db/redis/ui/proxy/RedisConnectionProxyConfigPane.java
  44. 18
      src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java
  45. 6
      src/main/java/com/fr/plugin/db/redis/ui/value/IndexValuePaneFactory.java
  46. 14
      src/main/java/com/fr/plugin/db/redis/ui/value/IntegerEditor.java
  47. 12
      src/main/java/com/fr/plugin/db/redis/util/RedisDesignUtils.java
  48. 10
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

BIN
lib/finekit-10.0-20190828.jar

Binary file not shown.

24
pom.xml

@ -42,4 +42,28 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project> </project>

4
src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java

@ -1,12 +1,12 @@
package com.fr.plugin.db.redis; package com.fr.plugin.db.redis;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.design.beans.BasicBeanPane; import com.fanruan.api.design.ui.container.BasicBeanPane;
import com.fr.design.fun.impl.AbstractConnectionProvider; import com.fr.design.fun.impl.AbstractConnectionProvider;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.ui.RedisConnectionPane; import com.fr.plugin.db.redis.ui.RedisConnectionPane;
public class RedisConnectionImpl extends AbstractConnectionProvider { public class RedisConnectionImpl extends AbstractConnectionProvider {
@Override @Override
public int currentAPILevel() { public int currentAPILevel() {

4
src/main/java/com/fr/plugin/db/redis/RedisScriptTableDataDefine.java

@ -4,9 +4,9 @@ import com.fr.base.TableData;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.fun.ServerTableDataDefineProvider; import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; import com.fr.design.fun.impl.AbstractTableDataDefineProvider;
import com.fr.locale.InterProviderFactory;
import com.fr.plugin.db.redis.core.RedisScriptTableData; import com.fr.plugin.db.redis.core.RedisScriptTableData;
import com.fr.plugin.db.redis.ui.RedisScriptTableDataPane; import com.fr.plugin.db.redis.ui.RedisScriptTableDataPane;
import com.fanruan.api.i18n.I18nKit;
/** /**
* @author richie * @author richie
@ -37,7 +37,7 @@ public class RedisScriptTableDataDefine extends AbstractTableDataDefineProvider
@Override @Override
public String nameForTableData() { public String nameForTableData() {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Script_Table_Data"); return I18nKit.getLocText("Plugin-Redis_Script_Table_Data");
} }
@Override @Override

20
src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.general.IOUtils; import com.fanruan.api.log.LogKit;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.util.IOKit;
import com.fr.script.ScriptFactory; import com.fanruan.api.script.ScriptKit;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
@ -46,21 +46,21 @@ public class DataWrapper<T> {
} }
public void transform(String script) throws ScriptException { public void transform(String script) throws ScriptException {
if (StringUtils.isBlank(script)) { if (StringKit.isBlank(script)) {
return; return;
} }
String scriptText = null; String scriptText = null;
if (script.startsWith("file:///")) { if (script.startsWith("file:///")) {
try { try {
FileInputStream in = new FileInputStream(new File(readAndRenderScriptFile(script))); FileInputStream in = new FileInputStream(new File(readAndRenderScriptFile(script)));
scriptText = IOUtils.inputStream2String(in); scriptText = IOKit.inputStream2String(in);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
} }
} else { } else {
scriptText = String.format("(function(){%s})()", script); scriptText = String.format("(function(){%s})()", script);
} }
ScriptEngine scriptEngine = ScriptFactory.newScriptEngine(); ScriptEngine scriptEngine = ScriptKit.newScriptEngine();
scriptEngine.put("$content", data); scriptEngine.put("$content", data);
scriptEngine.put("$column", columnNames); scriptEngine.put("$column", columnNames);
Object r = scriptEngine.eval(scriptText); Object r = scriptEngine.eval(scriptText);
@ -70,7 +70,7 @@ public class DataWrapper<T> {
Object vector = map.get("column"); Object vector = map.get("column");
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<String>();
for (Object name : ((Map)vector).values()) { for (Object name : ((Map)vector).values()) {
names.add(GeneralUtils.objectToString(name)); names.add(GeneralKit.objectToString(name));
} }
columnNames = names.toArray(new String[0]); columnNames = names.toArray(new String[0]);
Object content = map.get("content"); Object content = map.get("content");

44
src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java

@ -1,19 +1,19 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fr.config.holder.Conf; import cpm.fanruan.api.conf.HolderKit;
import com.fr.config.holder.factory.Holders; import com.fanruan.api.conf.impl.ColConf;
import com.fr.config.holder.impl.ColConf;
import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.locale.InterProviderFactory; import com.fanruan.api.i18n.I18nKit;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.security.SecurityToolbox; import com.fanruan.api.security.SecurityKit;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.StableUtils; import com.fanruan.api.util.ReflectKit;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.config.holder.Conf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -24,9 +24,9 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
private static final int DEFAULT_REDIS_PORT = 6379; private static final int DEFAULT_REDIS_PORT = 6379;
private Conf<String> host = Holders.simple(StringUtils.EMPTY); private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = Holders.simple(DEFAULT_REDIS_PORT); private Conf<Integer> port = HolderKit.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = Holders.simple(StringUtils.EMPTY); private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
public RedisDatabaseConnection() { public RedisDatabaseConnection() {
@ -82,8 +82,8 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
@Override @Override
public String[] summary(String... args) { public String[] summary(String... args) {
if (ArrayUtils.isEmpty(args)) { if (ArrayKit.isEmpty(args)) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayKit.EMPTY_STRING_ARRAY;
} else { } else {
Redis redis = createRedisClient(); Redis redis = createRedisClient();
Set<String> keys = redis.getClient().keys(args[0]); Set<String> keys = redis.getClient().keys(args[0]);
@ -96,16 +96,16 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
@Override @Override
public String connectMessage(boolean status) { public String connectMessage(boolean status) {
if (status) { if (status) {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Connection_Successfully") + "!"; return I18nKit.getLocText("Plugin-Redis_Connection_Successfully") + "!";
} else { } else {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Connection_Failed") + "!"; return I18nKit.getLocText("Plugin-Redis_Connection_Failed") + "!";
} }
} }
@Override @Override
public void addConnection(List<String> list, String connectionName, Class<? extends Connection>[] acceptTypes) { public void addConnection(List<String> list, String connectionName, Class<? extends Connection>[] acceptTypes) {
for (Class<? extends com.fr.data.impl.Connection> accept : acceptTypes) { for (Class<? extends com.fr.data.impl.Connection> accept : acceptTypes) {
if (StableUtils.classInstanceOf(getClass(), accept)) { if (ReflectKit.classInstanceOf(getClass(), accept)) {
list.add(connectionName); list.add(connectionName);
break; break;
} }
@ -143,11 +143,11 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tagName = reader.getTagName(); String tagName = reader.getTagName();
if ("Attr".equals(tagName)) { if ("Attr".equals(tagName)) {
setHost(reader.getAttrAsString("host", StringUtils.EMPTY)); setHost(reader.getAttrAsString("host", StringKit.EMPTY));
setPort(reader.getAttrAsInt("port", DEFAULT_REDIS_PORT)); setPort(reader.getAttrAsInt("port", DEFAULT_REDIS_PORT));
String pwd = reader.getAttrAsString("password", StringUtils.EMPTY); String pwd = reader.getAttrAsString("password", StringKit.EMPTY);
if (StringUtils.isNotEmpty(pwd)) { if (StringKit.isNotEmpty(pwd)) {
setPassword(SecurityToolbox.encrypt(pwd)); setPassword(SecurityKit.encrypt(pwd));
} }
} }
} }
@ -159,8 +159,8 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
writer.startTAG("Attr"); writer.startTAG("Attr");
writer.attr("host", getHost()); writer.attr("host", getHost());
writer.attr("port", getPort()); writer.attr("port", getPort());
if (StringUtils.isNotEmpty(getPassword())) { if (StringKit.isNotEmpty(getPassword())) {
writer.attr("password", SecurityToolbox.decrypt(getPassword())); writer.attr("password", SecurityKit.decrypt(getPassword()));
} }
writer.end(); writer.end();
} }

22
src/main/java/com/fr/plugin/db/redis/core/RedisNode.java

@ -1,23 +1,23 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.BaseUniqueKey;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.StringKit;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.config.utils.UniqueKey;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
/** /**
* @author richie * @author richie
* @version 10.0 * @version 10.0
* Created by richie on 2019-03-22 * Created by richie on 2019-03-22
*/ */
public class RedisNode extends UniqueKey { public class RedisNode extends BaseUniqueKey {
public static final int DEFAULT_REDIS_PORT = 6379; public static final int DEFAULT_REDIS_PORT = 6379;
private Conf<String> host = Holders.simple(StringUtils.EMPTY); private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = Holders.simple(DEFAULT_REDIS_PORT); private Conf<Integer> port = HolderKit.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = Holders.simple(StringUtils.EMPTY); private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
public RedisNode(String host, int port, String password) { public RedisNode(String host, int port, String password) {
this.setHost(host); this.setHost(host);
@ -52,14 +52,14 @@ public class RedisNode extends UniqueKey {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof RedisNode return obj instanceof RedisNode
&& AssistUtils.equals(((RedisNode) obj).getHost(), getHost()) && AssistKit.equals(((RedisNode) obj).getHost(), getHost())
&& ((RedisNode) obj).getPort() == getPort() && ((RedisNode) obj).getPort() == getPort()
&& AssistUtils.equals(((RedisNode) obj).getPassword(), getPassword()); && AssistKit.equals(((RedisNode) obj).getPassword(), getPassword());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return AssistUtils.hashCode(getHost(), getPort(), getPassword()); return AssistKit.hashCode(getHost(), getPort(), getPassword());
} }
@Override @Override

20
src/main/java/com/fr/plugin/db/redis/core/RedisPool.java

@ -2,7 +2,7 @@ package com.fr.plugin.db.redis.core;
import com.fr.config.Configuration; import com.fr.config.Configuration;
import com.fr.config.holder.ConfigChangeListener; import com.fr.config.holder.ConfigChangeListener;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis; 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.ProxyRedis;
import com.fr.plugin.db.redis.core.emb.impl.SimpleRedis; import com.fr.plugin.db.redis.core.emb.impl.SimpleRedis;
@ -11,12 +11,10 @@ import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
import com.fr.ssh.jsch.JSch; import com.fr.ssh.jsch.JSch;
import com.fr.ssh.jsch.JSchException; import com.fr.ssh.jsch.JSchException;
import com.fr.ssh.jsch.Session; import com.fr.ssh.jsch.Session;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.third.redis.clients.jedis.JedisCluster; import com.fanruan.api.redis.pool.JedisPool;
import com.fr.third.redis.clients.jedis.JedisPool; import com.fanruan.api.redis.pool.JedisPoolConfig;
import com.fr.third.redis.clients.jedis.JedisPoolConfig;
import com.fr.transaction.Configurations;
import com.fr.transaction.ValidateProxy; import com.fr.transaction.ValidateProxy;
import java.util.Map; import java.util.Map;
@ -60,7 +58,7 @@ public class RedisPool {
try { try {
return createJedisBySSH(host, port, password); return createJedisBySSH(host, port, password);
} catch (JSchException e) { } catch (JSchException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
} }
} else { } else {
String feature = host + ":" + port + "@" + password; String feature = host + ":" + port + "@" + password;
@ -109,7 +107,7 @@ public class RedisPool {
config.setTestWhileIdle(false); config.setTestWhileIdle(false);
//逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1 //逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
config.setTimeBetweenEvictionRunsMillis(-1); config.setTimeBetweenEvictionRunsMillis(-1);
if (StringUtils.isNotBlank(password)) { if (StringKit.isNotBlank(password)) {
return new JedisPool(config, host, port, poolConfig.getTimeout(), password); return new JedisPool(config, host, port, poolConfig.getTimeout(), password);
} else { } else {
return new JedisPool(config, host, port, poolConfig.getTimeout()); return new JedisPool(config, host, port, poolConfig.getTimeout());
@ -119,11 +117,11 @@ public class RedisPool {
private Redis createJedisBySSH(String host, int port, String password) throws JSchException { private Redis createJedisBySSH(String host, int port, String password) throws JSchException {
RedisConnectionProxyConfig proxyConfig = RedisConnectionProxyConfig.getInstance(); RedisConnectionProxyConfig proxyConfig = RedisConnectionProxyConfig.getInstance();
JSch jsch = new JSch(); JSch jsch = new JSch();
if (StringUtils.isNotBlank(proxyConfig.getPrivateKeyPath())) { if (StringKit.isNotBlank(proxyConfig.getPrivateKeyPath())) {
jsch.addIdentity(proxyConfig.getPrivateKeyPath()); jsch.addIdentity(proxyConfig.getPrivateKeyPath());
} }
Session session = jsch.getSession(proxyConfig.getUsername(), proxyConfig.getHost(), proxyConfig.getPort()); Session session = jsch.getSession(proxyConfig.getUsername(), proxyConfig.getHost(), proxyConfig.getPort());
if (StringUtils.isNotBlank(proxyConfig.getPassword())) { if (StringKit.isNotBlank(proxyConfig.getPassword())) {
session.setPassword(proxyConfig.getPassword()); session.setPassword(proxyConfig.getPassword());
} }
session.setConfig("StrictHostKeyChecking", "no"); session.setConfig("StrictHostKeyChecking", "no");
@ -133,7 +131,7 @@ public class RedisPool {
Jedis jedis = new Jedis(host, newPort); Jedis jedis = new Jedis(host, newPort);
if (StringUtils.isNotBlank(password)) { if (StringKit.isNotBlank(password)) {
jedis.auth(password); jedis.auth(password);
} }
return new ProxyRedis(session, jedis); return new ProxyRedis(session, jedis);

32
src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java

@ -1,28 +1,28 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.config.holder.Conf; import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.factory.Holders;
import com.fr.config.holder.factory.XmlHolders; import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData; import com.fr.data.AbstractParameterTableData;
import com.fr.data.core.DataCoreXmlUtils; import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.file.DatasourceManager; import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue; 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.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.config.holder.Conf;
/** /**
* @author richie * @author richie
@ -34,9 +34,9 @@ public class RedisScriptTableData extends AbstractParameterTableData {
private static final long serialVersionUID = 1525853354993816818L; private static final long serialVersionUID = 1525853354993816818L;
private Conf<Connection> database = Holders.obj(null, Connection.class); private Conf<Connection> database = HolderKit.obj(null, Connection.class);
private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG); private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG);
private Conf<String> script = Holders.simple(StringUtils.EMPTY); private Conf<String> script = HolderKit.simple(StringKit.EMPTY);
public void setDatabase(Connection c) { public void setDatabase(Connection c) {
this.database.set(c); this.database.set(c);
@ -79,7 +79,7 @@ public class RedisScriptTableData extends AbstractParameterTableData {
Connection connection = database.get(); Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameDatabaseConnection) {
String name = ((NameDatabaseConnection) connection).getName(); String name = ((NameDatabaseConnection) connection).getName();
RedisDatabaseConnection rc = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class); RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) { if (rc != null) {
OrderValue orderValue = dbIndex.get(); OrderValue orderValue = dbIndex.get();
DataModel model = new RedisScriptTableDataModel(rc, DataModel model = new RedisScriptTableDataModel(rc,
@ -101,13 +101,13 @@ public class RedisScriptTableData extends AbstractParameterTableData {
String tmpVal; String tmpVal;
if (OrderValue.XML_TAG.equals(tmpName)) { if (OrderValue.XML_TAG.equals(tmpName)) {
OrderValue orderValue = (OrderValue) GeneralXMLTools.readXMLable(reader); OrderValue orderValue = (OrderValue) XmlKit.readXMLable(reader);
if (orderValue != null) { if (orderValue != null) {
setOrderValue(orderValue); setOrderValue(orderValue);
} }
} else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) { } else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) {
if (reader.getAttrAsString("class", null) != null) { if (reader.getAttrAsString("class", null) != null) {
com.fr.data.impl.Connection con = DataCoreXmlUtils.readXMLConnection(reader); com.fr.data.impl.Connection con = XmlKit.readXMLConnection(reader);
this.setDatabase(con); this.setDatabase(con);
} }
} else if ("Script".equals(tmpName)) { } else if ("Script".equals(tmpName)) {
@ -122,9 +122,9 @@ public class RedisScriptTableData extends AbstractParameterTableData {
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer); super.writeXML(writer);
GeneralXMLTools.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG); XmlKit.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
if (this.database.get() != null) { if (this.database.get() != null) {
DataCoreXmlUtils.writeXMLConnection(writer, this.database.get()); XmlKit.writeXMLConnection(writer, this.database.get());
} }
writer.startTAG("Script").textNode(getScript()).end(); writer.startTAG("Script").textNode(getScript()).end();
} }

40
src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java

@ -1,31 +1,31 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.TemplateUtils; import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.config.holder.factory.XmlHolders; import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData; import com.fr.data.AbstractParameterTableData;
import com.fr.data.core.DataCoreXmlUtils; import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.file.DatasourceManager; import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original; import com.fr.intelli.record.Original;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue; 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.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.config.holder.Conf;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -35,10 +35,10 @@ import java.util.Map;
public class RedisTableData extends AbstractParameterTableData { public class RedisTableData extends AbstractParameterTableData {
private static final long serialVersionUID = 7017455818551800001L; private static final long serialVersionUID = 7017455818551800001L;
private Conf<Connection> database = Holders.obj(null, Connection.class); private Conf<Connection> database = HolderKit.obj(null, Connection.class);
private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG); private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG);
private Conf<String> query = Holders.simple(StringUtils.EMPTY); private Conf<String> query = HolderKit.simple(StringKit.EMPTY);
private Conf<String> script = Holders.simple(StringUtils.EMPTY); private Conf<String> script = HolderKit.simple(StringKit.EMPTY);
public void setDatabase(Connection c) { public void setDatabase(Connection c) {
this.database.set(c); this.database.set(c);
@ -89,7 +89,7 @@ public class RedisTableData extends AbstractParameterTableData {
Connection connection = database.get(); Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameDatabaseConnection) {
String name = ((NameDatabaseConnection) connection).getName(); String name = ((NameDatabaseConnection) connection).getName();
RedisDatabaseConnection rc = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class); RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) { if (rc != null) {
OrderValue orderValue = dbIndex.get(); OrderValue orderValue = dbIndex.get();
DataModel model = new RedisTableDataModel(calculator, ps, rc, DataModel model = new RedisTableDataModel(calculator, ps, rc,
@ -97,7 +97,7 @@ public class RedisTableData extends AbstractParameterTableData {
RedisUtils.calculateQuery(query.get(), ps), RedisUtils.calculateQuery(query.get(), ps),
RedisUtils.calculateQuery(script.get(), ps), RedisUtils.calculateQuery(script.get(), ps),
rowCount); 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; return model;
} }
} }
@ -114,13 +114,13 @@ public class RedisTableData extends AbstractParameterTableData {
String tmpVal; String tmpVal;
if (OrderValue.XML_TAG.equals(tmpName)) { if (OrderValue.XML_TAG.equals(tmpName)) {
OrderValue orderValue = (OrderValue) GeneralXMLTools.readXMLable(reader); OrderValue orderValue = (OrderValue) XmlKit.readXMLable(reader);
if (orderValue != null) { if (orderValue != null) {
setOrderValue(orderValue); setOrderValue(orderValue);
} }
} else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) { } else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) {
if (reader.getAttrAsString("class", null) != null) { if (reader.getAttrAsString("class", null) != null) {
com.fr.data.impl.Connection con = DataCoreXmlUtils.readXMLConnection(reader); com.fr.data.impl.Connection con = XmlKit.readXMLConnection(reader);
this.setDatabase(con); this.setDatabase(con);
} }
} else if ("Query".equals(tmpName)) { } else if ("Query".equals(tmpName)) {
@ -140,9 +140,9 @@ public class RedisTableData extends AbstractParameterTableData {
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer); super.writeXML(writer);
GeneralXMLTools.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG); XmlKit.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
if (this.database.get() != null) { if (this.database.get() != null) {
DataCoreXmlUtils.writeXMLConnection(writer, this.database.get()); XmlKit.writeXMLConnection(writer, this.database.get());
} }
writer.startTAG("Query").textNode(getQuery()).end(); writer.startTAG("Query").textNode(getQuery()).end();
writer.startTAG("Script").textNode(getScript()).end(); writer.startTAG("Script").textNode(getScript()).end();

12
src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java

@ -1,15 +1,15 @@
package com.fr.plugin.db.redis.core; package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.data.AbstractDataModel; import com.fr.data.AbstractDataModel;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.PluginLicense; import com.fr.plugin.PluginLicense;
import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.visit.VisitorFactory; import com.fr.plugin.db.redis.core.visit.VisitorFactory;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import java.util.List; import java.util.List;
@ -28,16 +28,16 @@ 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(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) {
if (StringUtils.isEmpty(query)) { if (StringKit.isEmpty(query)) {
return; return;
} }
Redis redis = mc.createRedisClient(); Redis redis = mc.createRedisClient();
redis.getClient().select(dbIndex); redis.getClient().select(dbIndex);
FineLoggerFactory.getLogger().info("Connect to redis and select database:" + dbIndex); LogKit.info("Connect to redis and select database:" + dbIndex);
try { try {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
DataWrapper<Object> wrapper = VisitorFactory.getKeyValueResult(calculator, ps, redis.getClient(), query, rowCount); DataWrapper<Object> wrapper = VisitorFactory.getKeyValueResult(calculator, ps, redis.getClient(), query, rowCount);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
wrapper.transform(script); wrapper.transform(script);
data = wrapper.getData(); data = wrapper.getData();
columnNames = wrapper.getColumnNames(); columnNames = wrapper.getColumnNames();

10
src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java

@ -1,15 +1,15 @@
package com.fr.plugin.db.redis.core.order; package com.fr.plugin.db.redis.core.order;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.config.utils.UniqueKey; import com.fanruan.api.conf.BaseUniqueKey;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
public abstract class OrderValue extends UniqueKey implements XMLable { public abstract class OrderValue extends BaseUniqueKey implements XMLable {
private static final long serialVersionUID = -5421898153556627638L; private static final long serialVersionUID = -5421898153556627638L;
@ -36,7 +36,7 @@ public abstract class OrderValue extends UniqueKey implements XMLable {
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG("Attr"); writer.startTAG("Attr");
writer.attr("value", GeneralUtils.objectToString(getValue())); writer.attr("value", GeneralKit.objectToString(getValue()));
writer.end(); writer.end();
} }

27
src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java

@ -1,16 +1,17 @@
package com.fr.plugin.db.redis.core.order.impl; package com.fr.plugin.db.redis.core.order.impl;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.Parameter; import com.fanruan.api.cal.FormulaKit;
import com.fr.base.ParameterHelper; import com.fr.stable.ParameterProvider;
import com.fr.base.ParameterMapNameSpace; import com.fanruan.api.cal.ParameterKit;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.UtilEvalError; import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.util.err.UtilEvalError;
import com.fr.stable.script.NameSpace; import com.fr.stable.script.NameSpace;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -37,12 +38,12 @@ public class FormulaOrderValue extends OrderValue {
@Override @Override
public int toIndex(Calculator cal, Parameter[] ps) { public int toIndex(Calculator cal, Parameter[] ps) {
NameSpace nameSpace = ParameterMapNameSpace.create(ps); NameSpace nameSpace = ParameterKit.createParameterProvider(ps);
cal.pushNameSpace(nameSpace); cal.pushNameSpace(nameSpace);
try { try {
return GeneralUtils.objectToNumber(formula.eval(cal)).intValue(); return GeneralKit.objectToNumber(formula.eval(cal)).intValue();
} catch (UtilEvalError u) { } catch (UtilEvalError u) {
FineLoggerFactory.getLogger().error(u.getMessage(), u); LogKit.error(u.getMessage(), u);
} finally { } finally {
cal.removeNameSpace(nameSpace); cal.removeNameSpace(nameSpace);
} }
@ -54,16 +55,16 @@ public class FormulaOrderValue extends OrderValue {
if (formula == null) { if (formula == null) {
return new ParameterProvider[0]; return new ParameterProvider[0];
} }
return ParameterHelper.analyze4ParametersFromFormula(formula.getContent()); return ParameterKit.analyze4ParametersFromFormula(formula.getContent());
} }
@Override @Override
public void readValue(XMLableReader reader) { public void readValue(XMLableReader reader) {
this.formula = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY)); this.formula = FormulaKit.newFormula(reader.getAttrAsString("value", StringKit.EMPTY));
} }
@Override @Override
public String toString() { public String toString() {
return formula == null ? StringUtils.EMPTY : formula.getPureContent(); return formula == null ? StringKit.EMPTY : formula.getPureContent();
} }
} }

2
src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.order.impl; package com.fr.plugin.db.redis.core.order.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;

20
src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java

@ -1,16 +1,18 @@
package com.fr.plugin.db.redis.core.pool; package com.fr.plugin.db.redis.core.pool;
import com.fr.config.ConfigContext; import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration; import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import javax.xml.ws.Holder;
/** /**
* @author richie * @author richie
* @version 10.0 * @version 10.0
* Created by richie on 2019-03-21 * Created by richie on 2019-03-21
*/ */
public class RedisConnectionPoolConfig extends DefaultConfiguration { public class RedisConnectionPoolConfig extends BaseConfiguration {
private static volatile RedisConnectionPoolConfig instance = null; private static volatile RedisConnectionPoolConfig instance = null;
@ -26,12 +28,12 @@ public class RedisConnectionPoolConfig extends DefaultConfiguration {
private static final int MAX_WAIT = -1; private static final int MAX_WAIT = -1;
private static final int TIME_OUT = 100 * 1000; private static final int TIME_OUT = 100 * 1000;
private Conf<Integer> maxTotal = Holders.simple(MAX_TOTAL); private Conf<Integer> maxTotal = HolderKit.simple(MAX_TOTAL);
private Conf<Integer> maxWait = Holders.simple(MAX_WAIT); private Conf<Integer> maxWait = HolderKit.simple(MAX_WAIT);
private Conf<Integer> maxIdle = Holders.simple(MAX_IDLE); private Conf<Integer> maxIdle = HolderKit.simple(MAX_IDLE);
private Conf<Boolean> blockWhenExhausted = Holders.simple(true); private Conf<Boolean> blockWhenExhausted = HolderKit.simple(true);
private Conf<Boolean> lifo = Holders.simple(true); private Conf<Boolean> lifo = HolderKit.simple(true);
private Conf<Integer> timeout = Holders.simple(TIME_OUT); private Conf<Integer> timeout = HolderKit.simple(TIME_OUT);
public int getMaxTotal() { public int getMaxTotal() {
return maxTotal.get(); return maxTotal.get();

26
src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java

@ -1,18 +1,18 @@
package com.fr.plugin.db.redis.core.pool; package com.fr.plugin.db.redis.core.pool;
import com.fr.config.ConfigContext; import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration; import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.security.SecurityKit;
import com.fanruan.api.util.StringKit;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StringUtils;
/** /**
* @author richie * @author richie
* @version 10.0 * @version 10.0
* Created by richie on 2019-03-21 * Created by richie on 2019-03-21
*/ */
public class RedisConnectionProxyConfig extends DefaultConfiguration { public class RedisConnectionProxyConfig extends BaseConfiguration {
private static volatile RedisConnectionProxyConfig instance = null; private static volatile RedisConnectionProxyConfig instance = null;
@ -23,17 +23,17 @@ public class RedisConnectionProxyConfig extends DefaultConfiguration {
return instance; return instance;
} }
private Conf<Boolean> open = Holders.simple(false); private Conf<Boolean> open = HolderKit.simple(false);
private Conf<String> host = Holders.simple(StringUtils.EMPTY); private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = Holders.simple(22); private Conf<Integer> port = HolderKit.simple(22);
private Conf<String> username = Holders.simple(StringUtils.EMPTY); private Conf<String> username = HolderKit.simple(StringKit.EMPTY);
private Conf<String> password = Holders.simple(StringUtils.EMPTY); private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
private Conf<String> privateKeyPath = Holders.simple(StringUtils.EMPTY); private Conf<String> privateKeyPath = HolderKit.simple(StringKit.EMPTY);
public boolean isOpen() { public boolean isOpen() {
@ -70,11 +70,11 @@ public class RedisConnectionProxyConfig extends DefaultConfiguration {
public String getPassword() { public String getPassword() {
String text = password.get(); String text = password.get();
return SecurityToolbox.decrypt(text); return SecurityKit.decrypt(text);
} }
public void setPassword(String password) { public void setPassword(String password) {
this.password.set(SecurityToolbox.encrypt(password)); this.password.set(SecurityKit.encrypt(password));
} }
public String getPrivateKeyPath() { public String getPrivateKeyPath() {

6
src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.core.visit; package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper; import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.plugin.db.redis.core.RedisConstants; import com.fr.plugin.db.redis.core.RedisConstants;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
/** /**
@ -23,6 +23,6 @@ public abstract class AbstractVisitor<T> implements Visitor<T> {
} }
protected String trimCommand(String cmd) { protected String trimCommand(String cmd) {
return StringUtils.trim(cmd); return StringKit.trim(cmd);
} }
} }

2
src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit; package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper; import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit; package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper; import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.plugin.db.redis.core.visit.impl.*; import com.fr.plugin.db.redis.core.visit.impl.*;
import com.fr.script.Calculator; import com.fr.script.Calculator;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;

6
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; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import java.util.ArrayList; import java.util.ArrayList;
@ -19,7 +19,7 @@ public class MGetVisitor extends AbstractVisitor<String> {
if (arr.length < 2) { if (arr.length < 2) {
throw new IllegalArgumentException("Illegal query:" + query); throw new IllegalArgumentException("Illegal query:" + query);
} }
String[] args = (String[]) ArrayUtils.remove(arr, 0); String[] args = (String[]) ArrayKit.remove(arr, 0);
List<String> data = client.mget(args); List<String> data = client.mget(args);
List<List<String>> result = new ArrayList<List<String>>(); List<List<String>> result = new ArrayList<List<String>>();
result.add(data); result.add(data);

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl; package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor; import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator; import com.fr.script.Calculator;

7
src/main/java/com/fr/plugin/db/redis/help/Console.java

@ -1,6 +1,7 @@
package com.fr.plugin.db.redis.help; package com.fr.plugin.db.redis.help;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
/** /**
* @author richie * @author richie
@ -15,12 +16,12 @@ public class Console {
@ScriptBridge @ScriptBridge
public void log(Object message) { public void log(Object message) {
FineLoggerFactory.getLogger().info(message == null ? null : message.toString()); LogKit.info(message == null ? null : message.toString());
} }
@ScriptBridge @ScriptBridge
public void error(Object message) { public void error(Object message) {
FineLoggerFactory.getLogger().error(message == null ? null : message.toString()); LogKit.error(message == null ? null : message.toString());
} }
@ScriptBridge @ScriptBridge

9
src/main/java/com/fr/plugin/db/redis/help/Files.java

@ -1,9 +1,8 @@
package com.fr.plugin.db.redis.help; package com.fr.plugin.db.redis.help;
import com.eclipsesource.v8.V8; import com.eclipsesource.v8.V8;
import com.fr.general.IOUtils; import com.fanruan.api.util.IOKit;
import com.fr.io.utils.ResourceIOUtils; import com.fanruan.api.consts.EncodeConstantsKit;
import com.fr.stable.EncodeConstants;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -23,10 +22,10 @@ public class Files {
@ScriptBridge @ScriptBridge
public void require(String filePath) { public void require(String filePath) {
InputStream in = ResourceIOUtils.read(filePath); InputStream in = IOKit.read(filePath);
if (in != null) { if (in != null) {
try { try {
v8.executeVoidScript(IOUtils.inputStream2String(in, EncodeConstants.ENCODING_UTF_8)); v8.executeVoidScript(IOKit.inputStream2String(in, EncodeConstantsKit.ENCODING_UTF_8));
} catch (UnsupportedEncodingException ignore) { } catch (UnsupportedEncodingException ignore) {
} }

7
src/main/java/com/fr/plugin/db/redis/help/client/BaseRedisClient.java

@ -1,6 +1,7 @@
package com.fr.plugin.db.redis.help.client; package com.fr.plugin.db.redis.help.client;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.help.ScriptBridge; import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.help.RedisClient; import com.fr.plugin.db.redis.help.RedisClient;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
@ -24,7 +25,7 @@ public abstract class BaseRedisClient<A, O> implements RedisClient<A, O> {
try { try {
return jedis.get(key); return jedis.get(key);
} finally { } finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
} }
} }
@ -34,7 +35,7 @@ public abstract class BaseRedisClient<A, O> implements RedisClient<A, O> {
try { try {
return jedis.hget(key, field); return jedis.hget(key, field);
} finally { } finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
} }
} }

18
src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java

@ -1,7 +1,7 @@
package com.fr.plugin.db.redis.help.client; package com.fr.plugin.db.redis.help.client;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console; import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.ScriptBridge; import com.fr.plugin.db.redis.help.ScriptBridge;
@ -42,7 +42,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] hkeys(String key) { public Object[] hkeys(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.keys(key); Set<String> set = jedis.keys(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]); return set.toArray(new String[0]);
} }
@ -51,7 +51,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] hmget(String key, String... fields) { public Object[] hmget(String key, String... fields) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<String> list = jedis.hmget(key, fields); List<String> list = jedis.hmget(key, fields);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return list.toArray(new String[0]); return list.toArray(new String[0]);
} }
@ -60,7 +60,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Map<Object, Object> hgetAll(String key) { public Map<Object, Object> hgetAll(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Map<String, String> map = jedis.hgetAll(key); Map<String, String> map = jedis.hgetAll(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return new TreeMap<Object, Object>(map); return new TreeMap<Object, Object>(map);
} }
@ -69,7 +69,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] keys(String pattern) { public Object[] keys(String pattern) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.keys(pattern); Set<String> set = jedis.keys(pattern);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]); return set.toArray(new String[0]);
} }
@ -78,7 +78,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] lrange(String key, long start, long end) { public Object[] lrange(String key, long start, long end) {
long start0 = System.currentTimeMillis(); long start0 = System.currentTimeMillis();
List<String> list = jedis.lrange(key, start, end); List<String> list = jedis.lrange(key, start, end);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
return list.toArray(new String[0]); return list.toArray(new String[0]);
} }
@ -92,7 +92,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
parameters[i] = String.valueOf(keys[i]); parameters[i] = String.valueOf(keys[i]);
} }
List<String> list = jedis.mget(parameters); List<String> list = jedis.mget(parameters);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return list.toArray(new String[0]); return list.toArray(new String[0]);
} }
@ -101,7 +101,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] smembers(String key) { public Object[] smembers(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.smembers(key); Set<String> set = jedis.smembers(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]); return set.toArray(new String[0]);
} }
@ -150,7 +150,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
} }
return new SimpleDataModel(columnNames, data, realCount); return new SimpleDataModel(columnNames, data, realCount);
} catch (ScriptException e) { } catch (ScriptException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
} }
return null; return null;
} }

16
src/main/java/com/fr/plugin/db/redis/help/client/RedisV8Client.java

@ -5,7 +5,7 @@ import com.eclipsesource.v8.V8Array;
import com.eclipsesource.v8.V8Object; import com.eclipsesource.v8.V8Object;
import com.eclipsesource.v8.utils.V8ObjectUtils; import com.eclipsesource.v8.utils.V8ObjectUtils;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console; import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.Files; import com.fr.plugin.db.redis.help.Files;
@ -37,7 +37,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array hkeys(String key) { public V8Array hkeys(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.keys(key); Set<String> set = jedis.keys(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set)); return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
} }
@ -46,7 +46,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array hmget(String key, String... fields) { public V8Array hmget(String key, String... fields) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<String> list = jedis.hmget(key, fields); List<String> list = jedis.hmget(key, fields);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, list); return V8ObjectUtils.toV8Array(v8, list);
} }
@ -55,7 +55,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Object hgetAll(String key) { public V8Object hgetAll(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Map<String, String> map = jedis.hgetAll(key); Map<String, String> map = jedis.hgetAll(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Object(v8, map); return V8ObjectUtils.toV8Object(v8, map);
} }
@ -64,7 +64,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array keys(String pattern) { public V8Array keys(String pattern) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.keys(pattern); Set<String> set = jedis.keys(pattern);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set)); return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
} }
@ -73,7 +73,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array lrange(String key, long start, long end) { public V8Array lrange(String key, long start, long end) {
long start0 = System.currentTimeMillis(); long start0 = System.currentTimeMillis();
List<String> list = jedis.lrange(key, start, end); List<String> list = jedis.lrange(key, start, end);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
return V8ObjectUtils.toV8Array(v8, list); return V8ObjectUtils.toV8Array(v8, list);
} }
@ -87,7 +87,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
parameters[i] = keys.getString(i); parameters[i] = keys.getString(i);
} }
List<String> list = jedis.mget(parameters); List<String> list = jedis.mget(parameters);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
keys.release(); keys.release();
return V8ObjectUtils.toV8Array(v8, list); return V8ObjectUtils.toV8Array(v8, list);
} }
@ -97,7 +97,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array smembers(String key) { public V8Array smembers(String key) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<String> set = jedis.smembers(key); Set<String> set = jedis.smembers(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start); LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set)); return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
} }

43
src/main/java/com/fr/plugin/db/redis/ui/RedisBaseTableDataPane.java

@ -1,19 +1,20 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.base.BaseUtils; import com.fanruan.api.util.IOKit;
import com.fr.base.ParameterHelper; import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.design.ui.action.UpdateAction;
import com.fanruan.api.cal.ParameterKit;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.design.actions.UpdateAction; import com.fanruan.api.design.DesignKit;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fanruan.api.design.ui.component.table.model.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fanruan.api.design.ui.component.UIToolbar;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import javax.swing.*; import javax.swing.*;
@ -28,8 +29,8 @@ import java.util.ArrayList;
*/ */
public abstract class RedisBaseTableDataPane<T extends TableData> extends AbstractTableDataPane<T> { public abstract class RedisBaseTableDataPane<T extends TableData> extends AbstractTableDataPane<T> {
private static final String PREVIEW_BUTTON = Toolkit.i18nText("Plugin-Redis_Preview"); private static final String PREVIEW_BUTTON = DesignKit.i18nText("Plugin-Redis_Preview");
private static final String REFRESH_BUTTON = Toolkit.i18nText("Plugin-Redis_Refresh"); private static final String REFRESH_BUTTON = DesignKit.i18nText("Plugin-Redis_Refresh");
protected RedisDBConnectionChosePane chosePane; protected RedisDBConnectionChosePane chosePane;
@ -50,7 +51,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
ParameterTableModel model = new ParameterTableModel() { ParameterTableModel model = new ParameterTableModel() {
@Override @Override
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
return ArrayUtils.add(super.createDBTableAction(), new RedisBaseTableDataPane.RefreshAction()); return ArrayKit.add(super.createDBTableAction(), new RedisBaseTableDataPane.RefreshAction());
} }
}; };
editorPane = new UITableEditorPane<ParameterProvider>(model); editorPane = new UITableEditorPane<ParameterProvider>(model);
@ -81,7 +82,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Query"); return DesignKit.i18nText("Plugin-Redis_Query");
} }
protected abstract JComponent createQueryPane(); protected abstract JComponent createQueryPane();
@ -94,19 +95,19 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
private void refresh() { private void refresh() {
String[] paramTexts = paramTexts(); String[] paramTexts = paramTexts();
ParameterProvider[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); ParameterProvider[] parameters = ParameterKit.analyze4Parameters(paramTexts, false);
ParameterProvider[] providers = getOrderValue().analyze4Parameters(); ParameterProvider[] providers = getOrderValue().analyze4Parameters();
editorPane.populate(ArrayUtils.addAll(parameters, providers)); editorPane.populate(ArrayKit.addAll(parameters, providers));
} }
private void checkParameter() { private void checkParameter() {
String[] paramTexts = paramTexts(); String[] paramTexts = paramTexts();
ParameterProvider[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); ParameterProvider[] parameters = ParameterKit.analyze4Parameters(paramTexts, false);
parameters = ArrayUtils.addAll(parameters, getOrderValue().analyze4Parameters()); parameters = ArrayKit.addAll(parameters, getOrderValue().analyze4Parameters());
if (parameters.length < 1 && editorPane.update().size() < 1) { if (parameters.length < 1 && editorPane.update().size() < 1) {
return; return;
@ -134,12 +135,12 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
public PreviewAction() { public PreviewAction() {
this.setName(PREVIEW_BUTTON); this.setName(PREVIEW_BUTTON);
this.setMnemonic('P'); this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/m_file/preview.png"));
} }
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
checkParameter(); checkParameter();
PreviewTablePane.previewTableData(RedisBaseTableDataPane.this.updateBean()); DesignKit.previewTableData(RedisBaseTableDataPane.this.updateBean());
} }
} }
@ -147,7 +148,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
protected class RefreshAction extends UITableEditAction { protected class RefreshAction extends UITableEditAction {
public RefreshAction() { public RefreshAction() {
this.setName(REFRESH_BUTTON); this.setName(REFRESH_BUTTON);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/control/refresh.png"));
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

47
src/main/java/com/fr/plugin/db/redis/ui/RedisConnectionPane.java

@ -1,20 +1,19 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.data.datapane.connect.DatabaseConnectionPane; import com.fanruan.api.design.ui.container.DatabaseConnectionPane;
import com.fr.design.dialog.BasicDialog; import com.fanruan.api.design.ui.container.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIPasswordField; import com.fanruan.api.design.ui.component.UIPasswordField;
import com.fr.design.gui.ilable.ActionLabel; import com.fanruan.api.design.component.UIActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField; import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField; import com.fanruan.api.design.ui.component.UINumberField;
import com.fr.design.gui.itextfield.UITextField; import com.fanruan.api.design.ui.component.UITextField;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.layout.TableLayout; import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fr.design.layout.TableLayoutHelper; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig; import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig;
import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig; import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
@ -51,14 +50,14 @@ public class RedisConnectionPane extends DatabaseConnectionPane<com.fr.plugin.db
globalConfigPane.setLayout(gridLayout); globalConfigPane.setLayout(gridLayout);
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Host") + ":"), hostTextField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Host") + ":"), hostTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Port") + ":"), portNumberField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Port") + ":"), portNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Password") + ":"), passwordTextField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Password") + ":"), passwordTextField},
{null, globalConfigPane} {null, globalConfigPane}
}; };
ActionLabel poolConfigLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Pool_Config")); UIActionLabel poolConfigLabel = new UIActionLabel(DesignKit.i18nText("Plugin-Redis_Pool_Config"));
ActionLabel proxyConfigLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Proxy_Config")); UIActionLabel proxyConfigLabel = new UIActionLabel(DesignKit.i18nText("Plugin-Redis_Proxy_Config"));
poolConfigLabel.addActionListener(new ActionListener() { poolConfigLabel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -99,17 +98,17 @@ public class RedisConnectionPane extends DatabaseConnectionPane<com.fr.plugin.db
dialog.setVisible(true); dialog.setVisible(true);
} }
}); });
globalConfigPane.add(GUICoreUtils.createFlowPane(poolConfigLabel, FlowLayout.LEFT)); globalConfigPane.add(GUICoreKit.createFlowPane(poolConfigLabel, FlowLayout.LEFT));
globalConfigPane.add(GUICoreUtils.createFlowPane(proxyConfigLabel, FlowLayout.LEFT)); globalConfigPane.add(GUICoreKit.createFlowPane(proxyConfigLabel, FlowLayout.LEFT));
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double[] rowSize = new double[]{p, p, p, p, p}; double[] rowSize = new double[]{p, p, p, p, p};
double[] columnSize = new double[]{p, 400}; double[] columnSize = new double[]{p, 400};
JPanel settingsUI = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel settingsUI = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize);
settingsUI.setBorder(UITitledBorder.createBorderWithTitle("Redis")); settingsUI.setBorder(UITitledBorder.createBorderWithTitle("Redis"));
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); JPanel centerPane = GUICoreKit.createNormalFlowInnerContainerPane();
centerPane.add(settingsUI); centerPane.add(settingsUI);

42
src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java

@ -2,18 +2,18 @@ package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.data.datapane.connect.ConnectionComboBoxPanel; import com.fanruan.api.design.ui.container.ConnectionComboBoxPanel;
import com.fr.design.dialog.BasicPane; import com.fanruan.api.design.ui.component.UIButton;
import com.fr.design.gui.ibutton.UIButton; import com.fanruan.api.design.ui.component.UIPlaceholderTextField;
import com.fr.design.gui.itextfield.PlaceholderTextField; import com.fanruan.api.design.DesignKit;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.data.ConnectionKit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.DatasourceManager;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.ui.event.DataLoadedListener; import com.fr.plugin.db.redis.ui.event.DataLoadedListener;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.design.util.GUICoreKit;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -28,7 +28,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
private ConnectionComboBoxPanel connectionComboBoxPanel; private ConnectionComboBoxPanel connectionComboBoxPanel;
private DefaultListModel listModel = new DefaultListModel(); private DefaultListModel listModel = new DefaultListModel();
private List<DataLoadedListener> listeners = new ArrayList<DataLoadedListener>(); private List<DataLoadedListener> listeners = new ArrayList<DataLoadedListener>();
private PlaceholderTextField keysPatternTextField; private UIPlaceholderTextField keysPatternTextField;
public RedisDBConnectionChosePane() { public RedisDBConnectionChosePane() {
setLayout(new BorderLayout(4, 4)); setLayout(new BorderLayout(4, 4));
@ -48,12 +48,12 @@ public class RedisDBConnectionChosePane extends BasicPane {
}); });
JList list = new JList(listModel); JList list = new JList(listModel);
keysPatternTextField = new PlaceholderTextField(10); keysPatternTextField = new UIPlaceholderTextField(10);
keysPatternTextField.setPlaceholder(Toolkit.i18nText("Plugin-Redis_Keys_Pattern")); keysPatternTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Keys_Pattern"));
JPanel centerPane = new JPanel(new BorderLayout()); JPanel centerPane = new JPanel(new BorderLayout());
UIButton searchButton = new UIButton(Toolkit.i18nText("Plugin-Redis_Keys_Pattern_Search")); UIButton searchButton = new UIButton(DesignKit.i18nText("Plugin-Redis_Keys_Pattern_Search"));
searchButton.addActionListener(new ActionListener() { searchButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -61,7 +61,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
} }
}); });
centerPane.add(GUICoreUtils.createBorderLayoutPane( centerPane.add(GUICoreKit.createBorderLayoutPane(
keysPatternTextField, BorderLayout.CENTER, keysPatternTextField, BorderLayout.CENTER,
searchButton, BorderLayout.EAST), BorderLayout.NORTH); searchButton, BorderLayout.EAST), BorderLayout.NORTH);
@ -72,12 +72,12 @@ public class RedisDBConnectionChosePane extends BasicPane {
private void loadKeys() { private void loadKeys() {
String name = getSelectRedisConnectionName(); String name = getSelectRedisConnectionName();
if (StringUtils.isEmpty(name)) { if (StringKit.isEmpty(name)) {
clearList(); clearList();
fireDataLoaded(ArrayUtils.EMPTY_STRING_ARRAY); fireDataLoaded(ArrayKit.EMPTY_STRING_ARRAY);
return; return;
} }
RedisDatabaseConnection connection = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class); RedisDatabaseConnection connection = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (connection != null) { if (connection != null) {
listMatchedPatternKeys(connection); listMatchedPatternKeys(connection);
} }
@ -94,8 +94,8 @@ public class RedisDBConnectionChosePane extends BasicPane {
@Override @Override
protected String[] doInBackground() throws Exception { protected String[] doInBackground() throws Exception {
String keysPattern = keysPatternTextField.getText(); String keysPattern = keysPatternTextField.getText();
if (StringUtils.isEmpty(keysPattern)) { if (StringKit.isEmpty(keysPattern)) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayKit.EMPTY_STRING_ARRAY;
} else { } else {
return DataOperator.getInstance().getTableSummary(connection, keysPattern); return DataOperator.getInstance().getTableSummary(connection, keysPattern);
} }
@ -110,7 +110,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
} }
fireDataLoaded(keys); fireDataLoaded(keys);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
} }
} }
}.execute(); }.execute();

43
src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java

@ -1,19 +1,18 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fanruan.api.design.ui.container.BasicPane;
import com.fr.design.dialog.BasicPane; import com.fanruan.api.layout.TableLayoutKit;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.gui.ilable.ActionLabel; import com.fanruan.api.log.LogKit;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.container.SQLEditPane;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.component.UIActionLabel;
import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextarea.DescriptionTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fanruan.api.design.ui.component.code.SyntaxConstants;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory; import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory;
import com.fr.plugin.db.redis.util.RedisDesignUtils; import com.fr.plugin.db.redis.util.RedisDesignUtils;
@ -29,25 +28,25 @@ public class RedisQueryPane extends BasicPane {
private SQLEditPane sqlTextPane; private SQLEditPane sqlTextPane;
private ValueEditorPane dbIndexEditor; private ValueEditorPane dbIndexEditor;
private RSyntaxTextArea scriptTextPane; private UISyntaxTextArea scriptTextPane;
public RedisQueryPane() { public RedisQueryPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
sqlTextPane = new SQLEditPane(); sqlTextPane = new SQLEditPane();
scriptTextPane = new RSyntaxTextArea(); scriptTextPane = new UISyntaxTextArea();
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane(); dbIndexEditor = IndexValuePaneFactory.createValueEditorPane();
ActionLabel helpLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Help")); UIActionLabel helpLabel = new UIActionLabel(DesignKit.i18nText("Plugin-Redis_Help"));
helpLabel.addActionListener(new ActionListener() { helpLabel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
Desktop.getDesktop().browse(URI.create(SiteCenter.getInstance().acquireUrlByKind("help.redis"))); Desktop.getDesktop().browse(URI.create(SiteCenter.getInstance().acquireUrlByKind("help.redis")));
} catch (IOException e1) { } catch (IOException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1); LogKit.error(e1.getMessage(), e1);
} }
} }
}); });
@ -56,11 +55,11 @@ public class RedisQueryPane extends BasicPane {
descriptionArea.setWrapStyleWord(true); descriptionArea.setWrapStyleWord(true);
descriptionArea.setLineWrap(true); descriptionArea.setLineWrap(true);
descriptionArea.setText(Toolkit.i18nText("Plugin-Redis_Script_Text_Description")); descriptionArea.setText(DesignKit.i18nText("Plugin-Redis_Script_Text_Description"));
Component[][] coms = new Component[][]{ Component[][] coms = new Component[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, {new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{GUICoreUtils.createBorderLayoutPane(new UILabel(Toolkit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH), {GUICoreKit.createBorderLayoutPane(new UILabel(DesignKit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH),
RedisDesignUtils.createConditionTextPane(sqlTextPane, SyntaxConstants.SYNTAX_STYLE_SQL, 300)} RedisDesignUtils.createConditionTextPane(sqlTextPane, SyntaxConstants.SYNTAX_STYLE_SQL, 300)}
}; };
@ -68,13 +67,13 @@ public class RedisQueryPane extends BasicPane {
// RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 200) // RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 200)
// } // }
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayout.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = {p, p}; double[] rowSize = {p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
add(TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize)); add(GUICoreKit.createTableLayoutPane(coms, rowSize, columnSize));
} }

30
src/main/java/com/fr/plugin/db/redis/ui/RedisScriptPane.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.design.dialog.BasicPane; import com.fanruan.api.design.ui.container.BasicPane;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.layout.TableLayoutKit;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fr.design.layout.TableLayout; import com.fanruan.api.design.ui.component.code.SyntaxConstants;
import com.fr.design.layout.TableLayoutHelper; import com.fanruan.api.design.DesignKit;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory; import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory;
import com.fr.plugin.db.redis.util.RedisDesignUtils; import com.fr.plugin.db.redis.util.RedisDesignUtils;
@ -22,29 +22,29 @@ import java.awt.*;
public class RedisScriptPane extends BasicPane { public class RedisScriptPane extends BasicPane {
private ValueEditorPane dbIndexEditor; private ValueEditorPane dbIndexEditor;
private RSyntaxTextArea scriptTextPane; private UISyntaxTextArea scriptTextPane;
public RedisScriptPane() { public RedisScriptPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
scriptTextPane = new RSyntaxTextArea(); scriptTextPane = new UISyntaxTextArea();
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane(); dbIndexEditor = IndexValuePaneFactory.createValueEditorPane();
Component[][] coms = new Component[][]{ Component[][] coms = new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, {new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Script_Query_Text") + ":"), {new UILabel(DesignKit.i18nText("Plugin-Redis_Script_Query_Text") + ":"),
RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 350)}, RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 350)},
}; };
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayout.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = {p, p, p}; double[] rowSize = {p, p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
add(TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize)); add(GUICoreKit.createTableLayoutPane(coms, rowSize, columnSize));
} }

6
src/main/java/com/fr/plugin/db/redis/ui/RedisScriptTableDataPane.java

@ -1,11 +1,11 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.plugin.db.redis.core.RedisScriptTableData; import com.fr.plugin.db.redis.core.RedisScriptTableData;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import javax.swing.*; import javax.swing.*;
import java.util.List; import java.util.List;
@ -61,7 +61,7 @@ public class RedisScriptTableDataPane extends RedisBaseTableDataPane<RedisScript
public RedisScriptTableData updateBean() { public RedisScriptTableData updateBean() {
RedisScriptTableData tableData = new RedisScriptTableData(); RedisScriptTableData tableData = new RedisScriptTableData();
String connectionName = chosePane.getSelectRedisConnectionName(); String connectionName = chosePane.getSelectRedisConnectionName();
if (StringUtils.isNotEmpty(connectionName)) { if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName)); tableData.setDatabase(new NameDatabaseConnection(connectionName));
} }
List<ParameterProvider> parameterList = editorPane.update(); List<ParameterProvider> parameterList = editorPane.update();

10
src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java

@ -1,12 +1,12 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.NameDatabaseConnection; import com.fanruan.api.design.DesignKit;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.plugin.db.redis.core.RedisTableData; import com.fr.plugin.db.redis.core.RedisTableData;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import javax.swing.*; import javax.swing.*;
import java.util.List; import java.util.List;
@ -24,7 +24,7 @@ public class RedisTableDataPane extends RedisBaseTableDataPane<RedisTableData> {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Query"); return DesignKit.i18nText("Plugin-Redis_Query");
} }
protected JComponent createQueryPane() { protected JComponent createQueryPane() {
@ -68,7 +68,7 @@ public class RedisTableDataPane extends RedisBaseTableDataPane<RedisTableData> {
RedisTableData tableData = new RedisTableData(); RedisTableData tableData = new RedisTableData();
String connectionName = chosePane.getSelectRedisConnectionName(); String connectionName = chosePane.getSelectRedisConnectionName();
if (StringUtils.isNotEmpty(connectionName)) { if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName)); tableData.setDatabase(new NameDatabaseConnection(connectionName));
} }

36
src/main/java/com/fr/plugin/db/redis/ui/pool/RedisConnectionPoolConfigPane.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui.pool; package com.fr.plugin.db.redis.ui.pool;
import com.fr.design.dialog.BasicPane; import com.fanruan.api.design.ui.container.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fanruan.api.layout.TableLayoutKit;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.gui.itextfield.UIIntNumberField; import com.fanruan.api.design.ui.component.UICheckBox;
import com.fr.design.gui.itextfield.UINumberField; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fr.design.layout.TableLayout; import com.fanruan.api.design.ui.component.UINumberField;
import com.fr.design.layout.TableLayoutHelper; import com.fanruan.api.design.DesignKit;
import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig; import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig;
import javax.swing.*; import javax.swing.*;
@ -43,24 +43,24 @@ public class RedisConnectionPoolConfigPane extends BasicPane {
timeoutNumberField = new UIIntNumberField(); timeoutNumberField = new UIIntNumberField();
JComponent[][] comps = new JComponent[][]{ JComponent[][] comps = new JComponent[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Total") + ":"), maxTotalNumberFiled}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Total") + ":"), maxTotalNumberFiled},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Wait") + ":"), maxWaitNumberField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Wait") + ":"), maxWaitNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Idle") + ":"), maxIdleNumberField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Idle") + ":"), maxIdleNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Block_When_Exhausted") + ":"), blockWhenExhaustedCheckBox}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Block_When_Exhausted") + ":"), blockWhenExhaustedCheckBox},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Lifo") + ":"), lifoCheckBox}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Lifo") + ":"), lifoCheckBox},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Timeout") + ":"), timeoutNumberField} {new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Timeout") + ":"), timeoutNumberField}
}; };
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayout.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = new double[]{p, p, p, p, p, p}; double[] rowSize = new double[]{p, p, p, p, p, p};
double[] columnSize = new double[]{p, f}; double[] columnSize = new double[]{p, f};
add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER); add(GUICoreKit.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Pool_Config"); return DesignKit.i18nText("Plugin-Redis_Pool_Config");
} }
public void populate(RedisConnectionPoolConfig config) { public void populate(RedisConnectionPoolConfig config) {

45
src/main/java/com/fr/plugin/db/redis/ui/proxy/RedisConnectionProxyConfigPane.java

@ -1,16 +1,15 @@
package com.fr.plugin.db.redis.ui.proxy; package com.fr.plugin.db.redis.ui.proxy;
import com.fr.design.dialog.BasicPane; import com.fanruan.api.design.ui.container.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fanruan.api.layout.TableLayoutKit;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.ui.component.UIButton;
import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fanruan.api.design.ui.component.UICheckBox;
import com.fr.design.gui.itextfield.UIIntNumberField; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fanruan.api.design.ui.component.UIPassWordField;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fr.design.layout.TableLayout; import com.fanruan.api.design.ui.component.UITextField;
import com.fr.design.layout.TableLayoutHelper; import com.fanruan.api.design.DesignKit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig; import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
import javax.swing.*; import javax.swing.*;
@ -47,22 +46,22 @@ public class RedisConnectionProxyConfigPane extends BasicPane {
passwordTextField = new UIPassWordField(); passwordTextField = new UIPassWordField();
privateKeyPathTextField = new UITextField(); privateKeyPathTextField = new UITextField();
privateKeyPathTextField.setPlaceholder(Toolkit.i18nText("Plugin-Redis_Proxy_Private_Key_Tip")); privateKeyPathTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Proxy_Private_Key_Tip"));
UIButton fileSelectButton = new UIButton("..."); UIButton fileSelectButton = new UIButton("...");
UILabel description = new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Description"), SwingConstants.CENTER); UILabel description = new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Description"), SwingConstants.CENTER);
JComponent[][] comps = new JComponent[][]{ JComponent[][] comps = new JComponent[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Open") + ":"), GUICoreUtils.createBorderLayoutPane( {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Open") + ":"), GUICoreKit.createBorderLayoutPane(
openCheckBox, BorderLayout.WEST, openCheckBox, BorderLayout.WEST,
description, BorderLayout.CENTER description, BorderLayout.CENTER
)}, )},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Host") + ":"), hostTextField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Host") + ":"), hostTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Port") + ":"), portNumberField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Port") + ":"), portNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Username") + ":"), usernameTextField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Username") + ":"), usernameTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Password") + ":"), passwordTextField}, {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Password") + ":"), passwordTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Private_Key_Path") + ":"), GUICoreUtils.createBorderLayoutPane( {new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Private_Key_Path") + ":"), GUICoreKit.createBorderLayoutPane(
privateKeyPathTextField, BorderLayout.CENTER, privateKeyPathTextField, BorderLayout.CENTER,
fileSelectButton, BorderLayout.EAST fileSelectButton, BorderLayout.EAST
)}, )},
@ -79,18 +78,18 @@ public class RedisConnectionProxyConfigPane extends BasicPane {
} }
}); });
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayout.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = new double[]{p, p, p, p, p, p}; double[] rowSize = new double[]{p, p, p, p, p, p};
double[] columnSize = new double[]{p, f}; double[] columnSize = new double[]{p, f};
add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER); add(GUICoreKit.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Proxy_Config"); return DesignKit.i18nText("Plugin-Redis_Proxy_Config");
} }
public void populate(RedisConnectionProxyConfig config) { public void populate(RedisConnectionProxyConfig config) {

18
src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui.value; package com.fr.plugin.db.redis.ui.value;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter; import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fr.design.editor.editor.Editor; import com.fanruan.api.design.ui.editor.Editor;
import com.fr.design.formula.FormulaFactory; import com.fanruan.api.design.ui.factory.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.itextfield.UITextField; import com.fanruan.api.design.ui.component.UITextField;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue; import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue;
import javax.swing.*; import javax.swing.*;
@ -27,7 +27,7 @@ public class FormulaEditor extends Editor<FormulaOrderValue> {
* Constructor. * Constructor.
*/ */
public FormulaEditor() { public FormulaEditor() {
this(Toolkit.i18nText("Plugin-Redis_Formula")); this(DesignKit.i18nText("Plugin-Redis_Formula"));
} }
public FormulaEditor(String name) { public FormulaEditor(String name) {
@ -38,9 +38,9 @@ public class FormulaEditor extends Editor<FormulaOrderValue> {
if (formula != null) { if (formula != null) {
this.orderValue = formula; this.orderValue = formula;
} }
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(GUICoreKit.createBorderLayout());
JPanel editPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel editPane = GUICoreKit.createBorderLayoutPane();
currentTextField = new UITextField(28); currentTextField = new UITextField(28);
currentTextField.setText(this.orderValue.getValue().getContent()); currentTextField.setText(this.orderValue.getValue().getContent());

6
src/main/java/com/fr/plugin/db/redis/ui/value/IndexValuePaneFactory.java

@ -1,8 +1,8 @@
package com.fr.plugin.db.redis.ui.value; package com.fr.plugin.db.redis.ui.value;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.editor.editor.Editor; import com.fanruan.api.design.ui.editor.Editor;
public class IndexValuePaneFactory { public class IndexValuePaneFactory {

14
src/main/java/com/fr/plugin/db/redis/ui/value/IntegerEditor.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.ui.value; package com.fr.plugin.db.redis.ui.value;
import com.fr.base.Utils; import com.fanruan.api.util.GeneralKit;
import com.fr.design.editor.editor.Editor; import com.fanruan.api.design.ui.editor.Editor;
import com.fr.design.gui.itextfield.UIIntNumberField; import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fr.design.gui.itextfield.UITextField; import com.fanruan.api.design.ui.component.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -32,7 +32,7 @@ public class IntegerEditor extends Editor<NumberOrderValue> {
* Constructor. * Constructor.
*/ */
public IntegerEditor(NumberOrderValue value, String name) { public IntegerEditor(NumberOrderValue value, String name) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(GUICoreKit.createBorderLayout());
numberField = new UIIntNumberField(); numberField = new UIIntNumberField();
this.add(numberField, BorderLayout.CENTER); this.add(numberField, BorderLayout.CENTER);
this.numberField.addKeyListener(textKeyListener); this.numberField.addKeyListener(textKeyListener);
@ -101,7 +101,7 @@ public class IntegerEditor extends Editor<NumberOrderValue> {
value = new NumberOrderValue(0); value = new NumberOrderValue(0);
} }
this.numberField.setValue(value.getValue()); this.numberField.setValue(value.getValue());
oldValue = Utils.objectToString(value); oldValue = GeneralKit.objectToString(value);
} }

12
src/main/java/com/fr/plugin/db/redis/util/RedisDesignUtils.java

@ -1,9 +1,9 @@
package com.fr.plugin.db.redis.util; package com.fr.plugin.db.redis.util;
import com.fr.design.border.UIRoundedBorder; import com.fanruan.api.design.ui.component.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fanruan.api.design.macro.UIConstants;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane; import com.fanruan.api.design.ui.component.code.UISyntaxTextScrollPane;
import java.awt.*; import java.awt.*;
@ -13,9 +13,9 @@ import java.awt.*;
* Created by richie on 2019-03-18 * Created by richie on 2019-03-18
*/ */
public class RedisDesignUtils { public class RedisDesignUtils {
public static RTextScrollPane createConditionTextPane(RSyntaxTextArea editorPane, String type, int height) { public static UISyntaxTextScrollPane createConditionTextPane(UISyntaxTextArea editorPane, String type, int height) {
editorPane.setSyntaxEditingStyle(type); editorPane.setSyntaxEditingStyle(type);
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(editorPane); UISyntaxTextScrollPane sqlTextScrollPane = new UISyntaxTextScrollPane(editorPane);
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
sqlTextScrollPane.setPreferredSize(new Dimension(680, height)); sqlTextScrollPane.setPreferredSize(new Dimension(680, height));
sqlTextScrollPane.setLineNumbersEnabled(false); sqlTextScrollPane.setLineNumbersEnabled(false);

10
src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.util; package com.fr.plugin.db.redis.util;
import com.eclipsesource.v8.V8Object; import com.eclipsesource.v8.V8Object;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.TemplateUtils; import com.fanruan.api.util.RenderKit;
import com.fr.plugin.db.redis.help.ScriptBridge; import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -27,7 +27,7 @@ public class RedisUtils {
} }
public static String calculateQuery(String query, Parameter[] ps) { public static String calculateQuery(String query, Parameter[] ps) {
if (ArrayUtils.isEmpty(ps)) { if (ArrayKit.isEmpty(ps)) {
return query; return query;
} }
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -35,7 +35,7 @@ public class RedisUtils {
map.put(p.getName(), p.getValue()); map.put(p.getName(), p.getValue());
} }
try { try {
return TemplateUtils.renderParameter4Tpl(query, map); return RenderKit.renderParameter4Tpl(query, map);
} catch (Exception e) { } catch (Exception e) {
return query; return query;
} }

Loading…
Cancel
Save