Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
60aa0c8b
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60aa0c8b
编写于
9月 16, 2020
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
password encrpt
上级
86e8ae6f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
55 addition
and
677 deletion
+55
-677
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheRedisImpl.java
...in/java/com/x/base/core/project/cache/CacheRedisImpl.java
+6
-6
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheRedisNotifyThread.java
...com/x/base/core/project/cache/CacheRedisNotifyThread.java
+3
-3
o2server/x_base_core_project/src/main/java/com/x/base/core/project/script/ScriptFactory.java
...in/java/com/x/base/core/project/script/ScriptFactory.java
+25
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/AbstractRuntime.java
...va/com/x/base/core/project/scripting/AbstractRuntime.java
+0
-108
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ResultObject.java
.../java/com/x/base/core/project/scripting/ResultObject.java
+0
-7
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ScriptHelper.java
.../java/com/x/base/core/project/scripting/ScriptHelper.java
+0
-189
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/Scripting.java
...ain/java/com/x/base/core/project/scripting/Scripting.java
+0
-23
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ScriptingEngine.java
...va/com/x/base/core/project/scripting/ScriptingEngine.java
+0
-253
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/RedisTools.java
...c/main/java/com/x/base/core/project/tools/RedisTools.java
+6
-6
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
.../main/java/com/x/base/core/project/tools/StringTools.java
+3
-0
o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java
...e/src/main/java/com/x/server/console/ResourceFactory.java
+12
-82
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheRedisImpl.java
浏览文件 @
60aa0c8b
...
...
@@ -9,7 +9,7 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
com.x.base.core.project.tools.Redis
Util
;
import
com.x.base.core.project.tools.Redis
Tools
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.config.Cache.Redis
;
...
...
@@ -42,7 +42,7 @@ public class CacheRedisImpl implements Cache {
public
void
put
(
CacheCategory
category
,
CacheKey
key
,
Object
o
)
throws
Exception
{
if
(
null
!=
o
)
{
Jedis
jedis
=
Redis
Util
.
getJedis
();
Jedis
jedis
=
Redis
Tools
.
getJedis
();
if
(
jedis
!=
null
)
{
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
))
{
...
...
@@ -50,7 +50,7 @@ public class CacheRedisImpl implements Cache {
byte
[]
bytes
=
baos
.
toByteArray
();
jedis
.
set
(
concrete
(
category
,
key
).
getBytes
(
StandardCharsets
.
UTF_8
),
bytes
,
setParams
);
}
Redis
Util
.
closeJedis
(
jedis
);
Redis
Tools
.
closeJedis
(
jedis
);
}
}
...
...
@@ -58,10 +58,10 @@ public class CacheRedisImpl implements Cache {
@Override
public
Optional
<
Object
>
get
(
CacheCategory
category
,
CacheKey
key
)
throws
Exception
{
Jedis
jedis
=
Redis
Util
.
getJedis
();
Jedis
jedis
=
Redis
Tools
.
getJedis
();
if
(
jedis
!=
null
)
{
byte
[]
bytes
=
jedis
.
get
(
concrete
(
category
,
key
).
getBytes
(
StandardCharsets
.
UTF_8
));
Redis
Util
.
closeJedis
(
jedis
);
Redis
Tools
.
closeJedis
(
jedis
);
if
((
null
!=
bytes
)
&&
bytes
.
length
>
0
)
{
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
bais
))
{
...
...
@@ -75,7 +75,7 @@ public class CacheRedisImpl implements Cache {
@Override
public
void
shutdown
()
{
this
.
notifyThread
.
interrupt
();
Redis
Util
.
closePool
();
Redis
Tools
.
closePool
();
}
@Override
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheRedisNotifyThread.java
浏览文件 @
60aa0c8b
...
...
@@ -7,7 +7,7 @@ import com.x.base.core.project.cache.Cache.CacheCategory;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.jaxrs.WrapClearCacheRequest
;
import
com.x.base.core.project.tools.Redis
Util
;
import
com.x.base.core.project.tools.Redis
Tools
;
import
redis.clients.jedis.Jedis
;
public
class
CacheRedisNotifyThread
extends
Thread
{
...
...
@@ -28,14 +28,14 @@ public class CacheRedisNotifyThread extends Thread {
// + "([\\s\\S]*)$))";
String
match
=
"*&*"
+
new
CacheCategory
(
wi
.
getClassName
()).
toString
()
+
"*&*"
+
new
CacheKey
(
wi
.
getKeys
()).
toString
()
+
"*"
;
Jedis
jedis
=
Redis
Util
.
getJedis
();
Jedis
jedis
=
Redis
Tools
.
getJedis
();
if
(
jedis
!=
null
)
{
Set
<
String
>
keys
=
jedis
.
keys
(
match
);
if
(!
keys
.
isEmpty
())
{
jedis
.
del
(
keys
.
toArray
(
new
String
[]{}));
jedis
.
flushDB
();
}
Redis
Util
.
closeJedis
(
jedis
);
Redis
Tools
.
closeJedis
(
jedis
);
}
}
catch
(
InterruptedException
ie
)
{
break
;
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/script/ScriptFactory.java
浏览文件 @
60aa0c8b
...
...
@@ -4,20 +4,27 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.regex.Matcher
;
import
javax.script.Compilable
;
import
javax.script.CompiledScript
;
import
javax.script.ScriptContext
;
import
javax.script.ScriptEngine
;
import
javax.script.ScriptEngineManager
;
import
javax.script.ScriptException
;
import
javax.script.SimpleScriptContext
;
import
org.apache.commons.beanutils.PropertyUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.text.StringEscapeUtils
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.tools.StringTools
;
import
jdk.nashorn.api.scripting.ScriptObjectMirror
;
...
...
@@ -269,4 +276,22 @@ public class ScriptFactory {
return
list
;
}
public
static
Object
evalIfScriptText
(
String
text
)
throws
ScriptException
{
if
(
StringUtils
.
isEmpty
(
text
))
{
return
text
;
}
Matcher
matcher
=
StringTools
.
SCRIPTTEXT_REGEX
.
matcher
(
text
);
if
(
matcher
.
matches
())
{
String
eval
=
functionalization
(
StringEscapeUtils
.
unescapeJson
(
matcher
.
group
(
1
)));
ScriptContext
scriptContext
=
new
SimpleScriptContext
();
return
ScriptFactory
.
scriptEngine
.
eval
(
eval
,
scriptContext
);
}
else
{
return
text
;
}
}
public
static
String
evalIfScriptTextAsString
(
String
text
)
throws
Exception
{
return
asString
(
evalIfScriptText
(
text
));
}
}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/AbstractRuntime.java
已删除
100644 → 0
浏览文件 @
86e8ae6f
//package com.x.base.core.project.scripting;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import org.apache.commons.collections4.list.TreeList;
//
//import com.x.base.core.project.annotation.FieldDescribe;
//import com.x.base.core.project.gson.GsonPropertyObject;
//
//public abstract class AbstractRuntime extends GsonPropertyObject {
//
// @FieldDescribe("当前用户")
// private String person = "";
//
// @FieldDescribe("组织")
// private List<String> unitList = new TreeList<>();
//
// @FieldDescribe("群组")
// private List<String> groupList = new TreeList<>();
//
// @FieldDescribe("角色")
// private List<String> roleList = new TreeList<>();
//
// @FieldDescribe("所有群组")
// private List<String> unitAllList = new TreeList<>();
//
// @FieldDescribe("身份")
// private List<String> identityList = new TreeList<>();
//
// @FieldDescribe("参数")
// private Map<String, Object> parameter = new HashMap<>();
//
// @FieldDescribe("数量")
// private Integer count = 0;
//
// public Map<String, Object> getParameter() {
// if (this.parameter == null) {
// this.parameter = new HashMap<String, Object>();
// }
// return this.parameter;
// }
//
// public String getPerson() {
// return person;
// }
//
// public void setPerson(String person) {
// this.person = person;
// }
//
// public List<String> getUnitList() {
// return unitList;
// }
//
// public void setUnitList(List<String> unitList) {
// this.unitList = unitList;
// }
//
// public List<String> getGroupList() {
// return groupList;
// }
//
// public void setGroupList(List<String> groupList) {
// this.groupList = groupList;
// }
//
// public List<String> getRoleList() {
// return roleList;
// }
//
// public void setRoleList(List<String> roleList) {
// this.roleList = roleList;
// }
//
// public List<String> getUnitAllList() {
// return unitAllList;
// }
//
// public void setUnitAllList(List<String> unitAllList) {
// this.unitAllList = unitAllList;
// }
//
// public List<String> getIdentityList() {
// return identityList;
// }
//
// public void setIdentityList(List<String> identityList) {
// this.identityList = identityList;
// }
//
// public Integer getCount() {
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public void setParameter(Map<String, Object> parameter) {
// this.parameter = parameter;
// }
//
//
//
//
//}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ResultObject.java
已删除
100644 → 0
浏览文件 @
86e8ae6f
//package com.x.base.core.project.scripting;
//
//import com.x.base.core.project.gson.GsonPropertyObject;
//
//public class ResultObject extends GsonPropertyObject {
//
//}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ScriptHelper.java
已删除
100644 → 0
浏览文件 @
86e8ae6f
//package com.x.base.core.project.scripting;
//
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.List;
//import java.util.Map;
//import java.util.Map.Entry;
//import java.util.Objects;
//
//import javax.script.ScriptEngine;
//import javax.script.ScriptEngineManager;
//
//import org.apache.commons.beanutils.PropertyUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.commons.lang3.SystemUtils;
//
//import com.x.base.core.project.exception.ExceptionScriptEval;
//import com.x.base.core.project.logger.Logger;
//import com.x.base.core.project.logger.LoggerFactory;
//
//import jdk.nashorn.api.scripting.ScriptObjectMirror;
//
//public class ScriptHelper {
//
// private static Logger logger = LoggerFactory.getLogger(ScriptHelper.class);
//
// private static final String defaultLanguage = "JavaScript";
//
// private static final String distinguishedName = "distinguishedName";
//
// private ScriptEngineManager factory;
// private ScriptEngine engine;
//
// public ScriptHelper() throws Exception {
// this(null, null);
// }
//
// public ScriptHelper(Map<String, Object> map) throws Exception {
// this(map, null);
// }
//
// public ScriptHelper(String initialScriptText) throws Exception {
// this(null, initialScriptText);
// }
//
// public ScriptHelper(Map<String, Object> map, String initialScriptText) throws Exception {
// this.factory = new ScriptEngineManager();
// this.engine = factory.getEngineByName(defaultLanguage);
// if (null != map && (!map.isEmpty())) {
// for (Entry<String, Object> entry : map.entrySet()) {
// engine.put(entry.getKey(), entry.getValue());
// }
// }
// if (StringUtils.isNotBlank(initialScriptText)) {
// engine.eval(initialScriptText);
// }
// }
//
// public void put(String key, Object value) {
// this.engine.put(key, value);
// }
//
// public void put(Map<String, Object> map) {
// for (Entry<String, Object> entry : map.entrySet()) {
// engine.put(entry.getKey(), entry.getValue());
// }
// }
//
// public Object eval(String scriptText) throws Exception {
// StringBuffer sb = new StringBuffer();
// try {
// sb.append("(function(){").append(System.lineSeparator());
// if (StringUtils.isNotEmpty(scriptText)) {
// sb.append(scriptText).append(System.lineSeparator());
// }
// sb.append("})();");
// Object obj = this.engine.eval(sb.toString());
// return obj;
// } catch (Exception e) {
// throw new ExceptionScriptEval(e, sb.toString());
// }
// }
//
// public List<String> evalAsStringList(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return this.readAsStringList(o);
// }
//
// public String evalAsString(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return Objects.toString(o);
// }
//
// public Boolean evalAsBoolean(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return (Boolean) o;
// }
//
// public List<String> evalExtrectDistinguishedName(String scriptText) throws Exception {
// List<String> list = new ArrayList<>();
// Object o = this.eval(scriptText);
// if (null != o) {
// if (o instanceof CharSequence) {
// list.add(Objects.toString(o, ""));
// } else if (o instanceof Iterable) {
// for (Object obj : (Iterable<?>) o) {
// if (null != obj) {
// if (obj instanceof CharSequence) {
// list.add(Objects.toString(obj, ""));
// } else {
// Object d = PropertyUtils.getProperty(obj, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// } else if (o instanceof ScriptObjectMirror) {
// ScriptObjectMirror som = (ScriptObjectMirror) o;
// if (som.isArray()) {
// Object[] objs = (som.to(Object[].class));
// for (Object obj : objs) {
// if (null != obj) {
// if (obj instanceof CharSequence) {
// list.add(Objects.toString(obj, ""));
// } else {
// Object d = PropertyUtils.getProperty(obj, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// } else {
// Object d = PropertyUtils.getProperty(o, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// return list;
// }
//
// private List<String> readAsStringList(Object obj) throws Exception {
// List<String> list = new ArrayList<>();
// for (Object o : this.iterator(obj)) {
// list.add(Objects.toString(o));
// }
// return list;
// }
//
// private List<Object> iterator(Object obj) throws Exception {
// List<Object> results = new ArrayList<>();
// this.iterator(obj, results);
// return results;
// }
//
// private void iterator(Object obj, List<Object> results) throws Exception {
// if (null == obj) {
// return;
// }
// List<Object> list = new ArrayList<>();
// if (obj.getClass().isArray()) {
// for (Object o : (Object[]) obj) {
// list.add(o);
// }
// } else if (obj instanceof Collection) {
// for (Object o : (Collection<?>) obj) {
// list.add(o);
// }
// } else if (obj instanceof ScriptObjectMirror) {
// ScriptObjectMirror som = (ScriptObjectMirror) obj;
// if (som.isArray()) {
// Object[] os = (som.to(Object[].class));
// for (Object o : os) {
// list.add(o);
// }
// } else {
// results.add(som);
// }
// } else {
// results.add(obj);
// }
// for (Object o : list) {
// iterator(o, results);
// }
// }
//}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/Scripting.java
已删除
100644 → 0
浏览文件 @
86e8ae6f
//package com.x.base.core.project.scripting;
//
//import javax.script.ScriptEngineManager;
//
//import com.x.base.core.project.config.Config;
//
//public class Scripting {
//
// private static ScriptEngineManager scriptEngineManager;
//
// public static ScriptingEngine getEngine() {
// if (scriptEngineManager == null) {
// synchronized (Scripting.class) {
// if (scriptEngineManager == null) {
// scriptEngineManager = new ScriptEngineManager();
// }
// }
// }
// ScriptingEngine engine = new ScriptingEngine(scriptEngineManager.getEngineByName(Config.SCRIPTING_ENGINE_NAME));
// return engine;
// }
//
//}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/scripting/ScriptingEngine.java
已删除
100644 → 0
浏览文件 @
86e8ae6f
//package com.x.base.core.project.scripting;
//
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.List;
//import java.util.Map;
//import java.util.Map.Entry;
//import java.util.Objects;
//
//import javax.script.ScriptEngine;
//
//import org.apache.commons.beanutils.PropertyUtils;
//import org.apache.commons.lang3.StringUtils;
//
//import com.x.base.core.project.exception.ExceptionScriptEval;
//import com.x.base.core.project.http.EffectivePerson;
//
//import jdk.nashorn.api.scripting.ScriptObjectMirror;
//
//public class ScriptingEngine {
//
// public ScriptEngine scriptEngine;
//
// private static final String distinguishedName = "distinguishedName";
//
// public static final String BINDINGNAME_GSON = "gson";
// public static final String BINDINGNAME_ORGANIZATION = "organization";
// public static final String BINDINGNAME_WORKCONTEXT = "workContext";
// public static final String BINDINGNAME_DATA = "data";
// public static final String BINDINGNAME_WEBSERVICESCLIENT = "webservicesClient";
// public static final String BINDINGNAME_DICTIONARY = "dictionary";
// public static final String BINDINGNAME__LOOKUP = "lookup";
// public static final String BINDINGNAME_APPLICATIONS = "applications";
// public static final String BINDINGNAME_PARAMETER = "parameter";
// public static final String BINDINGNAME_PARAMETERS = "parameters";
// public static final String BINDINGNAME_EFFECTIVEPERSON = "effectivePerson";
// public static final String BINDINGNAME_JAXRSRESPONSE = "jaxrsResponse";
// public static final String BINDINGNAME_JAXWSRESPONSE = "jaxwsResponse";
// public static final String BINDINGNAME_ROUTEDATA = "routeData";
//
// public static final String BINDINGNAME_ROUTES = "routes";
// public static final String BINDINGNAME_ROUTE = "route";
//
// public static final String BINDINGNAME_RESOURCES = "resources";
//
// public ScriptingEngine(ScriptEngine scriptEngine) {
// this.scriptEngine = scriptEngine;
// }
//
// public ScriptingEngine binding(String key, Object value) {
// this.scriptEngine.put(key, value);
// return this;
// }
//
// public ScriptingEngine binding(Map<String, Object> map) {
// for (Entry<String, Object> entry : map.entrySet()) {
// scriptEngine.put(entry.getKey(), entry.getValue());
// }
// return this;
// }
//
// public ScriptingEngine bindingOrganization(Object o) {
// this.scriptEngine.put(BINDINGNAME_ORGANIZATION, o);
// return this;
// }
//
// public ScriptingEngine bindingWorkContext(Object o) {
// this.scriptEngine.put(BINDINGNAME_WORKCONTEXT, o);
// return this;
// }
//
// public ScriptingEngine bindingData(Object o) {
// this.scriptEngine.put(BINDINGNAME_DATA, o);
// return this;
// }
//
// public ScriptingEngine bindingWebservicesClient(Object o) {
// this.scriptEngine.put(BINDINGNAME_WEBSERVICESCLIENT, o);
// return this;
// }
//
// public ScriptingEngine bindingDictionary(Object o) {
// this.scriptEngine.put(BINDINGNAME_DICTIONARY, o);
// return this;
// }
//
// public ScriptingEngine bindingApplications(Object o) {
// this.scriptEngine.put(BINDINGNAME_APPLICATIONS, o);
// return this;
// }
//
// public ScriptingEngine bindingEffectivePerson(EffectivePerson effectivePerson) {
// this.scriptEngine.put(BINDINGNAME_EFFECTIVEPERSON, effectivePerson);
// return this;
// }
//
// public ScriptingEngine bindingJaxrsResponse(Object o) {
// this.scriptEngine.put(BINDINGNAME_JAXRSRESPONSE, o);
// return this;
// }
//
// public ScriptingEngine bindingJaxwsResponse(Object o) {
// this.scriptEngine.put(BINDINGNAME_JAXWSRESPONSE, o);
// return this;
// }
//
// public ScriptingEngine bindingParameter(Object o) {
// this.scriptEngine.put(BINDINGNAME_PARAMETER, o);
// return this;
// }
//
// public ScriptingEngine bindingParameters(Object o) {
// this.scriptEngine.put(BINDINGNAME_PARAMETERS, o);
// return this;
// }
//
// public ScriptingEngine bindingRouteData(String str) {
// this.scriptEngine.put(BINDINGNAME_ROUTEDATA, str);
// return this;
// }
//
// public ScriptingEngine bindingRoutes(Object o) {
// this.scriptEngine.put(BINDINGNAME_ROUTES, o);
// return this;
// }
//
// public ScriptingEngine bindingRoute(Object o) {
// this.scriptEngine.put(BINDINGNAME_ROUTE, o);
// return this;
// }
//
// public Object eval(String scriptText) throws Exception {
// StringBuffer sb = new StringBuffer();
// try {
// sb.append("(function(){").append(System.lineSeparator());
// if (StringUtils.isNotEmpty(scriptText)) {
// sb.append(scriptText).append(System.lineSeparator());
// }
// sb.append("})();");
// Object obj = this.scriptEngine.eval(sb.toString());
// return obj;
// } catch (Exception e) {
// throw new ExceptionScriptEval(e, sb.toString());
// }
// }
//
// public List<String> evalAsStringList(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return this.readAsStringList(o);
// }
//
// public String evalAsString(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return Objects.toString(o);
// }
//
// public Boolean evalAsBoolean(String scriptText) throws Exception {
// Object o = this.eval(scriptText);
// return (Boolean) o;
// }
//
// public List<String> evalExtrectDistinguishedName(String scriptText) throws Exception {
// List<String> list = new ArrayList<>();
// Object o = this.eval(scriptText);
// if (null != o) {
// if (o instanceof CharSequence) {
// list.add(Objects.toString(o, ""));
// } else if (o instanceof Iterable) {
// for (Object obj : (Iterable<?>) o) {
// if (null != obj) {
// if (obj instanceof CharSequence) {
// list.add(Objects.toString(obj, ""));
// } else {
// Object d = PropertyUtils.getProperty(obj, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// } else if (o instanceof ScriptObjectMirror) {
// ScriptObjectMirror som = (ScriptObjectMirror) o;
// if (som.isArray()) {
// Object[] objs = (som.to(Object[].class));
// for (Object obj : objs) {
// if (null != obj) {
// if (obj instanceof CharSequence) {
// list.add(Objects.toString(obj, ""));
// } else {
// Object d = PropertyUtils.getProperty(obj, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// } else {
// Object d = PropertyUtils.getProperty(o, distinguishedName);
// if (null != d) {
// list.add(Objects.toString(d, ""));
// }
// }
// }
// }
// return list;
// }
//
// private List<String> readAsStringList(Object obj) throws Exception {
// List<String> list = new ArrayList<>();
// for (Object o : this.iterator(obj)) {
// list.add(Objects.toString(o));
// }
// return list;
// }
//
// private List<Object> iterator(Object obj) throws Exception {
// List<Object> results = new ArrayList<>();
// this.iterator(obj, results);
// return results;
// }
//
// private void iterator(Object obj, List<Object> results) throws Exception {
// if (null == obj) {
// return;
// }
// List<Object> list = new ArrayList<>();
// if (obj.getClass().isArray()) {
// for (Object o : (Object[]) obj) {
// list.add(o);
// }
// } else if (obj instanceof Collection) {
// for (Object o : (Collection<?>) obj) {
// list.add(o);
// }
// } else if (obj instanceof ScriptObjectMirror) {
// ScriptObjectMirror som = (ScriptObjectMirror) obj;
// if (som.isArray()) {
// Object[] os = (som.to(Object[].class));
// for (Object o : os) {
// list.add(o);
// }
// } else {
// results.add(som);
// }
// } else {
// results.add(obj);
// }
// for (Object o : list) {
// iterator(o, results);
// }
// }
//
//}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/Redis
Util
.java
→
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/Redis
Tools
.java
浏览文件 @
60aa0c8b
...
...
@@ -12,24 +12,24 @@ import redis.clients.jedis.Jedis;
import
redis.clients.jedis.JedisPool
;
import
redis.clients.jedis.JedisPoolConfig
;
public
class
Redis
Util
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Redis
Util
.
class
);
public
class
Redis
Tools
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Redis
Tools
.
class
);
private
static
ReentrantLock
lockPool
=
new
ReentrantLock
();
private
static
Redis
Util
instance
;
private
static
Redis
Tools
instance
;
private
static
JedisPool
jedisPool
;
private
static
ReentrantLock
lock
=
new
ReentrantLock
();
private
Redis
Util
()
{
private
Redis
Tools
()
{
}
public
static
Redis
Util
getInstance
()
{
public
static
Redis
Tools
getInstance
()
{
if
(
instance
==
null
)
{
lock
.
lock
();
if
(
instance
==
null
)
{
instance
=
new
Redis
Util
();
instance
=
new
Redis
Tools
();
}
lock
.
unlock
();
}
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
浏览文件 @
60aa0c8b
...
...
@@ -30,6 +30,9 @@ import org.apache.commons.lang3.reflect.FieldUtils;
import
org.slf4j.helpers.MessageFormatter
;
public
class
StringTools
{
// 脚本文本
public
static
final
Pattern
SCRIPTTEXT_REGEX
=
Pattern
.
compile
(
"^\\((.+?)\\)$"
);
public
static
final
Pattern
MOBILE_REGEX
=
Pattern
.
compile
(
"(^(\\+)?0{0,2}852\\d{8}$)|(^(\\+)?0{0,2}853\\d{8}$)|(^(\\+)?0{0,2}886\\d{9}$)|(^1(3|4|5|6|7|8|9)\\d{9}$)"
);
/** 中文,英文,数字,-,.· 【】() */
...
...
o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java
浏览文件 @
60aa0c8b
...
...
@@ -31,6 +31,7 @@ import com.x.base.core.project.config.DataServer;
import
com.x.base.core.project.config.ExternalDataSource
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.script.ScriptFactory
;
import
com.x.base.core.project.tools.ClassLoaderTools
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
com.x.base.core.project.tools.ListTools
;
...
...
@@ -44,6 +45,10 @@ public class ResourceFactory {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ResourceFactory
.
class
);
private
ResourceFactory
()
{
// nothing
}
public
static
void
bind
()
throws
Exception
{
try
(
ScanResult
sr
=
new
ClassGraph
()
.
addClassLoader
(
ClassLoaderTools
.
urlClassLoader
(
true
,
false
,
true
,
true
,
true
)).
enableAnnotationInfo
()
...
...
@@ -82,29 +87,9 @@ public class ResourceFactory {
external_druid_c3p0
();
}
private
static
void
external_dbcp2
()
throws
Exception
{
for
(
ExternalDataSource
ds
:
Config
.
externalDataSources
())
{
BasicDataSource
dataSource
=
new
BasicDataSource
();
dataSource
.
setDriverClassName
(
ds
.
getDriverClassName
());
dataSource
.
setUrl
(
ds
.
getUrl
());
dataSource
.
setInitialSize
(
0
);
dataSource
.
setMinIdle
(
0
);
dataSource
.
setMaxTotal
(
ds
.
getMaxTotal
());
dataSource
.
setMaxIdle
(
ds
.
getMaxTotal
());
dataSource
.
setTestOnCreate
(
false
);
dataSource
.
setTestWhileIdle
(
false
);
dataSource
.
setTestOnReturn
(
false
);
dataSource
.
setTestOnBorrow
(
false
);
dataSource
.
setUsername
(
ds
.
getUsername
());
dataSource
.
setPassword
(
ds
.
getPassword
());
String
name
=
Config
.
externalDataSources
().
name
(
ds
);
new
Resource
(
Config
.
RESOURCE_JDBC_PREFIX
+
name
,
dataSource
);
}
}
private
static
void
external_druid_c3p0
()
throws
Exception
{
for
(
ExternalDataSource
ds
:
Config
.
externalDataSources
())
{
if
(
!
ds
.
getEnable
(
))
{
if
(
BooleanUtils
.
isNotTrue
(
ds
.
getEnable
()
))
{
continue
;
}
DruidDataSourceC3P0Adapter
dataSource
=
new
DruidDataSourceC3P0Adapter
();
...
...
@@ -112,16 +97,16 @@ public class ResourceFactory {
dataSource
.
setDriverClass
(
ds
.
getDriverClassName
());
dataSource
.
setPreferredTestQuery
(
SlicePropertiesBuilder
.
validationQueryOfUrl
(
ds
.
getUrl
()));
dataSource
.
setUser
(
ds
.
getUsername
());
dataSource
.
setPassword
(
ds
.
getPassword
(
));
dataSource
.
setPassword
(
ScriptFactory
.
evalIfScriptTextAsString
(
ds
.
getPassword
()
));
dataSource
.
setMaxPoolSize
(
ds
.
getMaxTotal
());
dataSource
.
setMinPoolSize
(
ds
.
getMaxIdle
());
/
* 增加校验 */
/
/ 增加校验
dataSource
.
setTestConnectionOnCheckin
(
true
);
dataSource
.
setAcquireIncrement
(
0
);
dataSource
.
setTestConnectionOnCheckout
(
true
);
dataSource
.
setAcquireIncrement
(
2
);
if
(
BooleanUtils
.
isTrue
(
ds
.
getStatEnable
()))
{
dataSource
.
setFilters
(
ds
.
getStatFilter
());
Properties
properties
=
new
Properties
();
// property name="connectionProperties" value="druid.stat.slowSqlMillis=5000
properties
.
setProperty
(
"druid.stat.slowSqlMillis"
,
ds
.
getSlowSqlMillis
().
toString
());
dataSource
.
setProperties
(
properties
);
}
...
...
@@ -132,8 +117,6 @@ public class ResourceFactory {
private
static
void
internal
()
throws
Exception
{
internal_driud_c3p0
();
// internal_driud();
// internal_dbcp2();
}
private
static
void
internal_driud_c3p0
()
throws
Exception
{
...
...
@@ -141,7 +124,7 @@ public class ResourceFactory {
DruidDataSourceC3P0Adapter
dataSource
=
new
DruidDataSourceC3P0Adapter
();
String
url
=
"jdbc:h2:tcp://"
+
entry
.
getKey
()
+
":"
+
entry
.
getValue
().
getTcpPort
()
+
"/X;LOCK_MODE=0;DEFAULT_LOCK_TIMEOUT="
+
entry
.
getValue
().
getLockTimeout
()
+
";JMX="
+
(
entry
.
getValue
().
getJmxEnable
(
)
?
"TRUE"
:
"FALSE"
)
+
";CACHE_SIZE="
+
(
BooleanUtils
.
isTrue
(
entry
.
getValue
().
getJmxEnable
()
)
?
"TRUE"
:
"FALSE"
)
+
";CACHE_SIZE="
+
(
entry
.
getValue
().
getCacheSize
()
*
1024
);
dataSource
.
setJdbcUrl
(
url
);
dataSource
.
setDriverClass
(
SlicePropertiesBuilder
.
driver_h2
);
...
...
@@ -151,10 +134,9 @@ public class ResourceFactory {
dataSource
.
setMaxPoolSize
(
entry
.
getValue
().
getMaxTotal
());
dataSource
.
setMinPoolSize
(
entry
.
getValue
().
getMaxIdle
());
dataSource
.
setAcquireIncrement
(
0
);
if
(
entry
.
getValue
().
getStatEnable
(
))
{
if
(
BooleanUtils
.
isTrue
(
entry
.
getValue
().
getStatEnable
()
))
{
dataSource
.
setFilters
(
entry
.
getValue
().
getStatFilter
());
Properties
properties
=
new
Properties
();
// property name="connectionProperties" value="druid.stat.slowSqlMillis=5000
properties
.
setProperty
(
"druid.stat.slowSqlMillis"
,
entry
.
getValue
().
getSlowSqlMillis
().
toString
());
dataSource
.
setProperties
(
properties
);
}
...
...
@@ -163,58 +145,6 @@ public class ResourceFactory {
}
}
private
static
void
internal_dbcp2
()
throws
Exception
{
for
(
Entry
<
String
,
DataServer
>
entry
:
Config
.
nodes
().
dataServers
().
entrySet
())
{
BasicDataSource
dataSource
=
new
BasicDataSource
();
String
url
=
"jdbc:h2:tcp://"
+
entry
.
getKey
()
+
":"
+
entry
.
getValue
().
getTcpPort
()
+
"/X;LOCK_MODE=0;DEFAULT_LOCK_TIMEOUT="
+
entry
.
getValue
().
getLockTimeout
()
+
";JMX="
+
(
entry
.
getValue
().
getJmxEnable
()
?
"TRUE"
:
"FALSE"
)
+
";CACHE_SIZE="
+
(
entry
.
getValue
().
getCacheSize
()
*
1024
);
dataSource
.
setDriverClassName
(
SlicePropertiesBuilder
.
driver_h2
);
dataSource
.
setUrl
(
url
);
dataSource
.
setInitialSize
(
0
);
dataSource
.
setMinIdle
(
0
);
dataSource
.
setMaxTotal
(
50
);
dataSource
.
setMaxIdle
(
50
);
dataSource
.
setUsername
(
"sa"
);
dataSource
.
setTestOnCreate
(
false
);
dataSource
.
setTestWhileIdle
(
false
);
dataSource
.
setTestOnReturn
(
false
);
dataSource
.
setTestOnBorrow
(
false
);
dataSource
.
setPassword
(
Config
.
token
().
getPassword
());
String
name
=
Config
.
nodes
().
dataServers
().
name
(
entry
.
getValue
());
new
Resource
(
Config
.
RESOURCE_JDBC_PREFIX
+
name
,
dataSource
);
}
}
private
static
void
internal_driud
()
throws
Exception
{
for
(
Entry
<
String
,
DataServer
>
entry
:
Config
.
nodes
().
dataServers
().
entrySet
())
{
DruidDataSource
dataSource
=
new
DruidDataSource
();
String
url
=
"jdbc:h2:tcp://"
+
entry
.
getKey
()
+
":"
+
entry
.
getValue
().
getTcpPort
()
+
"/X;LOCK_MODE=0;DEFAULT_LOCK_TIMEOUT="
+
entry
.
getValue
().
getLockTimeout
()
+
";JMX="
+
(
entry
.
getValue
().
getJmxEnable
()
?
"TRUE"
:
"FALSE"
)
+
";CACHE_SIZE="
+
(
entry
.
getValue
().
getCacheSize
()
*
1024
);
dataSource
.
setDriverClassName
(
SlicePropertiesBuilder
.
driver_h2
);
dataSource
.
setUrl
(
url
);
dataSource
.
setInitialSize
(
0
);
dataSource
.
setMinIdle
(
0
);
dataSource
.
setMaxActive
(
50
);
dataSource
.
setUsername
(
"sa"
);
dataSource
.
setTestWhileIdle
(
false
);
dataSource
.
setTestOnReturn
(
false
);
dataSource
.
setTestOnBorrow
(
false
);
dataSource
.
setFilters
(
"stat"
);
dataSource
.
setPassword
(
Config
.
token
().
getPassword
());
dataSource
.
init
();
String
name
=
Config
.
nodes
().
dataServers
().
name
(
entry
.
getValue
());
new
Resource
(
Config
.
RESOURCE_JDBC_PREFIX
+
name
,
dataSource
);
}
}
private
static
void
containerEntityNames
(
ScanResult
sr
)
throws
Exception
{
List
<
String
>
list
=
new
ArrayList
<>();
for
(
ClassInfo
info
:
sr
.
getClassesWithAnnotation
(
ContainerEntity
.
class
.
getName
()))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录