diff --git a/plugin.xml b/plugin.xml
index 5685502..85306b7 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -12,6 +12,7 @@
[2019-09-29]修复无法兼容老版本的问题。
[2019-09-18]支持手动选择不同JavaScript脚本引擎。
[2019-09-18]支持连接redis集群。
+ [2019-09-03]适配新数据连接接口。
[2019-08-26]给console增加一个engine()函数,判断使用的脚本引擎名字。
[2019-08-26]不支持V8引擎的机器上使用JDK内置的脚本引擎(仅支持ES5语法)。
[2019-03-21]现在可以通过跳板服务连接redis。
@@ -36,6 +37,9 @@
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/db/redis/RedisConnectionComponent.java b/src/main/java/com/fr/plugin/db/redis/RedisConnectionComponent.java
new file mode 100644
index 0000000..fff856b
--- /dev/null
+++ b/src/main/java/com/fr/plugin/db/redis/RedisConnectionComponent.java
@@ -0,0 +1,13 @@
+package com.fr.plugin.db.redis;
+
+import com.fr.web.struct.Component;
+import com.fr.web.struct.browser.RequestClient;
+import com.fr.web.struct.category.ScriptPath;
+
+public class RedisConnectionComponent extends Component {
+ public static final RedisConnectionComponent KEY = new RedisConnectionComponent();
+ @Override
+ public ScriptPath script(RequestClient req) {
+ return ScriptPath.build("com/fr/plugin/db/redis/web/redis.js");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/db/redis/RedisUniversalConnectionImpl.java b/src/main/java/com/fr/plugin/db/redis/RedisUniversalConnectionImpl.java
new file mode 100644
index 0000000..18dea85
--- /dev/null
+++ b/src/main/java/com/fr/plugin/db/redis/RedisUniversalConnectionImpl.java
@@ -0,0 +1,105 @@
+package com.fr.plugin.db.redis;
+
+import com.fr.decision.fun.impl.AbstractUniversalConnectionProvider;
+import com.fr.decision.webservice.utils.DecisionServiceConstants;
+import com.fr.decision.webservice.utils.WebServiceUtils;
+import com.fr.json.JSONObject;
+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;
+import com.fr.stable.AssistUtils;
+import com.fr.transaction.Configurations;
+import com.fr.transaction.WorkerAdaptor;
+import com.fr.web.struct.Atom;
+
+
+public class RedisUniversalConnectionImpl extends AbstractUniversalConnectionProvider {
+
+ private static final String BASIC_INFO = "basicConfig";
+ private static final String POOL_INFO = "poolConfig";
+ private static final String PROXY_INFO = "proxyConfig";
+
+
+ @Override
+ public String nameForConnection() {
+ return "Redis";
+ }
+
+ @Override
+ public String iconPathForConnection() {
+ return "/com/fr/plugin/db/redis/images/redis.png";
+ }
+
+ @Override
+ public Class classForConnection() {
+ return RedisDatabaseConnection.class;
+ }
+
+ @Override
+ public Atom client() {
+ return RedisConnectionComponent.KEY;
+ }
+
+ @Override
+ public JSONObject serialize(RedisDatabaseConnection connection) {
+ JSONObject jsonObject = new JSONObject();
+ try {
+ jsonObject.put(BASIC_INFO, JSONObject.mapFrom(connection.clone()));
+ //将ConnectionPoolConfig和RedisConnectionProxyConfig也一次塞给前台展示
+ jsonObject.put(POOL_INFO, JSONObject.mapFrom(RedisConnectionPoolConfig.getInstance().clone()));
+ JSONObject proxy = JSONObject.mapFrom(RedisConnectionProxyConfig.getInstance().clone());
+ proxy.put("password", DecisionServiceConstants.DEFAULT_PASSWORD);
+ jsonObject.put(PROXY_INFO, proxy);
+ } catch (CloneNotSupportedException ignore) {
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public RedisDatabaseConnection deserialize(RedisDatabaseConnection oldConnection, JSONObject pluginData) {
+ JSONObject redisDatabaseConnection = getRedisDataConnection(pluginData);
+ if (oldConnection != null && DecisionServiceConstants.DEFAULT_PASSWORD.equals(redisDatabaseConnection.getString("password"))) {
+ redisDatabaseConnection.put("password", oldConnection.getPassword());
+ } else {
+ redisDatabaseConnection.put("password", WebServiceUtils.getBase64DecodeStr(redisDatabaseConnection.getString("password")));
+ }
+ return redisDatabaseConnection.mapTo(RedisDatabaseConnection.class);
+ }
+
+ private JSONObject getRedisDataConnection(JSONObject object) {
+
+ final JSONObject pool = object.getJSONObject(POOL_INFO);
+ if (pool != null) {
+ final RedisConnectionPoolConfig poolConfig = pool.mapTo(RedisConnectionPoolConfig.class);
+ Configurations.update(new WorkerAdaptor(RedisConnectionPoolConfig.class) {
+ @Override
+ public void run() {
+ RedisConnectionPoolConfig.getInstance().setBlockWhenExhausted(poolConfig.getBlockWhenExhausted());
+ RedisConnectionPoolConfig.getInstance().setLifo(poolConfig.getLifo());
+ RedisConnectionPoolConfig.getInstance().setMaxIdle(poolConfig.getMaxIdle());
+ RedisConnectionPoolConfig.getInstance().setMaxTotal(poolConfig.getMaxTotal());
+ RedisConnectionPoolConfig.getInstance().setMaxWait(poolConfig.getMaxWait());
+ RedisConnectionPoolConfig.getInstance().setTimeout(poolConfig.getTimeout());
+ }
+ });
+ }
+ final JSONObject proxy = object.getJSONObject(PROXY_INFO);
+ if (proxy != null) {
+ final RedisConnectionProxyConfig proxyConfig = proxy.mapTo(RedisConnectionProxyConfig.class);
+ Configurations.update(new WorkerAdaptor(RedisConnectionProxyConfig.class) {
+ @Override
+ public void run() {
+ RedisConnectionProxyConfig.getInstance().setHost(proxyConfig.getHost());
+ RedisConnectionProxyConfig.getInstance().setOpen(proxyConfig.isOpen());
+ if (!AssistUtils.equals(proxyConfig.getPassword(), DecisionServiceConstants.DEFAULT_PASSWORD)) {
+ RedisConnectionProxyConfig.getInstance().setPassword(WebServiceUtils.getBase64DecodeStr(proxyConfig.getPassword()));
+ }
+ RedisConnectionProxyConfig.getInstance().setPort(proxyConfig.getPort());
+ RedisConnectionProxyConfig.getInstance().setPrivateKeyPath(proxyConfig.getPrivateKeyPath());
+ RedisConnectionProxyConfig.getInstance().setUsername(proxyConfig.getUsername());
+ }
+ });
+ }
+ return object.getJSONObject(BASIC_INFO);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
index a78ac3e..5946fd5 100755
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
@@ -12,10 +12,12 @@ import com.fr.data.impl.Connection;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
+import com.fr.third.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import java.util.Set;
+@JsonIgnoreProperties({"id", "data", "classInfo", "nameSpace", "driver"})
public class RedisDatabaseConnection extends BaseConnection {
private static final int DEFAULT_REDIS_PORT = 6379;
diff --git a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
index 36d4f74..9edd9eb 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
@@ -3,6 +3,7 @@ package com.fr.plugin.db.redis.core.pool;
import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.Conf;
+import com.fr.third.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
@@ -10,6 +11,7 @@ import com.fr.config.holder.Conf;
* @version 10.0
* Created by richie on 2019-03-21
*/
+@JsonIgnoreProperties("nameSpace")
public class RedisConnectionPoolConfig extends BaseConfiguration {
private static volatile RedisConnectionPoolConfig instance = null;
diff --git a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java
index 5eb5509..d4f6e6a 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java
@@ -5,12 +5,14 @@ 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.third.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-21
*/
+@JsonIgnoreProperties("nameSpace")
public class RedisConnectionProxyConfig extends BaseConfiguration {
private static volatile RedisConnectionProxyConfig instance = null;
diff --git a/src/main/resources/com/fr/plugin/db/redis/web/demo-tabledate-redis-web.zip b/src/main/resources/com/fr/plugin/db/redis/web/demo-tabledate-redis-web.zip
new file mode 100644
index 0000000..8049dd9
Binary files /dev/null and b/src/main/resources/com/fr/plugin/db/redis/web/demo-tabledate-redis-web.zip differ
diff --git a/src/main/resources/com/fr/plugin/db/redis/web/redis.js b/src/main/resources/com/fr/plugin/db/redis/web/redis.js
new file mode 100644
index 0000000..a273367
--- /dev/null
+++ b/src/main/resources/com/fr/plugin/db/redis/web/redis.js
@@ -0,0 +1 @@
+/*! time: 2019-9-4 13:44:09 */!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){e.exports=o(1)},function(e,t,o){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{};return function(o){return function(n){function r(){return i(this,r),c(this,p(r).apply(this,arguments))}return l(r,o),u(r,[{key:"_store",value:function(){var o=t.props?t.props.apply(this):void 0;return BI.Models.getModel(e.xtype,o)}}]),r}()}}(Te)((Ie=Be=function(e){function t(){var e,o,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,a=new Array(i),u=0;u