提交 95e80523 编写于 作者: O o2null

Merge branch 'fix/reloadClassLoader' into 'develop'

修复classLoader的bug

See merge request o2oa/o2oa!478
......@@ -154,54 +154,6 @@ public abstract class JpaObject extends GsonPropertyObject implements Serializab
this.sequence = sequence;
}
// /* 暂存String */
// @Column(length = length_255B, name = ColumnNamePrefix + scratchString_FIELDNAME)
// private String scratchString;
//
// /* 暂存Boolean */
// @Column(name = ColumnNamePrefix + scratchBoolean_FIELDNAME)
// private Boolean scratchBoolean;
//
// /* 暂存Date */
// @Column(name = ColumnNamePrefix + scratchDate_FIELDNAME)
// private Date scratchDate;
//
// /* 暂存Integer */
// @Column(name = ColumnNamePrefix + scratchInteger_FIELDNAME)
// private Date scratchInteger;
//
// public String getScratchString() {
// return scratchString;
// }
//
// public void setScratchString(String scratchString) {
// this.scratchString = scratchString;
// }
//
// public Boolean getScratchBoolean() {
// return scratchBoolean;
// }
//
// public void setScratchBoolean(Boolean scratchBoolean) {
// this.scratchBoolean = scratchBoolean;
// }
//
// public Date getScratchDate() {
// return scratchDate;
// }
//
// public void setScratchDate(Date scratchDate) {
// this.scratchDate = scratchDate;
// }
//
// public Date getScratchInteger() {
// return scratchInteger;
// }
//
// public void setScratchInteger(Date scratchInteger) {
// this.scratchInteger = scratchInteger;
// }
public static final int length_1B = 1;
public static final int length_2B = 2;
......@@ -265,10 +217,10 @@ public abstract class JpaObject extends GsonPropertyObject implements Serializab
public static final String TYPE_LONG = "long";
public static final String TYPE_FLOAT = "float";
public static final String TYPE_DOUBLE = "double";
public static final String TYPE_BOOLEAN = "boolean";
public static final String TYPE_DATETIME = "dateTime";
public static final String TYPE_DATE = "date";
public static final String TYPE_TIME = "time";
public static final String TYPE_DATETIME = "dateTime";
public static final String TYPE_BOOLEAN = "boolean";
public static final String TYPE_JSONPROPERTIES = "JsonProperties";
public static final String TYPE_BYTEARRAY = "byteArray";
......@@ -278,16 +230,19 @@ public abstract class JpaObject extends GsonPropertyObject implements Serializab
public static final String TYPE_FLOATLIST = "floatList";
public static final String TYPE_DOUBLELIST = "doubleList";
public static final String TYPE_DATETIMELIST = "dateTimeList";
public static final String TYPE_DATELIST = "dateList";
public static final String TYPE_BOOLEANLIST = "booleanList";
public static final String TYPE_STRINGLOB = "stringLob";
public static final String TYPE_STRINGMAP = "stringMap";
public static final String TYPE_INTEGERMAP = "integerMap";
public static final String TYPE_LONGMAP = "longMap";
public static final String TYPE_FLOATMAP = "floatMap";
public static final String TYPE_DOUBLEMAP = "doubleMap";
public static final String TYPE_BOOLEANMAP = "booleanMap";
public static final String TYPE_DATETIMEMAP = "dateTimeMap";
public static final String TYPE_DATEMAP = "dateMap";
public static final String TYPE_BOOLEANMAP = "booleanMap";
public static final String[] ID_DISTRIBUTEFACTOR = new String[] { id_FIELDNAME, distributeFactor_FIELDNAME };
......
......@@ -61,7 +61,7 @@ public class DataItemConverter<T extends DataItem> {
}
private List<T> disassemble(JsonElement root, List<String> paths, List<T> list) throws Exception {
T t = clz.newInstance();
T t = clz.getDeclaredConstructor().newInstance();
t.path(paths);
list.add(t);
if (root.isJsonPrimitive()) {
......@@ -253,25 +253,6 @@ public class DataItemConverter<T extends DataItem> {
return ObjectUtils.compare(pl1, pl2);
}
// public List<T> subtract(List<T> l1, List<T> l2) throws Exception {
// List<T> result = new ArrayList<>();
// List<T> list2 = new ArrayList<>(l2);
// T dummy = null;
// next: for (T t1 : l1) {
// if (null != dummy) {
// list2.remove(dummy);
// }
// for (T t2 : list2) {
// if (this.equate(t1, t2)) {
// dummy = t2;
// continue next;
// }
// }
// result.add(t1);
// }
// return result;
// }
public boolean equate(T t1, T t2) {
if (!Objects.equals(t1.getPath0(), t2.getPath0())) {
return false;
......@@ -447,41 +428,4 @@ public class DataItemConverter<T extends DataItem> {
return true;
}
}
// private final List<Pair<BiFunction<Object, Object, Integer>, Function<T, Object>>> COMPARE_SEQ = Arrays.asList(
// comparePathLocationOf(DataItem::getPath0Location), comparePathLocationOf(DataItem::getPath1Location),
// comparePathOf(DataItem::getPath1), comparePathLocationOf(DataItem::getPath2Location),
// comparePathOf(DataItem::getPath2), comparePathLocationOf(DataItem::getPath3Location),
// comparePathOf(DataItem::getPath3), comparePathLocationOf(DataItem::getPath4Location),
// comparePathOf(DataItem::getPath4), comparePathLocationOf(DataItem::getPath5Location),
// comparePathOf(DataItem::getPath5), comparePathLocationOf(DataItem::getPath6Location),
// comparePathOf(DataItem::getPath6), comparePathLocationOf(DataItem::getPath7Location),
// comparePathOf(DataItem::getPath7));
//
// private Pair<BiFunction<Object, Object, Integer>, Function<T, Object>> comparePathLocationOf(
// final Function<T, Object> mapper) {
// return Pair.of(DataItemConverter::comparePathLocation, mapper);
// }
//
// private Pair<BiFunction<Object, Object, Integer>, Function<T, Object>> comparePathOf(
// final Function<T, Object> mapper) {
// return Pair.of(DataItemConverter::comparePath, mapper);
// }
//
// private final Comparator<T> comparator = new Comparator<T>() {
// public int compare(final T o1, final T o2) {
// return COMPARE_SEQ.stream()
// .mapToInt(t -> {
// final Function<T, Object> getter = Pair.getRight();
// return Pair.getLeft().apply(getter.apply(o1), getter.apply(o2));
// })
// .filter(t -> t != 0)
// .findAny()
// .orElse(0);
// }
// }
//
// public void sort(List<T> list) {
// Collections.sort(list, comparator);
// }
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.message.MessageConnector;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
import com.x.base.core.project.tools.ListTools;
......
......@@ -324,7 +324,6 @@ public class Business {
File jar = new File(Config.dir_dynamic_jars(true), DynamicEntity.JAR_PREFIX + query + DOT_JAR);
JarTools.jar(target, jar);
LOGGER.info("build table reload jar:{}", jar.getName());
this.reloadClassLoader();
}
FileUtils.cleanDirectory(dir);
return result;
......@@ -363,7 +362,7 @@ public class Business {
}
private void reloadClassLoader() {
public static void reloadClassLoader() {
try {
EntityManagerContainerFactory.close();
Business.refreshDynamicEntityClassLoader();
......
......@@ -42,7 +42,7 @@ class ActionBuildQueryDispatch extends BaseAction {
List<Application> apps = ThisApplication.context().applications().get(x_query_assemble_designer.class);
if (ListTools.isNotEmpty(apps)) {
apps.stream().forEach(o -> {
String url = o.getUrlJaxrsRoot() + "table/" + queryId + "/build?timestamp="
String url = o.getUrlJaxrsRoot() + "table/query/" + queryId + "/build?timestamp="
+ System.currentTimeMillis();
LOGGER.info("{} do dispatch build query {} table request to : {}.",
effectivePerson.getDistinguishedName(), queryId, url);
......@@ -53,6 +53,7 @@ class ActionBuildQueryDispatch extends BaseAction {
}
});
}
refreshDesigner();
refreshSurface();
refreshProcessing();
wo.setValue(true);
......@@ -62,6 +63,21 @@ class ActionBuildQueryDispatch extends BaseAction {
return result;
}
private void refreshDesigner() throws Exception {
List<Application> apps = ThisApplication.context().applications().get(x_query_assemble_designer.class);
if (ListTools.isNotEmpty(apps)) {
apps.stream().forEach(o -> {
try {
String url = o.getUrlJaxrsRoot() + "table/reload/dynamic";
LOGGER.info("refresh surface:{}.", url);
CipherConnectionAction.get(false, url);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
private void refreshSurface() throws Exception {
List<Application> apps = ThisApplication.context().applications().get(x_query_assemble_surface.class);
if (ListTools.isNotEmpty(apps)) {
......
package com.x.query.assemble.designer.jaxrs.table;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.designer.Business;
class ActionReloadDynamic extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionReloadDynamic.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Business.reloadClassLoader();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
private static final long serialVersionUID = -5755898083219447939L;
}
}
......@@ -33,7 +33,7 @@ import com.x.base.core.project.logger.LoggerFactory;
@JaxrsDescribe("表")
public class TableAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TableAction.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TableAction.class);
@JaxrsMethodDescribe(value = "根据query列示table对象.", action = ActionListWithQuery.class)
@GET
......@@ -47,15 +47,12 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionListWithQuery().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "编译指定应用所有表,执行后需要立即重新启动,支持集群环境.", action = ActionBuildQueryDispatch.class)
@GET
@Path("{query}/build/dispatch")
......@@ -68,7 +65,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionBuildQueryDispatch().execute(effectivePerson, query);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -76,7 +73,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "编译指定应用所有表,执行后需要立即重新启动,仅对当前服务器.", action = ActionBuildQuery.class)
@GET
@Path("{query}/build")
@Path("query/{query}/build")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void buildQuery(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -86,7 +83,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionBuildQuery().execute(effectivePerson, query);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -104,7 +101,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionGet().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -122,7 +119,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionStatusDraft().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -140,7 +137,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionStatusBuild().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -157,7 +154,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -175,7 +172,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionEdit().execute(effectivePerson, flag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -193,7 +190,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionEditPermission().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
......@@ -211,7 +208,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionDelete().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -230,7 +227,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowGet().execute(effectivePerson, tableFlag, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -249,7 +246,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionListRowSelectWhere().execute(effectivePerson, tableFlag, where);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -268,7 +265,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowCountWhere().execute(effectivePerson, tableFlag, where);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -286,7 +283,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowInsert().execute(effectivePerson, tableFlag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -305,7 +302,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowUpdate().execute(effectivePerson, tableFlag, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -324,7 +321,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowDelete().execute(effectivePerson, tableFlag, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -342,7 +339,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowDeleteAll().execute(effectivePerson, tableFlag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -362,7 +359,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionListRowNext().execute(effectivePerson, tableFlag, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -382,7 +379,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionListRowPrev().execute(effectivePerson, tableFlag, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -400,7 +397,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionExecute().execute(effectivePerson, flag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -418,7 +415,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowExport().execute(effectivePerson, tableFlag, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -436,7 +433,7 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionRowSave().execute(effectivePerson, tableFlag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......@@ -453,7 +450,24 @@ public class TableAction extends StandardJaxrsAction {
try {
result = new ActionManageList().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "在服务器重新编译dynamicEntity之后需要重新初始化EntityManagerContainerFactory.", action = ActionReloadDynamic.class)
@GET
@Path("reload/dynamic")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void reloadDynamic(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionReloadDynamic.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionReloadDynamic().execute(effectivePerson);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -74,7 +74,7 @@ public class Business {
try {
EntityManagerContainerFactory.close();
Business.refreshDynamicEntityClassLoader();
ThisApplication.context().initDatas(false, Business.getDynamicEntityClassLoader());
ThisApplication.context().initDatas(true, Business.getDynamicEntityClassLoader());
} catch (Exception e) {
LOGGER.error(e);
}
......
package com.x.query.assemble.surface.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -15,14 +13,12 @@ class ActionReloadDynamic extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business.reloadClassLoader();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
ActionResult<Wo> result = new ActionResult<>();
Business.reloadClassLoader();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
......
......@@ -57,7 +57,7 @@ public class Business {
try {
EntityManagerContainerFactory.close();
Business.refreshDynamicEntityClassLoader();
ThisApplication.context().initDatas(false, Business.getDynamicEntityClassLoader());
ThisApplication.context().initDatas(true, Business.getDynamicEntityClassLoader());
} catch (Exception e) {
LOGGER.error(e);
}
......
package com.x.query.service.processing.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -15,14 +13,12 @@ class ActionReloadDynamic extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business.reloadClassLoader();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
ActionResult<Wo> result = new ActionResult<>();
Business.reloadClassLoader();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册