Kaynağa Gözat

Merge branch 'feature/应用缓存优化' into 'develop'

【平台】应用缓存优化

See merge request o2oa/o2oa!1446
o2null 5 yıl önce
ebeveyn
işleme
d0fa976f13
36 değiştirilmiş dosya ile 290 ekleme ve 488 silme
  1. 10 56
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment/ActionDownload.java
  2. 10 56
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment/ActionDownloadStream.java
  3. 10 57
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownload.java
  4. 10 10
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownloadImageWidthHeight.java
  5. 10 55
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownloadStream.java
  6. 10 10
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionGetImageWidthHeightBase64.java
  7. 10 10
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionOfficePreview.java
  8. 10 11
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionDownload.java
  9. 10 11
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionDownloadStream.java
  10. 10 10
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/share/ActionDownload.java
  11. 4 1
      o2server/x_program_center/src/main/java/com/x/program/center/ThisApplication.java
  12. 7 7
      o2server/x_program_center/src/main/java/com/x/program/center/dingding/SyncOrganization.java
  13. 4 3
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/agent/ActionEdit.java
  14. 14 12
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/agent/ActionExecute.java
  15. 0 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/command/BaseAction.java
  16. 3 11
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/input/ActionCover.java
  17. 0 5
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/input/BaseAction.java
  18. 4 3
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/invoke/ActionEdit.java
  19. 12 15
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/invoke/ActionExecute.java
  20. 49 49
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/ActionClearCache.java
  21. 0 6
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java
  22. 6 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionCompare.java
  23. 6 3
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionCompareUpload.java
  24. 6 5
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionOutput.java
  25. 9 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionOutputFile.java
  26. 9 5
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionWrite.java
  27. 0 5
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/BaseAction.java
  28. 6 2
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/ActionSelect.java
  29. 10 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/ActionSelectFile.java
  30. 0 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/BaseAction.java
  31. 10 13
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/warnlog/ActionGetSystemLog.java
  32. 0 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/warnlog/BaseAction.java
  33. 7 7
      o2server/x_program_center/src/main/java/com/x/program/center/qiyeweixin/SyncOrganization.java
  34. 10 12
      o2server/x_program_center/src/main/java/com/x/program/center/schedule/TriggerAgent.java
  35. 7 7
      o2server/x_program_center/src/main/java/com/x/program/center/welink/SyncOrganization.java
  36. 7 7
      o2server/x_program_center/src/main/java/com/x/program/center/zhengwudingding/SyncOrganization.java

+ 10 - 56
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment/ActionDownload.java

@@ -1,12 +1,15 @@
 package com.x.file.assemble.control.jaxrs.attachment;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -15,13 +18,8 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.personal.Attachment;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionDownload extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -36,10 +34,11 @@ class ActionDownload extends StandardJaxrsAction {
 					&& (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName()))) {
 				throw new ExceptionAttachmentAccessDenied(effectivePerson, attachment);
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
 						attachment.getStorage());
@@ -55,7 +54,7 @@ class ActionDownload extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}
 			}
@@ -64,51 +63,6 @@ class ActionDownload extends StandardJaxrsAction {
 		}
 	}
 
-	// @HttpMethodDescribe(value =
-	// "创建Attachment对象./servlet/attachment/download/{id}")
-	// protected void doGet(HttpServletRequest request, HttpServletResponse
-	// response)
-	// throws ServletException, IOException {
-	// try (EntityManagerContainer emc =
-	// EntityManagerContainerFactory.instance().create()) {
-	// request.setCharacterEncoding(DefaultCharset.name);
-	// EffectivePerson effectivePerson = this.effectivePerson(request);
-	// String id = this.getURIPart(request.getRequestURI(), "download");
-	// /* 确定是否要用application/octet-stream输出 */
-	// boolean streamContentType = StringUtils.endsWith(request.getRequestURI(),
-	// "/stream");
-	// Attachment attachment = emc.find(id, Attachment.class,
-	// ExceptionWhen.not_found);
-	// if (!StringUtils.equals(effectivePerson.getDistinguishedName(),
-	// attachment.getPerson())
-	// &&
-	// (!attachment.getShareList().contains(effectivePerson.getDistinguishedName()))
-	// &&
-	// (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName())))
-	// {
-	// throw new Exception("person{name:" +
-	// effectivePerson.getDistinguishedName() + "} access attachment{id:"
-	// + id + "} access denied.");
-	// }
-	// this.setResponseHeader(response, attachment, streamContentType);
-	// StorageMapping mapping =
-	// ThisApplication.context().storageMappings().get(Attachment.class,
-	// attachment.getStorage());
-	// if (null == mapping) {
-	// throw new ExceptionStorageMappingNotExist(attachment.getStorage());
-	// }
-	// OutputStream output = response.getOutputStream();
-	// attachment.readContent(mapping, output);
-	// } catch (Exception e) {
-	// e.printStackTrace();
-	// ActionResult<Object> result = new ActionResult<>();
-	// result.error(e);
-	// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-	// response.getWriter().print(result.toJson());
-	// }
-	//
-	// }
-
 	public static class Wo extends WoFile {
 
 		public Wo(byte[] bytes, String contentType, String contentDisposition) {

+ 10 - 56
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment/ActionDownloadStream.java

@@ -1,12 +1,15 @@
 package com.x.file.assemble.control.jaxrs.attachment;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -15,13 +18,8 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.personal.Attachment;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionDownloadStream extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -36,10 +34,11 @@ class ActionDownloadStream extends StandardJaxrsAction {
 					&& (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName()))) {
 				throw new ExceptionAttachmentAccessDenied(effectivePerson, attachment);
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
 						attachment.getStorage());
@@ -55,7 +54,7 @@ class ActionDownloadStream extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}
 			}
@@ -64,51 +63,6 @@ class ActionDownloadStream extends StandardJaxrsAction {
 		}
 	}
 
-	// @HttpMethodDescribe(value =
-	// "创建Attachment对象./servlet/attachment/download/{id}")
-	// protected void doGet(HttpServletRequest request, HttpServletResponse
-	// response)
-	// throws ServletException, IOException {
-	// try (EntityManagerContainer emc =
-	// EntityManagerContainerFactory.instance().create()) {
-	// request.setCharacterEncoding(DefaultCharset.name);
-	// EffectivePerson effectivePerson = this.effectivePerson(request);
-	// String id = this.getURIPart(request.getRequestURI(), "download");
-	// /* 确定是否要用application/octet-stream输出 */
-	// boolean streamContentType = StringUtils.endsWith(request.getRequestURI(),
-	// "/stream");
-	// Attachment attachment = emc.find(id, Attachment.class,
-	// ExceptionWhen.not_found);
-	// if (!StringUtils.equals(effectivePerson.getDistinguishedName(),
-	// attachment.getPerson())
-	// &&
-	// (!attachment.getShareList().contains(effectivePerson.getDistinguishedName()))
-	// &&
-	// (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName())))
-	// {
-	// throw new Exception("person{name:" +
-	// effectivePerson.getDistinguishedName() + "} access attachment{id:"
-	// + id + "} access denied.");
-	// }
-	// this.setResponseHeader(response, attachment, streamContentType);
-	// StorageMapping mapping =
-	// ThisApplication.context().storageMappings().get(Attachment.class,
-	// attachment.getStorage());
-	// if (null == mapping) {
-	// throw new ExceptionStorageMappingNotExist(attachment.getStorage());
-	// }
-	// OutputStream output = response.getOutputStream();
-	// attachment.readContent(mapping, output);
-	// } catch (Exception e) {
-	// e.printStackTrace();
-	// ActionResult<Object> result = new ActionResult<>();
-	// result.error(e);
-	// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-	// response.getWriter().print(result.toJson());
-	// }
-	//
-	// }
-
 	public static class Wo extends WoFile {
 
 		public Wo(byte[] bytes, String contentType, String contentDisposition) {

+ 10 - 57
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownload.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.attachment2;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,19 +15,14 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.lang3.StringUtils;
-
-import javax.persistence.EntityManager;
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 class ActionDownload extends StandardJaxrsAction {
 
 	private static Logger logger = LoggerFactory.getLogger( ActionDownload.class );
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -42,10 +39,11 @@ class ActionDownload extends StandardJaxrsAction {
 			if (null == originFile) {
 				throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
 						originFile.getStorage());
@@ -61,7 +59,7 @@ class ActionDownload extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}catch (Exception e){
 					if(e.getMessage().indexOf("existed") > -1){
@@ -78,51 +76,6 @@ class ActionDownload extends StandardJaxrsAction {
 		}
 	}
 
-	// @HttpMethodDescribe(value =
-	// "创建Attachment对象./servlet/attachment/download/{id}")
-	// protected void doGet(HttpServletRequest request, HttpServletResponse
-	// response)
-	// throws ServletException, IOException {
-	// try (EntityManagerContainer emc =
-	// EntityManagerContainerFactory.instance().create()) {
-	// request.setCharacterEncoding(DefaultCharset.name);
-	// EffectivePerson effectivePerson = this.effectivePerson(request);
-	// String id = this.getURIPart(request.getRequestURI(), "download");
-	// /* 确定是否要用application/octet-stream输出 */
-	// boolean streamContentType = StringUtils.endsWith(request.getRequestURI(),
-	// "/stream");
-	// Attachment attachment = emc.find(id, Attachment.class,
-	// ExceptionWhen.not_found);
-	// if (!StringUtils.equals(effectivePerson.getDistinguishedName(),
-	// attachment.getPerson())
-	// &&
-	// (!attachment.getShareList().contains(effectivePerson.getDistinguishedName()))
-	// &&
-	// (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName())))
-	// {
-	// throw new Exception("person{name:" +
-	// effectivePerson.getDistinguishedName() + "} access attachment{id:"
-	// + id + "} access denied.");
-	// }
-	// this.setResponseHeader(response, attachment, streamContentType);
-	// StorageMapping mapping =
-	// ThisApplication.context().storageMappings().get(Attachment.class,
-	// attachment.getStorage());
-	// if (null == mapping) {
-	// throw new ExceptionStorageMappingNotExist(attachment.getStorage());
-	// }
-	// OutputStream output = response.getOutputStream();
-	// attachment.readContent(mapping, output);
-	// } catch (Exception e) {
-	// e.printStackTrace();
-	// ActionResult<Object> result = new ActionResult<>();
-	// result.error(e);
-	// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-	// response.getWriter().print(result.toJson());
-	// }
-	//
-	// }
-
 	public static class Wo extends WoFile {
 
 		public Wo(byte[] bytes, String contentType, String contentDisposition) {

+ 10 - 10
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownloadImageWidthHeight.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.attachment2;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.base.core.project.http.ActionResult;
@@ -13,8 +15,6 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.math.NumberUtils;
@@ -23,13 +23,12 @@ import org.imgscalr.Scalr;
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.util.Optional;
 
 class ActionDownloadImageWidthHeight extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger( ActionDownloadImageWidthHeight.class );
 
-	private Ehcache cache = ApplicationCache.instance().getCache(ActionDownloadImageWidthHeight.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, Integer width, Integer height)
 			throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
@@ -54,10 +53,11 @@ class ActionDownloadImageWidthHeight extends BaseAction {
 				throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
 			}
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id+width+height);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id+width+height);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 				result.setData(wo);
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
@@ -81,7 +81,7 @@ class ActionDownloadImageWidthHeight extends BaseAction {
 							wo = new Wo(bs, this.contentType(false, attachment.getName()),
 									this.contentDisposition(false, attachment.getName()));
 
-							cache.put(new Element(cacheKey, wo));
+							CacheManager.put(cacheCategory, cacheKey, wo);
 							result.setData(wo);
 						}
 					}

+ 10 - 55
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionDownloadStream.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.attachment2;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,18 +15,15 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 class ActionDownloadStream extends StandardJaxrsAction {
 
 	private static Logger logger = LoggerFactory.getLogger( ActionDownloadStream.class );
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -41,10 +40,11 @@ class ActionDownloadStream extends StandardJaxrsAction {
 			if (null == originFile) {
 				throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
 						originFile.getStorage());
@@ -60,7 +60,7 @@ class ActionDownloadStream extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}catch (Exception e){
 					if(e.getMessage().indexOf("existed") > -1){
@@ -77,51 +77,6 @@ class ActionDownloadStream extends StandardJaxrsAction {
 		}
 	}
 
-	// @HttpMethodDescribe(value =
-	// "创建Attachment对象./servlet/attachment/download/{id}")
-	// protected void doGet(HttpServletRequest request, HttpServletResponse
-	// response)
-	// throws ServletException, IOException {
-	// try (EntityManagerContainer emc =
-	// EntityManagerContainerFactory.instance().create()) {
-	// request.setCharacterEncoding(DefaultCharset.name);
-	// EffectivePerson effectivePerson = this.effectivePerson(request);
-	// String id = this.getURIPart(request.getRequestURI(), "download");
-	// /* 确定是否要用application/octet-stream输出 */
-	// boolean streamContentType = StringUtils.endsWith(request.getRequestURI(),
-	// "/stream");
-	// Attachment attachment = emc.find(id, Attachment.class,
-	// ExceptionWhen.not_found);
-	// if (!StringUtils.equals(effectivePerson.getDistinguishedName(),
-	// attachment.getPerson())
-	// &&
-	// (!attachment.getShareList().contains(effectivePerson.getDistinguishedName()))
-	// &&
-	// (!attachment.getEditorList().contains(effectivePerson.getDistinguishedName())))
-	// {
-	// throw new Exception("person{name:" +
-	// effectivePerson.getDistinguishedName() + "} access attachment{id:"
-	// + id + "} access denied.");
-	// }
-	// this.setResponseHeader(response, attachment, streamContentType);
-	// StorageMapping mapping =
-	// ThisApplication.context().storageMappings().get(Attachment.class,
-	// attachment.getStorage());
-	// if (null == mapping) {
-	// throw new ExceptionStorageMappingNotExist(attachment.getStorage());
-	// }
-	// OutputStream output = response.getOutputStream();
-	// attachment.readContent(mapping, output);
-	// } catch (Exception e) {
-	// e.printStackTrace();
-	// ActionResult<Object> result = new ActionResult<>();
-	// result.error(e);
-	// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-	// response.getWriter().print(result.toJson());
-	// }
-	//
-	// }
-
 	public static class Wo extends WoFile {
 
 		public Wo(byte[] bytes, String contentType, String contentDisposition) {

+ 10 - 10
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionGetImageWidthHeightBase64.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.attachment2;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.base.core.project.http.ActionResult;
@@ -11,8 +13,6 @@ import com.x.base.core.project.jaxrs.WrapString;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.lang3.ArrayUtils;
@@ -22,11 +22,10 @@ import org.imgscalr.Scalr;
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.util.Optional;
 
 class ActionGetImageWidthHeightBase64 extends BaseAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(ActionGetImageWidthHeightBase64.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, Integer width, Integer height)
 			throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
@@ -50,10 +49,11 @@ class ActionGetImageWidthHeightBase64 extends BaseAction {
 			if (null == originFile) {
 				throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id+width+height);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				Wo wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id+width+height);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				Wo wo = (Wo) optional.get();
 				result.setData(wo);
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
@@ -75,7 +75,7 @@ class ActionGetImageWidthHeightBase64 extends BaseAction {
 							String str = Base64.encodeBase64String(baos.toByteArray());
 							Wo wo = new Wo();
 							wo.setValue(str);
-							cache.put(new Element(cacheKey, wo));
+							CacheManager.put(cacheCategory, cacheKey, wo);
 							result.setData(wo);
 						}
 					}

+ 10 - 10
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionOfficePreview.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.attachment2;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -12,16 +14,13 @@ import com.x.base.core.project.tools.DocumentTools;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 class ActionOfficePreview extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String type) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -38,10 +37,11 @@ class ActionOfficePreview extends StandardJaxrsAction {
 			if (null == originFile) {
 				throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
 			}
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id, type);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
 						originFile.getStorage());
@@ -66,7 +66,7 @@ class ActionOfficePreview extends StandardJaxrsAction {
 						 * 对10M以下的文件进行缓存
 						 */
 						if (bs.length < (1024 * 1024 * 10)) {
-							cache.put(new Element(cacheKey, wo));
+							CacheManager.put(cacheCategory, cacheKey, wo);
 						}
 					}else{
 						wo = new Wo(bs, this.contentType(false, attachment.getName()),

+ 10 - 11
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionDownload.java

@@ -1,10 +1,13 @@
 package com.x.file.assemble.control.jaxrs.file;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,21 +16,17 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.File;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionDownload extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(WoFile.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				File file = emc.find(id, File.class);
 				if (null == file) {
@@ -46,7 +45,7 @@ class ActionDownload extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}
 			}

+ 10 - 11
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionDownloadStream.java

@@ -1,10 +1,13 @@
 package com.x.file.assemble.control.jaxrs.file;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,21 +16,17 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.file.assemble.control.ThisApplication;
 import com.x.file.core.entity.open.File;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionDownloadStream extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(WoFile.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), id);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				File file = emc.find(id, File.class);
 				if (null == file) {
@@ -46,7 +45,7 @@ class ActionDownloadStream extends StandardJaxrsAction {
 					 * 对10M以下的文件进行缓存
 					 */
 					if (bs.length < (1024 * 1024 * 10)) {
-						cache.put(new Element(cacheKey, wo));
+						CacheManager.put(cacheCategory, cacheKey, wo);
 					}
 				}
 			}

+ 10 - 10
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/share/ActionDownload.java

@@ -2,7 +2,9 @@ package com.x.file.assemble.control.jaxrs.share;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,18 +15,15 @@ import com.x.file.core.entity.open.OriginFile;
 import com.x.file.core.entity.personal.Attachment2;
 import com.x.file.core.entity.personal.Folder2;
 import com.x.file.core.entity.personal.Share;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 class ActionDownload extends BaseAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String shareId, String fileId, String password) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
@@ -62,10 +61,11 @@ class ActionDownload extends BaseAction {
 				if (null == originFile) {
 					throw new ExceptionAttachmentNotExist(shareId, fileId);
 				}
-				String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), fileId);
-				Element element = cache.get(cacheKey);
-				if ((null != element) && (null != element.getObjectValue())) {
-					wo = (Wo) element.getObjectValue();
+				CacheCategory cacheCategory = new CacheCategory(Attachment2.class);
+				CacheKey cacheKey = new CacheKey(this.getClass(), fileId);
+				Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+				if (optional.isPresent()) {
+					wo = (Wo) optional.get();
 				} else {
 					StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
 							originFile.getStorage());
@@ -81,7 +81,7 @@ class ActionDownload extends BaseAction {
 						 * 对10M以下的文件进行缓存
 						 */
 						if (bs.length < (1024 * 1024 * 10)) {
-							cache.put(new Element(cacheKey, wo));
+							CacheManager.put(cacheCategory, cacheKey, wo);
 						}
 					}
 				}

+ 4 - 1
o2server/x_program_center/src/main/java/com/x/program/center/ThisApplication.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.lang3.BooleanUtils;
 
 import com.google.gson.internal.LinkedTreeMap;
@@ -56,6 +57,7 @@ public class ThisApplication {
 
 	public static void init() {
 		try {
+			CacheManager.init(context.clazz().getSimpleName());
 			LoggerFactory.setLevel(Config.logLevel().x_program_center());
 			/* 20190927新报告机制 */
 			context().startQueue(centerQueue);
@@ -99,7 +101,7 @@ public class ThisApplication {
 			context().scheduleLocal(CleanupCode.class, 10, 60 * 30);
 			context().scheduleLocal(Cleanup.class, 10, 60 * 30);
 			context().scheduleLocal(CollectPerson.class, 10, 60 * 30);
-			context().scheduleLocal(CollectMarket.class, 10, 60 * 60 * 6);
+			context().scheduleLocal(CollectMarket.class, 10, 60 * 60 * 10);
 			context().scheduleLocal(CollectLog.class, 10, 60 * 30);
 			// 运行间隔由60秒缩减到30秒
 			context().scheduleLocal(TriggerAgent.class, 150, 30);
@@ -112,6 +114,7 @@ public class ThisApplication {
 
 	public static void destroy() {
 		try {
+			CacheManager.shutdown();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}

+ 7 - 7
o2server/x_program_center/src/main/java/com/x/program/center/dingding/SyncOrganization.java

@@ -21,6 +21,7 @@ import javax.script.Bindings;
 import javax.script.ScriptContext;
 import javax.script.SimpleScriptContext;
 
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -30,7 +31,6 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.annotation.CheckRemoveType;
 import com.x.base.core.entity.type.GenderType;
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.XGsonBuilder;
@@ -67,12 +67,12 @@ public class SyncOrganization {
 			this.check(business, result, units, people, personAttributes, identities, accessToken, factory, null, root);
 		}
 		this.clean(business, result, units, people, identities);
-		ApplicationCache.notify(Person.class);
-		ApplicationCache.notify(PersonAttribute.class);
-		ApplicationCache.notify(Unit.class);
-		ApplicationCache.notify(UnitAttribute.class);
-		ApplicationCache.notify(UnitDuty.class);
-		ApplicationCache.notify(Identity.class);
+		CacheManager.notify(Person.class);
+		CacheManager.notify(PersonAttribute.class);
+		CacheManager.notify(Unit.class);
+		CacheManager.notify(UnitAttribute.class);
+		CacheManager.notify(UnitDuty.class);
+		CacheManager.notify(Identity.class);
 		result.end();
 		if (!result.getCreateUnitList().isEmpty()) {
 			logger.print("创建组织({}):{}.", result.getCreateUnitList().size(),

+ 4 - 3
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/agent/ActionEdit.java

@@ -1,6 +1,6 @@
 package com.x.program.center.jaxrs.agent;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
@@ -16,6 +16,8 @@ import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.tools.ListTools;
 import com.x.program.center.core.entity.Agent;
 
+import javax.script.CompiledScript;
+
 class ActionEdit extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
@@ -39,8 +41,7 @@ class ActionEdit extends BaseAction {
 			this.addComment(agent);
 			emc.check(agent, CheckPersistType.all);
 			emc.commit();
-
-			ApplicationCache.notify(Agent.class);
+			CacheManager.notify(Agent.class);
 			Wo wo = new Wo();
 			wo.setId(agent.getId());
 			result.setData(wo);

+ 14 - 12
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/agent/ActionExecute.java

@@ -1,6 +1,7 @@
 package com.x.program.center.jaxrs.agent;
 
 import java.util.Date;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.script.Bindings;
@@ -10,7 +11,9 @@ import javax.script.SimpleScriptContext;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -24,15 +27,10 @@ import com.x.organization.core.express.Organization;
 import com.x.program.center.ThisApplication;
 import com.x.program.center.core.entity.Agent;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionExecute extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionExecute.class);
 
-	private static Ehcache CACHE = ApplicationCache.instance().getCache(Agent.class);
-
 	private static final CopyOnWriteArrayList<String> LOCK = new CopyOnWriteArrayList<>();
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
@@ -61,14 +59,18 @@ class ActionExecute extends BaseAction {
 					resources.setWebservicesClient(new WebservicesClient());
 					bindings.put(ScriptFactory.BINDING_NAME_RESOURCES, resources);
 					bindings.put(ScriptFactory.BINDING_NAME_APPLICATIONS, ThisApplication.context().applications());
-					String cacheKey = ApplicationCache.concreteCacheKey(ActionExecute.class, agent.getId());
-					Element element = CACHE.get(cacheKey);
+
+					CacheCategory cacheCategory = new CacheCategory(Agent.class);
+					CacheKey cacheKey = new CacheKey(ActionExecute.class, agent.getId());
 					CompiledScript compiledScript = null;
-					if ((null != element) && (null != element.getObjectValue())) {
-						logger.print("has agent cache {}", agent.getId());
+					Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+					if (optional.isPresent()) {
+						compiledScript = (CompiledScript)optional.get();
+					}else {
+						compiledScript = ScriptFactory.compile(ScriptFactory.functionalization(agent.getText()));
+						CacheManager.put(cacheCategory, cacheKey, compiledScript);
 					}
-					compiledScript = ScriptFactory.compile(ScriptFactory.functionalization(agent.getText()));
-					CACHE.put(new Element(cacheKey, compiledScript));
+
 					try {
 						ScriptFactory.initialServiceScriptText().eval(scriptContext);
 						compiledScript.eval(scriptContext);

+ 0 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/command/BaseAction.java

@@ -1,14 +1,10 @@
 package com.x.program.center.jaxrs.command;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-    public static Ehcache cacheLog = ApplicationCache.instance().getCache(CacheLogObject.class);
-
     public static class CacheLogObject extends GsonPropertyObject {
 
         private String userToken;

+ 3 - 11
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/input/ActionCover.java

@@ -4,21 +4,13 @@ import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
-import com.x.base.core.entity.annotation.CheckPersistType;
-import com.x.base.core.entity.dataitem.DataItemConverter;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.StringTools;
-import com.x.cms.core.entity.AppInfo;
-import com.x.cms.core.entity.CategoryExt;
-import com.x.cms.core.entity.CategoryInfo;
-import com.x.cms.core.entity.CategoryInfo_;
-import com.x.cms.core.entity.element.*;
-import com.x.cms.core.entity.element.wrap.*;
 import com.x.program.center.Business;
 import com.x.program.center.core.entity.Agent;
 import com.x.program.center.core.entity.Invoke;
@@ -108,10 +100,10 @@ class ActionCover extends BaseAction {
 		business.entityManagerContainer().commit();
 
 		if(!wi.getAgentList().isEmpty()){
-			ApplicationCache.notify(Agent.class);
+			CacheManager.notify(Agent.class);
 		}
 		if(!wi.getInvokeList().isEmpty()){
-			ApplicationCache.notify(Invoke.class);
+			CacheManager.notify(Invoke.class);
 		}
 		return serviceModuleEnum;
 	}

+ 0 - 5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/input/BaseAction.java

@@ -1,14 +1,9 @@
 package com.x.program.center.jaxrs.input;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache inputCache = ApplicationCache.instance().getCache(BaseAction.class.getName(), 100,
-			ApplicationCache.MINUTES_20, ApplicationCache.MINUTES_20);
-
 	public enum Method {
 		cover, create, ignore;
 	}

+ 4 - 3
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/invoke/ActionEdit.java

@@ -1,6 +1,6 @@
 package com.x.program.center.jaxrs.invoke;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
@@ -10,13 +10,14 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.tools.ListTools;
 import com.x.program.center.core.entity.Invoke;
 
+import javax.script.CompiledScript;
+
 class ActionEdit extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
@@ -40,7 +41,7 @@ class ActionEdit extends BaseAction {
 			this.addComment(invoke);
 			emc.check(invoke, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Invoke.class);
+			CacheManager.notify(Invoke.class);
 			Wo wo = new Wo();
 			wo.setId(invoke.getId());
 			result.setData(wo);

+ 12 - 15
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/invoke/ActionExecute.java

@@ -2,6 +2,7 @@ package com.x.program.center.jaxrs.invoke;
 
 import java.util.Date;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -11,14 +12,16 @@ import javax.script.ScriptContext;
 import javax.script.SimpleScriptContext;
 import javax.servlet.http.HttpServletRequest;
 
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.entity.annotation.CheckPersistType;
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoContentType;
@@ -35,15 +38,10 @@ import com.x.organization.core.express.Organization;
 import com.x.program.center.ThisApplication;
 import com.x.program.center.core.entity.Invoke;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionExecute extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionExecute.class);
 
-	public static Ehcache CACHE = ApplicationCache.instance().getCache(Invoke.class);
-
 	ActionResult<Object> execute(HttpServletRequest request, EffectivePerson effectivePerson, String flag,
 			JsonElement jsonElement) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
@@ -65,18 +63,17 @@ class ActionExecute extends BaseAction {
 			invoke.setLastStartTime(new Date());
 			emc.commit();
 
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), invoke.getId());
-
+			CacheCategory cacheCategory = new CacheCategory(Invoke.class);
+			CacheKey cacheKey = new CacheKey(ActionExecute.class, invoke.getId());
 			CompiledScript compiledScript = null;
-
-			Element element = CACHE.get(cacheKey);
-
-			if ((null != element) && (null != element.getObjectValue())) {
-				compiledScript = (CompiledScript) element.getObjectValue();
-			} else {
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				compiledScript = (CompiledScript)optional.get();
+			}else {
 				compiledScript = ScriptFactory.compile(invoke.getText());
-				CACHE.put(new Element(cacheKey, compiledScript));
+				CacheManager.put(cacheCategory, cacheKey, compiledScript);
 			}
+
 			ScriptContext scriptContext = new SimpleScriptContext();
 			Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
 			Resources resources = new Resources();

+ 49 - 49
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/ActionClearCache.java

@@ -1,6 +1,6 @@
 package com.x.program.center.jaxrs.jest;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.cms.core.entity.AppInfo;
@@ -34,76 +34,76 @@ class ActionClearCache extends BaseAction {
 			wo.setValue(false);
 		}else if("all".equalsIgnoreCase(source)){
 			//cms
-			ApplicationCache.notify(CategoryInfo.class);
-			ApplicationCache.notify(AppDictItem.class);
-			ApplicationCache.notify(AppDict.class);
-			ApplicationCache.notify(Form.class);
-			ApplicationCache.notify(Script.class);
-			ApplicationCache.notify(AppInfo.class);
+			CacheManager.notify(CategoryInfo.class);
+			CacheManager.notify(AppDictItem.class);
+			CacheManager.notify(AppDict.class);
+			CacheManager.notify(Form.class);
+			CacheManager.notify(Script.class);
+			CacheManager.notify(AppInfo.class);
 			//portal
-			ApplicationCache.notify(com.x.portal.core.entity.Script.class);
-			ApplicationCache.notify(Page.class);
-			ApplicationCache.notify(Widget.class);
-			ApplicationCache.notify(Portal.class);
+			CacheManager.notify(com.x.portal.core.entity.Script.class);
+			CacheManager.notify(Page.class);
+			CacheManager.notify(Widget.class);
+			CacheManager.notify(Portal.class);
 			//query
-			ApplicationCache.notify(Reveal.class);
-			ApplicationCache.notify(Stat.class);
-			ApplicationCache.notify(View.class);
-			ApplicationCache.notify(Table.class);
-			ApplicationCache.notify(Statement.class);
+			CacheManager.notify(Reveal.class);
+			CacheManager.notify(Stat.class);
+			CacheManager.notify(View.class);
+			CacheManager.notify(Table.class);
+			CacheManager.notify(Statement.class);
 			//process
-			ApplicationCache.notify(ApplicationDictItem.class);
-			ApplicationCache.notify(ApplicationDict.class);
-			ApplicationCache.notify(FormField.class);
-			ApplicationCache.notify(com.x.processplatform.core.entity.element.Form.class);
-			ApplicationCache.notify(com.x.processplatform.core.entity.element.Script.class);
-			ApplicationCache.notify(Process.class);
-			ApplicationCache.notify(Application.class);
+			CacheManager.notify(ApplicationDictItem.class);
+			CacheManager.notify(ApplicationDict.class);
+			CacheManager.notify(FormField.class);
+			CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
+			CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
+			CacheManager.notify(Process.class);
+			CacheManager.notify(Application.class);
 			//agent
-			ApplicationCache.notify(Agent.class);
+			CacheManager.notify(Agent.class);
 			//invoke
-			ApplicationCache.notify(Invoke.class);
+			CacheManager.notify(Invoke.class);
 			wo.setValue(true);
 		}else if("cms".equalsIgnoreCase(source)){
-			ApplicationCache.notify(CategoryInfo.class);
-			ApplicationCache.notify(AppDictItem.class);
-			ApplicationCache.notify(AppDict.class);
-			ApplicationCache.notify(Form.class);
-			ApplicationCache.notify(Script.class);
-			ApplicationCache.notify(AppInfo.class);
+			CacheManager.notify(CategoryInfo.class);
+			CacheManager.notify(AppDictItem.class);
+			CacheManager.notify(AppDict.class);
+			CacheManager.notify(Form.class);
+			CacheManager.notify(Script.class);
+			CacheManager.notify(AppInfo.class);
 
 			wo.setValue(true);
 		}else if("portal".equalsIgnoreCase(source)){
-			ApplicationCache.notify(com.x.portal.core.entity.Script.class);
-			ApplicationCache.notify(Page.class);
-			ApplicationCache.notify(Widget.class);
-			ApplicationCache.notify(Portal.class);
+			CacheManager.notify(com.x.portal.core.entity.Script.class);
+			CacheManager.notify(Page.class);
+			CacheManager.notify(Widget.class);
+			CacheManager.notify(Portal.class);
 
 			wo.setValue(true);
 		}else if("query".equalsIgnoreCase(source)){
-			ApplicationCache.notify(Reveal.class);
-			ApplicationCache.notify(Stat.class);
-			ApplicationCache.notify(View.class);
-			ApplicationCache.notify(Table.class);
-			ApplicationCache.notify(Statement.class);
+			CacheManager.notify(Reveal.class);
+			CacheManager.notify(Stat.class);
+			CacheManager.notify(View.class);
+			CacheManager.notify(Table.class);
+			CacheManager.notify(Statement.class);
 
 			wo.setValue(true);
 		}else if("process".equalsIgnoreCase(source)){
-			ApplicationCache.notify(ApplicationDictItem.class);
-			ApplicationCache.notify(ApplicationDict.class);
-			ApplicationCache.notify(FormField.class);
-			ApplicationCache.notify(com.x.processplatform.core.entity.element.Form.class);
-			ApplicationCache.notify(com.x.processplatform.core.entity.element.Script.class);
-			ApplicationCache.notify(Process.class);
-			ApplicationCache.notify(Application.class);
+			CacheManager.notify(ApplicationDictItem.class);
+			CacheManager.notify(ApplicationDict.class);
+			CacheManager.notify(FormField.class);
+			CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
+			CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
+			CacheManager.notify(Process.class);
+			CacheManager.notify(Application.class);
 
 			wo.setValue(true);
 		}else if("agent".equalsIgnoreCase(source)){
-			ApplicationCache.notify(Agent.class);
+			CacheManager.notify(Agent.class);
 
 			wo.setValue(true);
 		}else if("invoke".equalsIgnoreCase(source)){
-			ApplicationCache.notify(Invoke.class);
+			CacheManager.notify(Invoke.class);
 
 			wo.setValue(true);
 		}

+ 0 - 6
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java

@@ -1,16 +1,10 @@
 package com.x.program.center.jaxrs.market;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-import com.x.program.center.WrapModule;
-import com.x.program.center.core.entity.Application;
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache cache = ApplicationCache.instance().getCache(Application.class);
-
 	public boolean hasAuth(EffectivePerson effectivePerson, String person){
 		if(effectivePerson.isManager()){
 			return true;

+ 6 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionCompare.java

@@ -3,9 +3,9 @@ package com.x.program.center.jaxrs.module;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.connection.CipherConnectionAction;
 import com.x.program.center.core.entity.wrap.WrapServiceModule;
-import org.apache.commons.lang3.BooleanUtils;
 
 import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
@@ -16,6 +16,8 @@ import com.x.base.core.project.x_portal_assemble_designer;
 import com.x.base.core.project.x_processplatform_assemble_designer;
 import com.x.base.core.project.x_query_assemble_designer;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.connection.ActionResponse;
 import com.x.base.core.project.connection.ConnectionAction;
@@ -32,8 +34,6 @@ import com.x.program.center.ThisApplication;
 import com.x.program.center.WrapModule;
 import com.x.query.core.entity.wrap.WrapQuery;
 
-import net.sf.ehcache.Element;
-
 class ActionCompare extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
@@ -64,7 +64,9 @@ class ActionCompare extends BaseAction {
 			CacheObject cacheObject = new CacheObject();
 			cacheObject.setModule(module);
 			String flag = StringTools.uniqueToken();
-			cache.put(new Element(flag, cacheObject));
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			CacheManager.put(cacheCategory, cacheKey, cacheObject);
 			wo.setFlag(flag);
 			for (WrapProcessPlatform o : module.getProcessPlatformList()) {
 				ActionResponse r = ThisApplication.context().applications().putQuery(effectivePerson.getDebugger(),

+ 6 - 3
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionCompareUpload.java

@@ -3,6 +3,7 @@ package com.x.program.center.jaxrs.module;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.connection.CipherConnectionAction;
 import com.x.program.center.core.entity.wrap.WrapServiceModule;
@@ -15,6 +16,8 @@ import com.x.base.core.project.x_portal_assemble_designer;
 import com.x.base.core.project.x_processplatform_assemble_designer;
 import com.x.base.core.project.x_query_assemble_designer;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.project.connection.ActionResponse;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.XGsonBuilder;
@@ -31,8 +34,6 @@ import com.x.program.center.ThisApplication;
 import com.x.program.center.WrapModule;
 import com.x.query.core.entity.wrap.WrapQuery;
 
-import net.sf.ehcache.Element;
-
 class ActionCompareUpload extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionCompareUpload.class);
@@ -47,7 +48,9 @@ class ActionCompareUpload extends BaseAction {
 		CacheObject cacheObject = new CacheObject();
 		cacheObject.setModule(module);
 		String flag = StringTools.uniqueToken();
-		cache.put(new Element(flag, cacheObject));
+		CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+		CacheKey cacheKey = new CacheKey(flag);
+		CacheManager.put(cacheCategory, cacheKey, cacheObject);
 		wo.setFlag(flag);
 		for (WrapProcessPlatform o : module.getProcessPlatformList()) {
 			ActionResponse r = ThisApplication.context().applications().putQuery(effectivePerson.getDebugger(),

+ 6 - 5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionOutput.java

@@ -1,11 +1,11 @@
 package com.x.program.center.jaxrs.module;
 
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.connection.CipherConnectionAction;
 import com.x.base.core.project.tools.DefaultCharset;
 import com.x.program.center.core.entity.wrap.WrapServiceModule;
-import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
@@ -18,15 +18,15 @@ import com.x.base.core.project.x_portal_assemble_designer;
 import com.x.base.core.project.x_processplatform_assemble_designer;
 import com.x.base.core.project.x_query_assemble_designer;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.ListTools;
-import com.x.base.core.project.tools.StringTools;
 import com.x.cms.core.entity.element.wrap.WrapCms;
 import com.x.portal.core.entity.wrap.WrapPortal;
 import com.x.processplatform.core.entity.element.wrap.WrapProcessPlatform;
@@ -35,7 +35,6 @@ import com.x.program.center.WrapModule;
 import com.x.program.center.core.entity.Structure;
 import com.x.query.core.entity.wrap.WrapQuery;
 
-import net.sf.ehcache.Element;
 
 public class ActionOutput extends BaseAction {
 
@@ -99,9 +98,11 @@ public class ActionOutput extends BaseAction {
 			emc.persist(structure);
 			emc.commit();
 
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(wo.getFlag());
 			CacheObject cacheObject = new CacheObject();
 			cacheObject.setModule(wo);
-			this.cache.put(new Element(wo.getFlag(), cacheObject));
+			CacheManager.put(cacheCategory, cacheKey, cacheObject);
 			result.setData(wo);
 			return result;
 		}

+ 9 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionOutputFile.java

@@ -2,6 +2,9 @@ package com.x.program.center.jaxrs.module;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -13,9 +16,9 @@ import com.x.program.center.ThisApplication;
 import com.x.program.center.WrapModule;
 
 import com.x.program.center.core.entity.Structure;
-import net.sf.ehcache.Element;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Optional;
 
 public class ActionOutputFile extends BaseAction {
 
@@ -25,9 +28,11 @@ public class ActionOutputFile extends BaseAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			Element element = cache.get(flag);
-			if (null != element && null != element.getObjectValue()) {
-				CacheObject cacheObject = (CacheObject) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				CacheObject cacheObject = (CacheObject) optional.get();
 				WrapModule module = cacheObject.getModule();
 				wo = new Wo(gson.toJson(module).getBytes(DefaultCharset.name),
 						this.contentType(true, module.getName() +"."+ Structure.default_extension),

+ 9 - 5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionWrite.java

@@ -2,6 +2,7 @@ package com.x.program.center.jaxrs.module;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.connection.CipherConnectionAction;
@@ -17,6 +18,9 @@ import com.x.base.core.project.x_portal_assemble_designer;
 import com.x.base.core.project.x_processplatform_assemble_designer;
 import com.x.base.core.project.x_query_assemble_designer;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -31,8 +35,6 @@ import com.x.program.center.ThisApplication;
 import com.x.program.center.WrapModule;
 import com.x.query.core.entity.wrap.WrapQuery;
 
-import net.sf.ehcache.Element;
-
 public class ActionWrite extends BaseAction {
 	
 	private static Logger logger = LoggerFactory.getLogger(ActionWrite.class);
@@ -42,11 +44,13 @@ public class ActionWrite extends BaseAction {
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Wo wo = new Wo();
 			ActionResult<Wo> result = new ActionResult<>();
-			Element element = cache.get(flag);
-			if (null == element || null == element.getObjectValue()) {
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (!optional.isPresent()) {
 				throw new ExceptionFlagNotExist(flag);
 			}
-			CacheObject cacheObject = (CacheObject) element.getObjectValue();
+			CacheObject cacheObject = (CacheObject) optional.get();
 			WrapModule module = cacheObject.getModule();
 			List<WrapPair> replaces = new ArrayList<>();
 			for (WiCommand cmd : wi.getProcessPlatformList()) {

+ 0 - 5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/BaseAction.java

@@ -1,15 +1,10 @@
 package com.x.program.center.jaxrs.module;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.program.center.WrapModule;
 
-import net.sf.ehcache.Ehcache;
-
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache cache = ApplicationCache.instance().getCache(CacheObject.class);
-
 	public static class CacheObject {
 
 		private WrapModule module;

+ 6 - 2
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/ActionSelect.java

@@ -4,6 +4,9 @@ import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.tools.StringTools;
@@ -14,7 +17,6 @@ import com.x.program.center.core.entity.wrap.ServiceModuleEnum;
 import com.x.program.center.core.entity.wrap.WrapAgent;
 import com.x.program.center.core.entity.wrap.WrapInvoke;
 import com.x.program.center.core.entity.wrap.WrapServiceModule;
-import net.sf.ehcache.Element;
 
 class ActionSelect extends BaseAction {
 
@@ -36,8 +38,10 @@ class ActionSelect extends BaseAction {
 			cacheObject.setName(serviceModuleEnum.getDescription());
 
 			String flag = StringTools.uniqueToken();
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			CacheManager.put(cacheCategory, cacheKey, cacheObject);
 
-			cache.put(new Element(flag, cacheObject));
 			Wo wo = gson.fromJson(gson.toJson(wrapAppInfo), Wo.class);
 			wo.setFlag(flag);
 			result.setData(wo);

+ 10 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/ActionSelectFile.java

@@ -2,11 +2,15 @@ package com.x.program.center.jaxrs.output;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.tools.DefaultCharset;
-import net.sf.ehcache.Element;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+
+import java.util.Optional;
 
 class ActionSelectFile extends BaseAction {
 
@@ -15,11 +19,13 @@ class ActionSelectFile extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Element element = cache.get(flag);
-			if (null == element || null == element.getObjectValue()) {
+			CacheCategory cacheCategory = new CacheCategory(CacheObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (!optional.isPresent()) {
 				throw new ExceptionFlagNotExist(flag);
 			}
-			CacheObject cacheObject = (CacheObject) element.getObjectValue();
+			CacheObject cacheObject = (CacheObject) optional.get();
 			Wo wo = new Wo( gson.toJson(cacheObject.getModule()).getBytes(DefaultCharset.name ),
 					this.contentType(true, cacheObject.getName() + extension ),
 					this.contentDisposition(true, cacheObject.getName() + extension ));

+ 0 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/output/BaseAction.java

@@ -1,14 +1,10 @@
 package com.x.program.center.jaxrs.output;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.program.center.core.entity.wrap.WrapServiceModule;
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-    protected Ehcache cache = ApplicationCache.instance().getCache(CacheObject.class);
-
     public static class CacheObject {
 
         private WrapServiceModule module;

+ 10 - 13
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/warnlog/ActionGetSystemLog.java

@@ -2,7 +2,9 @@ package com.x.program.center.jaxrs.warnlog;
 
 import com.google.gson.reflect.TypeToken;
 import com.x.base.core.project.bean.NameValuePair;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.Nodes;
 import com.x.base.core.project.connection.ConnectionAction;
@@ -11,22 +13,16 @@ import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.http.HttpToken;
-import com.x.base.core.project.jaxrs.WoValue;
-import com.x.base.core.project.jaxrs.WrapStringList;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.Crypto;
 import com.x.base.core.project.tools.ListTools;
-import net.sf.ehcache.Element;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.net.Socket;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 class ActionGetSystemLog extends BaseAction {
 
@@ -70,11 +66,12 @@ class ActionGetSystemLog extends BaseAction {
 						dos.flush();
 
 						long lastPoint = 0;
-						String cacheKey = ApplicationCache.concreteCacheKey(key, node.toLowerCase());
-						Element element = cacheLog.get(cacheKey);
+						CacheCategory cacheCategory = new CacheCategory(CacheLogObject.class);
+						CacheKey cacheKey = new CacheKey(key, node.toLowerCase());
+						Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 						CacheLogObject clo = null;
-						if ((null != element) && (null != element.getObjectValue())) {
-							clo = (CacheLogObject) element.getObjectValue();
+						if (optional.isPresent()) {
+							clo = (CacheLogObject) optional.get();
 							lastPoint = clo.getLastPoint();
 						}
 						dos.writeLong(lastPoint);
@@ -95,7 +92,7 @@ class ActionGetSystemLog extends BaseAction {
 							}else{
 								clo.setLastPoint(returnLastPoint);
 							}
-							cacheLog.put(new Element(cacheKey, clo));
+							CacheManager.put(cacheCategory, cacheKey, clo);
 						}
 					}
 

+ 0 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/warnlog/BaseAction.java

@@ -1,14 +1,10 @@
 package com.x.program.center.jaxrs.warnlog;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-    public static Ehcache cacheLog = ApplicationCache.instance().getCache(CacheLogObject.class);
-
     public static class CacheLogObject extends GsonPropertyObject {
 
         private String userToken;

+ 7 - 7
o2server/x_program_center/src/main/java/com/x/program/center/qiyeweixin/SyncOrganization.java

@@ -4,7 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.annotation.CheckRemoveType;
 import com.x.base.core.entity.type.GenderType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.XGsonBuilder;
@@ -53,12 +53,12 @@ public class SyncOrganization {
 		}
 		logger.print("开始清理本地用户组织信息");
 		this.clean(business, result, units, people, identities);
-		ApplicationCache.notify(Person.class);
-		ApplicationCache.notify(PersonAttribute.class);
-		ApplicationCache.notify(Unit.class);
-		ApplicationCache.notify(UnitAttribute.class);
-		ApplicationCache.notify(UnitDuty.class);
-		ApplicationCache.notify(Identity.class);
+		CacheManager.notify(Person.class);
+		CacheManager.notify(PersonAttribute.class);
+		CacheManager.notify(Unit.class);
+		CacheManager.notify(UnitAttribute.class);
+		CacheManager.notify(UnitDuty.class);
+		CacheManager.notify(Identity.class);
 		result.end();
 		if (!result.getCreateUnitList().isEmpty()) {
 			logger.print("创建组织({}):{}.", result.getCreateUnitList().size(),

+ 10 - 12
o2server/x_program_center/src/main/java/com/x/program/center/schedule/TriggerAgent.java

@@ -3,6 +3,7 @@ package com.x.program.center.schedule;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.stream.Collectors;
 
@@ -21,10 +22,11 @@ import javax.script.SimpleScriptContext;
 import org.apache.commons.lang3.StringUtils;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
-
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.script.AbstractResources;
@@ -38,17 +40,12 @@ import com.x.program.center.ThisApplication;
 import com.x.program.center.core.entity.Agent;
 import com.x.program.center.core.entity.Agent_;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 public class TriggerAgent extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(TriggerAgent.class);
 
 	private static final CopyOnWriteArrayList<String> LOCK = new CopyOnWriteArrayList<>();
 
-	private static Ehcache cache = ApplicationCache.instance().getCache(Agent.class);
-
 	@Override
 	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 		try {
@@ -186,14 +183,15 @@ public class TriggerAgent extends BaseAction {
 				try {
 					LOCK.add(agent.getId());
 					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						String cacheKey = ApplicationCache.concreteCacheKey(TriggerAgent.class, agent.getId());
-						Element element = cache.get(cacheKey);
+						CacheCategory cacheCategory = new CacheCategory(Agent.class);
+						CacheKey cacheKey = new CacheKey(TriggerAgent.class, agent.getId());
 						CompiledScript compiledScript = null;
-						if ((null != element) && (null != element.getObjectValue())) {
-							compiledScript = (CompiledScript) element.getObjectValue();
+						Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+						if (optional.isPresent()) {
+							compiledScript = (CompiledScript) optional.get();
 						} else {
 							compiledScript = ScriptFactory.compile(ScriptFactory.functionalization(agent.getText()));
-							cache.put(new Element(cacheKey, compiledScript));
+							CacheManager.put(cacheCategory, cacheKey, compiledScript);
 						}
 						ScriptContext scriptContext = new SimpleScriptContext();
 						Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);

+ 7 - 7
o2server/x_program_center/src/main/java/com/x/program/center/welink/SyncOrganization.java

@@ -4,7 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.annotation.CheckRemoveType;
 import com.x.base.core.entity.type.GenderType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.XGsonBuilder;
@@ -56,12 +56,12 @@ public class SyncOrganization {
             this.check(business, result, units, people, personAttributes, identities, accessToken, factory, null, root);
         }
         this.clean(business, result, units, people, identities);
-        ApplicationCache.notify(Person.class);
-        ApplicationCache.notify(PersonAttribute.class);
-        ApplicationCache.notify(Unit.class);
-        ApplicationCache.notify(UnitAttribute.class);
-        ApplicationCache.notify(UnitDuty.class);
-        ApplicationCache.notify(Identity.class);
+        CacheManager.notify(Person.class);
+        CacheManager.notify(PersonAttribute.class);
+        CacheManager.notify(Unit.class);
+        CacheManager.notify(UnitAttribute.class);
+        CacheManager.notify(UnitDuty.class);
+        CacheManager.notify(Identity.class);
         result.end();
         if (!result.getCreateUnitList().isEmpty()) {
             logger.print("创建组织({}):{}.", result.getCreateUnitList().size(),

+ 7 - 7
o2server/x_program_center/src/main/java/com/x/program/center/zhengwudingding/SyncOrganization.java

@@ -18,6 +18,7 @@ import javax.script.Bindings;
 import javax.script.ScriptContext;
 import javax.script.SimpleScriptContext;
 
+import com.x.base.core.project.cache.CacheManager;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -27,7 +28,6 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.annotation.CheckRemoveType;
 import com.x.base.core.entity.type.GenderType;
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.XGsonBuilder;
@@ -64,12 +64,12 @@ public class SyncOrganization {
 			this.check(business, result, units, people, personAttributes, identities, accessToken, factory, null, root);
 		}
 		this.clean(business, result, units, people, identities);
-		ApplicationCache.notify(Person.class);
-		ApplicationCache.notify(PersonAttribute.class);
-		ApplicationCache.notify(Unit.class);
-		ApplicationCache.notify(UnitAttribute.class);
-		ApplicationCache.notify(UnitDuty.class);
-		ApplicationCache.notify(Identity.class);
+		CacheManager.notify(Person.class);
+		CacheManager.notify(PersonAttribute.class);
+		CacheManager.notify(Unit.class);
+		CacheManager.notify(UnitAttribute.class);
+		CacheManager.notify(UnitDuty.class);
+		CacheManager.notify(Identity.class);
 		result.end();
 		if (!result.getCreateUnitList().isEmpty()) {
 			logger.print("创建组织({}):{}.", result.getCreateUnitList().size(),