Browse Source

依赖最新版本的FineKit

paid
richie 5 years ago
parent
commit
d84ce2adfd
  1. BIN
      lib/commons-pool2-2.0.jar
  2. BIN
      lib/finekit-10.0.jar
  3. BIN
      lib/jsch-0.1.55.jar
  4. 22
      pom.xml
  5. 2
      src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java
  6. 9
      src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
  7. 34
      src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
  8. 4
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
  9. 4
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java
  10. 4
      src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
  11. 8
      src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java
  12. 2
      src/main/java/com/fr/plugin/db/redis/core/emb/Redis.java
  13. 4
      src/main/java/com/fr/plugin/db/redis/core/emb/impl/ProxyRedis.java
  14. 2
      src/main/java/com/fr/plugin/db/redis/core/emb/impl/SimpleRedis.java
  15. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java
  16. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java
  17. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java
  18. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java
  19. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java
  20. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java
  21. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java
  22. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java
  23. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java
  24. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java
  25. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java
  26. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java
  27. 4
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java
  28. 2
      src/main/java/com/fr/plugin/db/redis/help/client/BaseRedisClient.java
  29. 36
      src/main/java/com/fr/plugin/db/redis/help/client/NashornFiles.java
  30. 13
      src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java
  31. 5
      src/main/java/com/fr/plugin/db/redis/help/client/RedisV8Client.java
  32. 11
      src/main/java/com/fr/plugin/db/redis/help/client/V8Files.java
  33. 4
      src/main/java/com/fr/plugin/db/redis/ui/RedisConnectionPane.java
  34. 2
      src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java
  35. 2
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

BIN
lib/commons-pool2-2.0.jar

Binary file not shown.

BIN
lib/finekit-10.0-20190830.jar → lib/finekit-10.0.jar

Binary file not shown.

BIN
lib/jsch-0.1.55.jar

Binary file not shown.

22
pom.xml

@ -16,23 +16,29 @@
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jedis-2.9.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core-sdk</artifactId>
<version>10.0</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/commons-pool2-2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.report</groupId>
<artifactId>designer-base</artifactId>
<version>10.0</version>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jsch-0.1.55.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fanruan.api</groupId>
<artifactId>finekit</artifactId>
<version>1.0</version>
<version>10.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/finekit-10.0-20190830.jar.jar</systemPath>
<systemPath>${project.basedir}/lib/finekit-10.0.jar</systemPath>
</dependency>
</dependencies>
<build>

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

@ -1,7 +1,7 @@
package com.fr.plugin.db.redis;
import com.fanruan.api.design.ui.container.BasicBeanPane;
import com.fr.data.impl.Connection;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractConnectionProvider;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.ui.RedisConnectionPane;

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

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.data.open.BaseConnection;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.security.SecurityKit;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.util.TypeKit;
import com.fr.config.holder.Conf;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.stable.xml.XMLPrintWriter;
@ -16,7 +16,7 @@ import com.fr.stable.xml.XMLableReader;
import java.util.List;
import java.util.Set;
public class RedisDatabaseConnection extends AbstractDatabaseConnection {
public class RedisDatabaseConnection extends BaseConnection {
private static final int DEFAULT_REDIS_PORT = 6379;
@ -71,11 +71,6 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
return RedisPool.getPool().getResource(getHost(), getPort(), getPassword());
}
@Override
public java.sql.Connection createConnection() throws Exception {
return Connection.IGNORE;
}
@Override
public String[] summary(String... args) {
if (ArrayKit.isEmpty(args)) {

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

@ -1,20 +1,22 @@
package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.ConfigurationKit;
import com.fanruan.api.generic.Matcher;
import com.fanruan.api.generic.Runner;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.config.holder.ConfigChangeListener;
import com.fr.config.Configuration;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.emb.impl.ProxyRedis;
import com.fr.plugin.db.redis.core.emb.impl.SimpleRedis;
import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig;
import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
import com.fr.ssh.jsch.JSch;
import com.fr.ssh.jsch.JSchException;
import com.fr.ssh.jsch.Session;
import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.third.redis.clients.jedis.JedisPool;
import com.fr.third.redis.clients.jedis.JedisPoolConfig;
import com.fr.transaction.ValidateProxy;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -29,15 +31,15 @@ public class RedisPool {
private static RedisPool pool = new RedisPool();
static {
ValidateProxy.getInstance().getValidateManager().registerListener(new ConfigChangeListener() {
ConfigurationKit.listenCacheChange(new Matcher<Class<? extends Configuration>>() {
@Override
public void change() {
pool.clearAll();
public boolean match(Class clazz) {
return RedisConnectionPoolConfig.class == clazz;
}
}, new Runner() {
@Override
public boolean accept(Class clazz) {
return RedisConnectionPoolConfig.class == clazz;
public void run() {
pool.clearAll();
}
});
}
@ -79,8 +81,6 @@ public class RedisPool {
config.setMaxTotal(poolConfig.getMaxTotal());
//连接耗尽时是否阻塞, false报异常,true阻塞直到超时, 默认true
config.setBlockWhenExhausted(poolConfig.getBlockWhenExhausted());
//设置的逐出策略类名, 默认DefaultEvictionPolicy(当连接超过最大空闲时间,或连接数超过最大空闲连接数)
config.setEvictionPolicyClassName("com.fr.third.org.apache.commons.pool2.impl.DefaultEvictionPolicy");
//是否启用pool的jmx管理功能, 默认true
config.setJmxEnabled(true);
//MBean ObjectName = new ObjectName("org.apache.commons.pool2:type=GenericObjectPool,name=" + "pool" + i); 默认为"pool", JMX不熟,具体不知道是干啥的...默认就好.
@ -109,7 +109,7 @@ public class RedisPool {
if (StringKit.isNotBlank(password)) {
return new JedisPool(config, host, port, poolConfig.getTimeout(), password);
} else {
return new JedisPool(config, host, port, poolConfig.getTimeout());
return new JedisPool(config, host, port, poolConfig.getTimeout());
}
}

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

@ -3,12 +3,12 @@ package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.xml.XmlHolderKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.open.BaseTableData;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.xml.XmlKit;
import com.fr.base.TableData;
import com.fr.config.holder.Conf;
import com.fr.data.AbstractParameterTableData;
import com.fr.data.impl.Connection;
import com.fr.general.data.DataModel;
import com.fr.intelli.record.Focus;
@ -28,7 +28,7 @@ import com.fr.stable.xml.XMLableReader;
* Created by richie on 2019-03-18
*/
@EnableMetrics
public class RedisScriptTableData extends AbstractParameterTableData {
public class RedisScriptTableData extends BaseTableData {
private static final long serialVersionUID = 1525853354993816818L;

4
src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core;
import com.fr.data.AbstractDataModel;
import com.fanruan.api.data.open.BaseDataModel;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.RedisClient;
import com.fr.plugin.db.redis.help.RedisClientSelector;
@ -14,7 +14,7 @@ import java.util.List;
* @version 10.0
* Created by richie on 2019-03-18
*/
public class RedisScriptTableDataModel extends AbstractDataModel {
public class RedisScriptTableDataModel extends BaseDataModel {
private RedisDatabaseConnection mc;
private String script;

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

@ -3,12 +3,12 @@ package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.xml.XmlHolderKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.open.BaseTableData;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.xml.XmlKit;
import com.fr.base.TableData;
import com.fr.config.holder.Conf;
import com.fr.data.AbstractParameterTableData;
import com.fr.data.impl.Connection;
import com.fr.general.data.DataModel;
import com.fr.intelli.record.Focus;
@ -25,7 +25,7 @@ import com.fr.stable.xml.XMLableReader;
@EnableMetrics
public class RedisTableData extends AbstractParameterTableData {
public class RedisTableData extends BaseTableData {
private static final long serialVersionUID = 7017455818551800001L;
private Conf<Connection> database = HolderKit.obj(null, Connection.class);

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

@ -1,9 +1,9 @@
package com.fr.plugin.db.redis.core;
import com.fanruan.api.data.open.BaseDataModel;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.runtime.PluginKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.AbstractDataModel;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.visit.VisitorFactory;
import com.fr.stable.ParameterProvider;
@ -11,12 +11,12 @@ import com.fr.stable.script.CalculatorProvider;
import java.util.List;
public class RedisTableDataModel extends AbstractDataModel {
public class RedisTableDataModel extends BaseDataModel {
private String[] columnNames;
private List<List<Object>> data;
public RedisTableDataModel(CalculatorProvider calculator, ParameterProvider[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) {
if (PluginKit.isCurrentPluginAvailable()) {
if (PluginContexts.currentContext().isAvailable()) {
initRedisData(calculator, ps, mc, dbIndex, query, script, rowCount);
} else {
throw new RuntimeException("Redis Plugin License Expired!");

2
src/main/java/com/fr/plugin/db/redis/core/emb/Redis.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.emb;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
/**
* @author richie

4
src/main/java/com/fr/plugin/db/redis/core/emb/impl/ProxyRedis.java

@ -1,8 +1,8 @@
package com.fr.plugin.db.redis.core.emb.impl;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.ssh.jsch.Session;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import com.jcraft.jsch.Session;
/**
* @author richie

2
src/main/java/com/fr/plugin/db/redis/core/emb/impl/SimpleRedis.java

@ -1,7 +1,7 @@
package com.fr.plugin.db.redis.core.emb.impl;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
/**
* @author richie

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

@ -5,7 +5,7 @@ import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.plugin.db.redis.core.RedisConstants;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
/**
* Created by richie on 2017/5/2.

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit;
import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.List;

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

@ -13,7 +13,7 @@ import com.fr.plugin.db.redis.core.visit.impl.SetVisitor;
import com.fr.plugin.db.redis.core.visit.impl.ZRangeVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -4,7 +4,7 @@ import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -4,7 +4,7 @@ import com.fanruan.api.util.ArrayKit;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -3,7 +3,7 @@ package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;

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

@ -4,8 +4,8 @@ import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.CalculatorProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.third.redis.clients.jedis.Tuple;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Tuple;
import java.util.ArrayList;
import java.util.List;

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

@ -4,7 +4,7 @@ import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.help.RedisClient;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
/**
* @author richie

36
src/main/java/com/fr/plugin/db/redis/help/client/NashornFiles.java

@ -0,0 +1,36 @@
package com.fr.plugin.db.redis.help.client;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.macro.EncodeConstants;
import com.fanruan.api.util.IOKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import javax.script.ScriptEngine;
import java.io.InputStream;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-09-17
*/
public class NashornFiles {
private ScriptEngine scriptEngine;
public NashornFiles(ScriptEngine scriptEngine) {
this.scriptEngine = scriptEngine;
}
@ScriptBridge
public void require(String filePath) {
InputStream in = IOKit.read(filePath);
if (in != null) {
try {
String text = IOKit.inputStream2String(in, EncodeConstants.ENCODING_UTF_8);
scriptEngine.eval(text);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
}
}
}
}

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

@ -5,7 +5,7 @@ import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
@ -27,7 +27,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
private static final String PREPARE_SCRIPT =
"function unique(array) {var res = [];for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {for (var j = 0, resLen = res.length; j < resLen; j++ ) {if (array[i] === res[j]) {break;}} if (j === resLen) {res.push(array[i])}} return res;}\n" +
"function merge(table, column) {return {content:table, column:column}};";
"function merge(table, column) {return {content:table, column:column}};";
private ScriptEngine scriptEngine;
@ -87,7 +87,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
long start = System.currentTimeMillis();
int len = keys.length;
String[] parameters = new String[len];
for (int i = 0; i < len; i ++) {
for (int i = 0; i < len; i++) {
parameters[i] = String.valueOf(keys[i]);
}
List<String> list = jedis.mget(parameters);
@ -107,6 +107,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
@Override
public SimpleDataModel build(Redis redis, String query, int limit) {
scriptEngine.put("console", new Console());
scriptEngine.put("Files", new NashornFiles(scriptEngine));
scriptEngine.put("redis", new RedisNashornClient(redis.getClient()));
try {
scriptEngine.eval(PREPARE_SCRIPT);
@ -135,12 +136,12 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
Object el = entry.getValue();
if (el instanceof Map) {
Map<String, Object> rowCollection = (Map<String, Object>)entry.getValue();
Map<String, Object> rowCollection = (Map<String, Object>) entry.getValue();
for (Map.Entry<String, Object> rowEntry : rowCollection.entrySet()) {
row.add(rowEntry.getValue());
}
} else if (el instanceof Object[]) {
Object[] array = (Object[])el;
Object[] array = (Object[]) el;
row.addAll(Arrays.asList(array));
}
@ -157,7 +158,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
private static ScriptEngine findScriptEngine() {
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine engine = scriptEngineManager.getEngineByName("nashorn");
if(engine == null) {
if (engine == null) {
List<ScriptEngineFactory> factories = scriptEngineManager.getEngineFactories();
for (ScriptEngineFactory factory : factories) {
ScriptEngine current = factory.getScriptEngine();

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

@ -8,10 +8,9 @@ import com.fr.base.TableData;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.Files;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;
@ -157,7 +156,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
private V8Object initRequire(V8 v8) {
V8Object v8Files = new V8Object(v8);
v8.add("Files", v8Files);
Files console = new Files(v8);
V8Files console = new V8Files(v8);
RedisUtils.registerJavaMethods(v8Files, console);
return v8Files;
}

11
src/main/java/com/fr/plugin/db/redis/help/Files.java → src/main/java/com/fr/plugin/db/redis/help/client/V8Files.java

@ -1,22 +1,23 @@
package com.fr.plugin.db.redis.help;
package com.fr.plugin.db.redis.help.client;
import com.eclipsesource.v8.V8;
import com.fanruan.api.macro.EncodeConstants;
import com.fanruan.api.util.IOKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-19
*/
public class Files {
public class V8Files {
private V8 v8;
public Files(V8 v8) {
public V8Files(V8 v8) {
this.v8 = v8;
}
@ -25,7 +26,7 @@ public class Files {
InputStream in = IOKit.read(filePath);
if (in != null) {
try {
v8.executeVoidScript(IOKit.inputStream2String(in, StandardCharsets.UTF_8));
v8.executeVoidScript(IOKit.inputStream2String(in, EncodeConstants.ENCODING_UTF_8));
} catch (UnsupportedEncodingException ignore) {
}

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

@ -1,7 +1,6 @@
package com.fr.plugin.db.redis.ui;
import com.fanruan.api.conf.ConfigurationKit;
import com.fanruan.api.conf.Runner;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.ui.component.UIActionLabel;
import com.fanruan.api.design.ui.component.UIIntNumberField;
@ -10,10 +9,11 @@ import com.fanruan.api.design.ui.component.UIPasswordField;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.ui.component.UITitledBorder;
import com.fanruan.api.design.ui.container.BasicDialog;
import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.design.work.DatabaseConnectionPane;
import com.fanruan.api.generic.Runner;
import com.fr.design.dialog.DialogActionAdapter;
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.RedisConnectionProxyConfig;

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

@ -2,10 +2,10 @@ package com.fr.plugin.db.redis.ui.value;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.design.work.formula.FormulaUIKit;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.editor.Editor;
import com.fr.design.formula.UIFormula;
import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue;

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

@ -5,7 +5,7 @@ import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.RenderKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.stable.ParameterProvider;
import com.fr.third.redis.clients.jedis.Jedis;
import redis.clients.jedis.Jedis;
import java.lang.reflect.Method;
import java.util.HashMap;

Loading…
Cancel
Save