Browse Source

增加动态实体类

roo00 7 years ago
parent
commit
5d4726afcc
38 changed files with 1518 additions and 295 deletions
  1. 1 2
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Nodes.java
  2. 3 2
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/JarTools.java
  3. 0 7
      o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestOver.java
  4. 8 0
      o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/javapoet/package-info.java
  5. 25 22
      o2server/x_console/src/main/java/com/x/server/console/Main.java
  6. 16 16
      o2server/x_console/src/main/java/com/x/server/console/NodeAgent.java
  7. 17 10
      o2server/x_console/src/main/java/com/x/server/console/action/PersistenceXmlHelper.java
  8. 114 33
      o2server/x_console/src/main/java/com/x/server/console/server/JettySeverTools.java
  9. 152 47
      o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java
  10. 62 12
      o2server/x_console/src/main/java/com/x/server/console/server/center/CenterServerTools.java
  11. 44 0
      o2server/x_program_center/aaa.json
  12. 39 19
      o2server/x_program_center/src/main/java/com/x/program/center/Context.java
  13. 7 8
      o2server/x_program_center/src/main/java/com/x/program/center/ReportQueue.java
  14. 17 3
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/cachedispatch/ActionDispatch.java
  15. 67 44
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/cachedispatch/BaseAction.java
  16. 28 19
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/distribute/BaseAction.java
  17. 4 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/ActionList.java
  18. 14 17
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/BaseAction.java
  19. 1 1
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/schedule/ActionFire.java
  20. 1 1
      o2server/x_program_center/src/main/java/com/x/program/center/schedule/FireSchedule.java
  21. 1 1
      o2server/x_program_center_core_entity/src/main/java/com/x/program/center/core/entity/validation/Meta.java
  22. 302 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/DynamicEntity.java
  23. 367 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/DynamicEntityBuilder.java
  24. 2 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/ActionApplication.java
  25. 10 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/TableJaxrsFilter.java
  26. 6 6
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionCreateModel.java
  27. 2 2
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionListModel.java
  28. 94 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/ActionCompile.java
  29. 7 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/BaseAction.java
  30. 46 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/TableAction.java
  31. 8 0
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/package-info.java
  32. 20 0
      o2server/x_query_assemble_designer/src/test/java/com/x/query/assemble/designer/test/TestClient.java
  33. 8 0
      o2server/x_query_assemble_designer/src/test/java/com/x/query/assemble/designer/test/package-info.java
  34. 4 4
      o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionListCalculate.java
  35. 5 5
      o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/NeuralAction.java
  36. 2 2
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionListCalculateWithWork.java
  37. 4 4
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/NeuralAction.java
  38. 10 4
      o2server/x_query_service_processing/src/test/java/com/x/query/service/processing/test/TestClient.java

+ 1 - 2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Nodes.java

@@ -79,9 +79,8 @@ public class Nodes extends ConcurrentSkipListMap<String, Node> {
 	}
 
 	public void save() throws Exception {
-		File dir = new File(Config.base(), Config.PATH_CONFIG);
 		for (Entry<String, Node> en : this.entrySet()) {
-			File file = new File(dir, "node_" + en.getKey() + ".json");
+			File file = new File(Config.dir_config(), "node_" + en.getKey() + ".json");
 			FileUtils.write(file, XGsonBuilder.toJson(en.getValue()), DefaultCharset.charset);
 		}
 	}

+ 3 - 2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/JarTools.java

@@ -15,6 +15,7 @@ import java.util.jar.JarOutputStream;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
 
 public class JarTools {
 
@@ -199,8 +200,8 @@ public class JarTools {
 	}
 
 	public static void main(String[] args) throws Exception {
-		byte[] bytes = JarTools.jar("e:/bbb");
-		FileUtils.writeByteArrayToFile(new File("e:/bbb2.zip"), bytes);
+		System.out.println(StringUtils.startsWith("asdfasdf", ""));
+		System.out.println(StringUtils.startsWith("asdfasdf", null));
 	}
 
 }

+ 0 - 7
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestOver.java

@@ -56,11 +56,4 @@ public class TestOver {
 		}
 	}
 
-	@Test
-	public void test5() throws Exception {
-		for (Class<?> x : AssembleA.dependWith(x_processplatform_core_entity.class)) {
-			System.out.println(x);
-		}
-	}
-
 }

+ 8 - 0
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/javapoet/package-info.java

@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author zhour
+ *
+ */
+package com.x.base.core.project.test.javapoet;

+ 25 - 22
o2server/x_console/src/main/java/com/x/server/console/Main.java

@@ -733,18 +733,18 @@ public class Main {
 		Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class });
 		method.setAccessible(true);
 		/* loading ext */
-		File extDir = new File(base, "commons/ext");
-		File extDirManifest = new File(extDir, MANIFEST_FILENAME);
-		if (!extDirManifest.exists()) {
+		File commons_ext_dir = new File(base, "commons/ext");
+		File commons_ext_manifest_file = new File(commons_ext_dir, MANIFEST_FILENAME);
+		if (!commons_ext_manifest_file.exists()) {
 			throw new Exception("can not find " + MANIFEST_FILENAME + " in commons/ext.");
 		}
-		List<String> extDirManifestNames = readManifest(extDirManifest);
-		if (extDirManifestNames.isEmpty()) {
+		List<String> commons_ext_manifest_names = readManifest(commons_ext_manifest_file);
+		if (commons_ext_manifest_names.isEmpty()) {
 			throw new Exception("commons/ext manifest is empty.");
 		}
-		for (File file : extDir.listFiles()) {
+		for (File file : commons_ext_dir.listFiles()) {
 			if ((!file.getName().equals(MANIFEST_FILENAME)) && (!file.getName().equals(GITIGNORE_FILENAME))) {
-				if (!extDirManifestNames.remove(file.getName())) {
+				if (!commons_ext_manifest_names.remove(file.getName())) {
 					System.out.println("载入 commons/ext 过程中删除无效的文件:" + file.getName());
 					file.delete();
 				} else {
@@ -752,21 +752,19 @@ public class Main {
 				}
 			}
 		}
-		if (!extDirManifestNames.isEmpty()) {
-			for (String str : extDirManifestNames) {
-				System.out.println("载入 commons/ext 过程中无法找到文件:" + str);
-			}
+		for (String str : commons_ext_manifest_names) {
+			System.out.println("载入 commons/ext 过程中无法找到文件:" + str);
 		}
 		/* loading jars */
-		File jarsDir = new File(base, "store/jars");
-		File jarsDirManifest = new File(jarsDir, MANIFEST_FILENAME);
-		if (!jarsDirManifest.exists()) {
+		File store_jars_dir = new File(base, "store/jars");
+		File store_jars_manifest_file = new File(store_jars_dir, MANIFEST_FILENAME);
+		if (!store_jars_manifest_file.exists()) {
 			throw new Exception("can not find " + MANIFEST_FILENAME + " in store/jars.");
 		}
-		List<String> jarsDirManifestNames = readManifest(jarsDirManifest);
-		for (File file : jarsDir.listFiles()) {
+		List<String> store_jars_manifest_names = readManifest(store_jars_manifest_file);
+		for (File file : store_jars_dir.listFiles()) {
 			if ((!file.getName().equals(MANIFEST_FILENAME)) && (!file.getName().equals(GITIGNORE_FILENAME))) {
-				if (!jarsDirManifestNames.remove(file.getName())) {
+				if (!store_jars_manifest_names.remove(file.getName())) {
 					System.out.println("载入 store/jars 过程中删除无效的文件:" + file.getName());
 					file.delete();
 				} else {
@@ -774,13 +772,18 @@ public class Main {
 				}
 			}
 		}
-		if (!jarsDirManifestNames.isEmpty()) {
-			for (String str : jarsDirManifestNames) {
-				System.out.println("载入 store/jars 过程中无法找到文件:" + str);
+		for (String str : store_jars_manifest_names) {
+			System.out.println("载入 store/jars 过程中无法找到文件:" + str);
+		}
+		/* load custom jar */
+		File custom_jars_dir = new File(base, "custom/jars");
+		if (custom_jars_dir.exists() && custom_jars_dir.isDirectory()) {
+			for (File file : Config.dir_custom_jars().listFiles()) {
+				method.invoke(urlClassLoader, new Object[] { file.toURI().toURL() });
 			}
 		}
-		File tempDir = new File(base, "local/temp/classes");
-		method.invoke(urlClassLoader, new Object[] { tempDir.toURI().toURL() });
+		/* load temp class */
+		method.invoke(urlClassLoader, new Object[] { Config.dir_local_temp_classes().toURI().toURL() });
 	}
 
 	private static String getBasePath() throws Exception {

+ 16 - 16
o2server/x_console/src/main/java/com/x/server/console/NodeAgent.java

@@ -101,22 +101,22 @@ public class NodeAgent extends Thread {
 				byte[] bytes = Base64.decodeBase64(body);
 				File file = new File(Config.base(), "store/jars/" + cls.getSimpleName() + ".jar");
 				FileUtils.writeByteArrayToFile(file, bytes);
-				if (Servers.applicationServerIsRunning()) {
-					DeploymentManager deployer = Servers.applicationServer.getBean(DeploymentManager.class);
-					List<String> dependWithContexts = new ArrayList<>();
-					for (Class<AssembleA> a : AssembleA.dependWith(cls)) {
-						dependWithContexts.add("/" + a.getSimpleName());
-					}
-					System.out.println(XGsonBuilder.toJson(dependWithContexts));
-					if (ListTools.isNotEmpty(dependWithContexts)) {
-						for (App app : deployer.getApps()) {
-							if (dependWithContexts.contains(app.getContextPath())) {
-								app.getContextHandler().stop();
-								app.getContextHandler().start();
-							}
-						}
-					}
-				}
+//				if (Servers.applicationServerIsRunning()) {
+//					DeploymentManager deployer = Servers.applicationServer.getBean(DeploymentManager.class);
+//					List<String> dependWithContexts = new ArrayList<>();
+//					for (Class<AssembleA> a : AssembleA.dependWith(cls)) {
+//						dependWithContexts.add("/" + a.getSimpleName());
+//					}
+//					System.out.println(XGsonBuilder.toJson(dependWithContexts));
+//					if (ListTools.isNotEmpty(dependWithContexts)) {
+//						for (App app : deployer.getApps()) {
+//							if (dependWithContexts.contains(app.getContextPath())) {
+//								app.getContextHandler().stop();
+//								app.getContextHandler().start();
+//							}
+//						}
+//					}
+//				}
 			} else if (ServiceA.class.isAssignableFrom(cls)) {
 				byte[] bytes = Base64.decodeBase64(body);
 				File file = new File(Config.base(), "store/" + cls.getSimpleName() + ".war");

+ 17 - 10
o2server/x_console/src/main/java/com/x/server/console/action/PersistenceXmlHelper.java

@@ -25,15 +25,14 @@ import com.x.base.core.entity.AbstractPersistenceProperties;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.Storage;
 import com.x.base.core.entity.annotation.ContainerEntity;
-import com.x.base.core.project.Packages;
 import com.x.base.core.project.config.DataMapping;
 import com.x.base.core.project.config.DataMappings;
-import com.x.base.core.project.tools.ClassTools;
 import com.x.base.core.project.tools.DefaultCharset;
 import com.x.base.core.project.tools.ListTools;
 
-import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
-import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ScanResult;
 
 public class PersistenceXmlHelper {
 
@@ -278,15 +277,23 @@ public class PersistenceXmlHelper {
 	}
 
 	public static List<String> listDataClassName() throws Exception {
-		ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
-		List<String> list = scanResult.getNamesOfClassesWithAnnotation(ContainerEntity.class);
-		return list;
+		try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+			List<String> list = new ArrayList<>();
+			for (ClassInfo info : scanResult.getClassesWithAnnotation(ContainerEntity.class.getName())) {
+				list.add(info.getName());
+			}
+			return list;
+		}
 	}
 
 	public static List<String> listStorageClassName() throws Exception {
-		ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
-		List<String> list = scanResult.getNamesOfClassesWithAnnotation(Storage.class);
-		return list;
+		try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+			List<String> list = new ArrayList<>();
+			for (ClassInfo info : scanResult.getClassesWithAnnotation(Storage.class.getName())) {
+				list.add(info.getName());
+			}
+			return list;
+		}
 	}
 
 	public static List<Class<?>> listClassWithIncludesExcludes(List<String> list, List<String> includes,

+ 114 - 33
o2server/x_console/src/main/java/com/x/server/console/server/JettySeverTools.java

@@ -19,11 +19,23 @@ import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 
+import com.x.base.core.project.Dependency;
+import com.x.base.core.project.Deployable;
+import com.x.base.core.project.x_base_core_project;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.tools.DefaultCharset;
 
+import io.github.classgraph.ClassInfo;
+
 public abstract class JettySeverTools {
 
+	protected static final String PATH_COMMONS = "commons";
+	protected static final String PATH_COMMONS_EXT = "commons/ext";
+	protected static final String PATH_STORE = "store";
+	protected static final String PATH_STORE_JARS = "store/jars";
+	protected static final String PATH_CUSTOM = "custom";
+	protected static final String PATH_CUSTOM_JARS = "custom/jars";
+
 	protected static void addHttpsConnector(Server server, Integer port) throws Exception {
 		SslContextFactory sslContextFactory = new SslContextFactory();
 		// File file = new File(configDir, "o2.keystore");
@@ -68,66 +80,135 @@ public abstract class JettySeverTools {
 		FileUtils.cleanDirectory(dir);
 	}
 
-	protected static void createDeployDescriptor(Class<?> clazz, File webappsDir, File workDir, File storeDir,
-			File extDir, File jarsDir) throws Exception {
+//	protected static void createDeployDescriptor(Class<?> clazz, File webappsDir, File workDir, File storeDir,
+//			File extDir, File jarsDir) throws Exception {
+//		StringBuffer buffer = new StringBuffer();
+//		buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+//		if (Config.currentNode().getQuickStartWebApp()) {
+//			buffer.append("<Configure class=\"org.eclipse.jetty.quickstart.QuickStartWebApp\">");
+//			buffer.append("<Set name=\"autoPreconfigure\">true</Set>");
+//			/*
+//			 * 使用org.eclipse.jetty.quickstart.QuickStartWebApp 启动速度大约快50% 需要设置
+//			 * autoPreconfigure=true
+//			 */
+//		} else {
+//			buffer.append("<Configure class=\"org.eclipse.jetty.webapp.WebAppContext\">");
+//		}
+//		buffer.append("<Set name=\"contextPath\">/" + clazz.getSimpleName() + "</Set>");
+//		File war = new File(storeDir, clazz.getSimpleName() + ".war");
+//		buffer.append("<Set name=\"war\">" + war.getAbsolutePath() + "</Set>");
+//		String extraClasspath = calculateExtraClassPath(clazz, extDir, jarsDir);
+//		buffer.append("	<Set name=\"extraClasspath\">" + extraClasspath + "</Set>");
+//		String tempDirectory = new File(workDir, clazz.getSimpleName()).getAbsolutePath();
+//		buffer.append("	<Set name=\"tempDirectory\">" + tempDirectory + "</Set>");
+//		buffer.append("	</Configure>");
+//		File file = new File(webappsDir, clazz.getSimpleName() + ".xml");
+//		FileUtils.write(file, buffer.toString(), DefaultCharset.charset);
+//	}
+
+	protected static void createOfficialDeployDescriptor(ClassInfo info) throws Exception {
 		StringBuffer buffer = new StringBuffer();
+		Class<?> cls = Class.forName(info.getName());
 		buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
 		if (Config.currentNode().getQuickStartWebApp()) {
 			buffer.append("<Configure class=\"org.eclipse.jetty.quickstart.QuickStartWebApp\">");
 			buffer.append("<Set name=\"autoPreconfigure\">true</Set>");
-			/*
-			 * 使用org.eclipse.jetty.quickstart.QuickStartWebApp 启动速度大约快50% 需要设置
-			 * autoPreconfigure=true
-			 */
 		} else {
 			buffer.append("<Configure class=\"org.eclipse.jetty.webapp.WebAppContext\">");
 		}
-		buffer.append("<Set name=\"contextPath\">/" + clazz.getSimpleName() + "</Set>");
-		File war = new File(storeDir, clazz.getSimpleName() + ".war");
+		buffer.append("<Set name=\"contextPath\">/" + info.getSimpleName() + "</Set>");
+		File war = new File(Config.dir_store(), info.getSimpleName() + ".war");
 		buffer.append("<Set name=\"war\">" + war.getAbsolutePath() + "</Set>");
-		String extraClasspath = calculateExtraClassPath(clazz, extDir, jarsDir);
-		buffer.append("	<Set name=\"extraClasspath\">" + extraClasspath + "</Set>");
-		String tempDirectory = new File(workDir, clazz.getSimpleName()).getAbsolutePath();
-		buffer.append("	<Set name=\"tempDirectory\">" + tempDirectory + "</Set>");
-		buffer.append("	</Configure>");
-		File file = new File(webappsDir, clazz.getSimpleName() + ".xml");
+		String extraClasspath = calculateExtraClassPath(cls);
+		buffer.append("<Set name=\"extraClasspath\">" + extraClasspath + "</Set>");
+		String tempDirectory = new File(Config.dir_servers_applicationServer_work(), info.getSimpleName())
+				.getAbsolutePath();
+		buffer.append("<Set name=\"tempDirectory\">" + tempDirectory + "</Set>");
+		buffer.append("</Configure>");
+		File file = new File(Config.dir_servers_applicationServer_webapps(), info.getSimpleName() + ".xml");
 		FileUtils.write(file, buffer.toString(), DefaultCharset.charset);
 	}
 
-	private static String calculateExtraClassPath(Class<?> clazz, File extDir, File jarsDir) throws Exception {
+	protected static String calculateExtraClassPath(Class<?> cls) throws Exception {
 		List<String> jars = new ArrayList<>();
-		jars.addAll(calculateExtraClassPathExt(extDir));
-		jars.addAll(calculateExtraClassPathDependents(clazz, jarsDir));
+		jars.addAll(calculateExtraClassPathDefault());
+		Deployable deployable = (Deployable) cls.newInstance();
+		Dependency dependency = deployable.dependency();
+		for (String str : dependency.storeJars) {
+			File file = new File(Config.dir_store_jars(), str + ".jar");
+			if (file.exists()) {
+				jars.add(file.getAbsolutePath());
+			}
+		}
+		for (String str : dependency.customJars) {
+			File file = new File(Config.dir_custom_jars(), str + ".jar");
+			if (file.exists()) {
+				jars.add(file.getAbsolutePath());
+			}
+		}
 		return StringUtils.join(jars, ";");
 	}
 
-	private static List<String> calculateExtraClassPathExt(File extDir) {
+//	private static String calculateExtraClassPath(ClassInfo classInfo, File commons_ext_dir, File store_jars_dir,
+//			File custom_jars_dir) throws Exception {
+//		List<String> jars = new ArrayList<>();
+//		jars.addAll(calculateExtraClassPathDefault(commons_ext_dir, store_jars_dir));
+//		jars.addAll(calculateExtraClassPathDependency(classInfo, commons_ext_dir, store_jars_dir, custom_jars_dir));
+//		return StringUtils.join(jars, ";");
+//	}
+
+//	protected static List<String> calculateExtraClassPathDefault(File commons_ext_dir, File store_jars_dir) {
+//		List<String> jars = new ArrayList<>();
+//		IOFileFilter filter = new WildcardFileFilter(x_base_core_project.class.getSimpleName() + "*.jar");
+//		for (File o : FileUtils.listFiles(store_jars_dir, filter, null)) {
+//			jars.add(o.getAbsolutePath());
+//		}
+//		filter = new WildcardFileFilter("slf4j-api-*.jar");
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("slf4j-simple-*.jar"));
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("jul-to-slf4j-*.jar"));
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("openjpa-*.jar"));
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("ehcache-*.jar"));
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("jetty-all-*.jar"));
+//		filter = FileFilterUtils.or(filter, new WildcardFileFilter("quartz-*.jar"));
+//		for (File o : FileUtils.listFiles(commons_ext_dir, filter, null)) {
+//			jars.add(o.getAbsolutePath());
+//		}
+//		return jars;
+//	}
+
+	private static List<String> calculateExtraClassPathDefault() throws Exception {
 		List<String> jars = new ArrayList<>();
-		IOFileFilter filter = new WildcardFileFilter("slf4j-api-*.jar");
+		IOFileFilter filter = new WildcardFileFilter(x_base_core_project.class.getSimpleName() + "*.jar");
+		for (File o : FileUtils.listFiles(Config.dir_store_jars(), filter, null)) {
+			jars.add(o.getAbsolutePath());
+		}
+		filter = new WildcardFileFilter("slf4j-api-*.jar");
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("slf4j-simple-*.jar"));
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("jul-to-slf4j-*.jar"));
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("openjpa-*.jar"));
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("ehcache-*.jar"));
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("jetty-all-*.jar"));
 		filter = FileFilterUtils.or(filter, new WildcardFileFilter("quartz-*.jar"));
-		for (File o : FileUtils.listFiles(extDir, filter, null)) {
+		for (File o : FileUtils.listFiles(Config.dir_commons_ext(), filter, null)) {
 			jars.add(o.getAbsolutePath());
 		}
 		return jars;
 	}
 
-	private static List<String> calculateExtraClassPathDependents(Class<?> clazz, File jarsDir) throws Exception {
-		List<String> jars = new ArrayList<>();
-		IOFileFilter filter = FalseFileFilter.FALSE;
-		@SuppressWarnings("unchecked")
-		List<Class<?>> list = (List<Class<?>>) FieldUtils.readStaticField(clazz, "dependents");
-		for (Class<?> o : list) {
-			filter = FileFilterUtils.or(filter, new WildcardFileFilter(o.getSimpleName() + ".jar"));
-		}
-		for (File o : FileUtils.listFiles(jarsDir, filter, null)) {
-			jars.add(o.getAbsolutePath());
-		}
-		return jars;
-	}
+//	private static List<String> calculateExtraClassPathDependency(ClassInfo classInfo, File commons_ext_dir,
+//			File store_jars_dir, File custom_jars_dir) throws Exception {
+//		List<String> jars = new ArrayList<>();
+//		IOFileFilter filter = FalseFileFilter.FALSE;
+//		@SuppressWarnings("unchecked")
+//		Class<?> cls = Class.forName(classInfo.getName());
+//		List<Class<?>> list = (List<Class<?>>) FieldUtils.readStaticField(cls, "dependents");
+//		for (Class<?> o : list) {
+//			filter = FileFilterUtils.or(filter, new WildcardFileFilter(o.getSimpleName() + ".jar"));
+//		}
+//		for (File o : FileUtils.listFiles(store_jars_dir, filter, null)) {
+//			jars.add(o.getAbsolutePath());
+//		}
+//		return jars;
+//	}
 
 }

+ 152 - 47
o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java

@@ -1,10 +1,24 @@
 package com.x.server.console.server.application;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jetty.annotations.AnnotationConfiguration;
@@ -23,48 +37,69 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.eclipse.jetty.webapp.Configuration.ClassList;
 import org.eclipse.jetty.webapp.FragmentConfiguration;
 import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
 
-import com.x.base.core.project.AssembleA;
-import com.x.base.core.project.Packages;
-import com.x.base.core.project.ServiceA;
+import com.x.base.core.project.annotation.Module;
+import com.x.base.core.project.annotation.ModuleCategory;
+import com.x.base.core.project.annotation.ModuleType;
 import com.x.base.core.project.config.ApplicationServer;
 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.tools.DefaultCharset;
+import com.x.base.core.project.tools.JarTools;
 import com.x.base.core.project.tools.ListTools;
 import com.x.server.console.server.JettySeverTools;
 
-import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
-import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ScanResult;
 
 public class ApplicationServerTools extends JettySeverTools {
 
-	private static String project_class_prefix = "com.x.base.core.project.";
+	// private static String project_class_prefix = "com.x.base.core.project.";
 
 	private static Logger logger = LoggerFactory.getLogger(ApplicationServerTools.class);
 
-	private static int APPLICATIONSERVER_THREAD_POOL_SIZE_MIN = 10;
+	private static int APPLICATIONSERVER_THREAD_POOL_SIZE_MIN = 5;
 	private static int APPLICATIONSERVER_THREAD_POOL_SIZE_MAX = 50;
 
+	protected static String PATH_WEBAPPS = "servers/applicationServer/webapps";
+	protected static String PATH_WORK = "servers/applicationServer/work";
+
 	public static Server start(ApplicationServer applicationServer) throws Exception {
-		File commonsDir = new File(Config.base(), "commons");
-		File webappsDir = new File(Config.base(), "servers/applicationServer/webapps");
-		File workDir = new File(Config.base(), "servers/applicationServer/work");
-		File extDir = new File(Config.base(), "commons/ext");
-		File storeDir = new File(Config.base(), "store");
-		File jarsDir = new File(Config.base(), "store/jars");
 
 		if (BooleanUtils.isTrue(applicationServer.getRedeploy())) {
-			cleanDirectory(workDir);
-			cleanDirectory(webappsDir);
-			List<Class<?>> classes = calculateProjectToDepoly();
-			for (Class<?> clz : classes) {
-				/** 检查store目录是否存在war文件 */
-				File war = new File(storeDir, clz.getSimpleName() + ".war");
-				if (war.exists()) {
-					/* 创建空tempDirectory目录 */
-					FileUtils.forceMkdir(new File(workDir, clz.getSimpleName()));
-					createDeployDescriptor(clz, webappsDir, workDir, storeDir, extDir, jarsDir);
+			cleanDirectory(Config.dir_servers_applicationServer_work());
+			cleanDirectory(Config.dir_servers_applicationServer_webapps());
+			List<ClassInfo> classInfoList = listOfficial();
+			classInfoList = filter(classInfoList);
+			logger.print("start to deploy official module, size:{}.", classInfoList.size());
+			for (ClassInfo info : classInfoList) {
+				Class<?> clz = Class.forName(info.getName());
+				Module module = clz.getAnnotation(Module.class);
+				if (Objects.equals(ModuleCategory.OFFICIAL, module.category())) {
+					/* 检查store目录是否存在war文件 */
+					File war = new File(Config.dir_store(), info.getSimpleName() + ".war");
+					if (war.exists()) {
+						/* 创建空tempDirectory目录 */
+						FileUtils.forceMkdir(
+								new File(Config.dir_servers_applicationServer_work(), info.getSimpleName()));
+						createOfficialDeployDescriptor(info);
+					}
+				}
+			}
+			List<String> customWars = listCustom();
+			if (!customWars.isEmpty()) {
+				logger.print("start to deploy custom module, size:{}.", customWars.size());
+				for (String str : customWars) {
+					File war = new File(Config.dir_custom(), str);
+					if (war.exists()) {
+						/* 创建空tempDirectory目录 */
+						// FileUtils.forceMkdir(new File(Config, FilenameUtils.getBaseName(str)));
+						customDeployDescriptor(war);
+					}
 				}
 			}
 		}
@@ -90,8 +125,8 @@ public class ApplicationServerTools extends JettySeverTools {
 		deployer.setContexts(contexts);
 
 		WebAppProvider webAppProvider = new WebAppProvider();
-		webAppProvider.setMonitoredDirName(webappsDir.getAbsolutePath());
-		webAppProvider.setDefaultsDescriptor(new File(commonsDir, "webdefault_a.xml").getAbsolutePath());
+		webAppProvider.setMonitoredDirName(Config.dir_servers_applicationServer_webapps().getAbsolutePath());
+		webAppProvider.setDefaultsDescriptor(new File(Config.dir_commons(), "webdefault_a.xml").getAbsolutePath());
 		webAppProvider.setScanInterval(applicationServer.getScanInterval());
 		webAppProvider.setExtractWars(true);
 		webAppProvider.setConfigurationManager(new PropertiesConfigurationManager());
@@ -118,34 +153,104 @@ public class ApplicationServerTools extends JettySeverTools {
 		return server;
 	}
 
-	private static List<Class<?>> calculateProjectToDepoly() throws Exception {
-		ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
+	private static List<ClassInfo> listOfficial() throws Exception {
+		try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+			List<ClassInfo> list = new ArrayList<>();
+			List<ClassInfo> classInfos = scanResult.getClassesWithAnnotation(Module.class.getName());
+			for (ClassInfo info : classInfos) {
+				Class<?> clz = Class.forName(info.getName());
+				Module module = clz.getAnnotation(Module.class);
+				if (Objects.equals(module.type(), ModuleType.ASSEMBLE)
+						|| Objects.equals(module.type(), ModuleType.SERVICE)) {
+					list.add(info);
+				}
+			}
+			List<String> filters = new ArrayList<>();
+			for (ClassInfo info : list) {
+				filters.add(info.getName());
+			}
+			filters = ListTools.includesExcludes(filters, Config.currentNode().getApplication().getIncludes(),
+					Config.currentNode().getApplication().getExcludes());
+			List<ClassInfo> os = new ArrayList<>();
+			for (ClassInfo info : list) {
+				if (filters.contains(info.getName())) {
+					os.add(info);
+				}
+			}
+			return os;
+		}
+	}
+
+	private static List<String> listCustom() throws Exception {
 		List<String> list = new ArrayList<>();
-		list.addAll(scanResult.getNamesOfSubclassesOf(AssembleA.class));
-		list.addAll(scanResult.getNamesOfSubclassesOf(ServiceA.class));
+		for (String str : Config.dir_custom()
+				.list(FileFilterUtils.or(new WildcardFileFilter("*.WAR"), new WildcardFileFilter("*.war")))) {
+			list.add(str);
+		}
+		return list;
+	}
+
+	private static List<ClassInfo> filter(List<ClassInfo> list) throws Exception {
 		List<String> includes = new ArrayList<>();
 		List<String> excludes = new ArrayList<>();
-		if (ListTools.isNotEmpty(Config.currentNode().getApplication().getIncludes())) {
-			for (String str : Config.currentNode().getApplication().getIncludes()) {
-				if (!StringUtils.startsWith(str, project_class_prefix)) {
-					str = project_class_prefix + str;
-				}
-				includes.add(str);
-			}
+		includes.addAll(Config.currentNode().getApplication().getIncludes());
+		excludes.addAll(Config.currentNode().getApplication().getExcludes());
+		List<String> names = new ArrayList<>();
+		for (ClassInfo info : list) {
+			names.add(info.getName());
 		}
-		if (ListTools.isNotEmpty(Config.currentNode().getApplication().getExcludes())) {
-			for (String str : Config.currentNode().getApplication().getExcludes()) {
-				if (!StringUtils.startsWith(str, project_class_prefix)) {
-					str = project_class_prefix + str;
-				}
-				excludes.add(str);
+		names = ListTools.includesExcludesWildcard(names, includes, excludes);
+		List<ClassInfo> os = new ArrayList<>();
+		for (ClassInfo info : list) {
+			if (ListTools.contains(names, info.getName())) {
+				os.add(info);
 			}
 		}
-		list = ListTools.includesExcludesWildcard(list, includes, excludes);
-		List<Class<?>> clzs = new ArrayList<>();
-		for (String o : list) {
-			clzs.add(Class.forName(o));
+		return os;
+	}
+
+	private static void customDeployDescriptor(File war) throws Exception {
+		File unzip_dir = new File(Config.dir_local_temp(), FilenameUtils.getBaseName(war.getName()));
+		FileUtils.forceMkdir(unzip_dir);
+		FileUtils.cleanDirectory(unzip_dir);
+		JarTools.unjar(FileUtils.readFileToByteArray(war), "WEB-INF", unzip_dir, true);
+		URLClassLoader classLoader = new URLClassLoader(
+				new URL[] { new File(unzip_dir, "WEB-INF/classes").toURI().toURL() });
+		String className = contextParamProject(unzip_dir);
+		Class<?> cls = classLoader.loadClass(className);
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+		if (Config.currentNode().getQuickStartWebApp()) {
+			buffer.append("<Configure class=\"org.eclipse.jetty.quickstart.QuickStartWebApp\">");
+			buffer.append("<Set name=\"autoPreconfigure\">true</Set>");
+		} else {
+			buffer.append("<Configure class=\"org.eclipse.jetty.webapp.WebAppContext\">");
 		}
-		return clzs;
+		buffer.append("<Set name=\"contextPath\">/" + FilenameUtils.getBaseName(war.getName()) + "</Set>");
+		buffer.append("<Set name=\"war\">" + war.getAbsolutePath() + "</Set>");
+		String extraClasspath = calculateExtraClassPath(cls);
+		buffer.append("<Set name=\"extraClasspath\">" + extraClasspath + "</Set>");
+		String tempDirectory = new File(Config.dir_servers_applicationServer_work(),
+				FilenameUtils.getBaseName(war.getAbsolutePath())).getAbsolutePath();
+		buffer.append("<Set name=\"tempDirectory\">" + tempDirectory + "</Set>");
+		buffer.append("</Configure>");
+		/* classLoader需要关闭 */
+		classLoader.close();
+		File file = new File(Config.dir_servers_applicationServer_webapps(),
+				FilenameUtils.getBaseName(war.getName()) + ".xml");
+		FileUtils.write(file, buffer.toString(), DefaultCharset.charset);
+	}
+
+	private static String contextParamProject(File dir) throws Exception {
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder builder = factory.newDocumentBuilder();
+		Document doc = builder
+				.parse(new ByteArrayInputStream(FileUtils.readFileToByteArray(new File(dir, "WEB-INF/web.xml"))));
+		XPathFactory xPathfactory = XPathFactory.newInstance();
+		XPath xpath = xPathfactory.newXPath();
+		XPathExpression expr = xpath.compile("web-app/context-param[param-name='project']/param-value");
+		NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
+		String str = nodes.item(0).getTextContent();
+		return StringUtils.trim(str);
 	}
 }

+ 62 - 12
o2server/x_console/src/main/java/com/x/server/console/server/center/CenterServerTools.java

@@ -2,6 +2,7 @@ package com.x.server.console.server.center;
 
 import java.io.File;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.BooleanUtils;
 import org.eclipse.jetty.annotations.AnnotationConfiguration;
 import org.eclipse.jetty.deploy.DeploymentManager;
@@ -25,6 +26,7 @@ import com.x.base.core.project.config.CenterServer;
 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.tools.DefaultCharset;
 import com.x.server.console.server.JettySeverTools;
 
 public class CenterServerTools extends JettySeverTools {
@@ -32,20 +34,26 @@ public class CenterServerTools extends JettySeverTools {
 	private static Logger logger = LoggerFactory.getLogger(CenterServerTools.class);
 
 	private static int CENTERSERVER_THREAD_POOL_SIZE_MIN = 5;
-	private static int CENTERSERVER_THREAD_POOL_SIZE_MAX = 20;
+	private static int CENTERSERVER_THREAD_POOL_SIZE_MAX = 50;
+
+	protected static final String PATH_WEBAPPS = "servers/centerServer/webapps";
+	protected static final String PATH_WORK = "servers/centerServer/work";
 
 	public static Server start(CenterServer centerServer) throws Exception {
-		File commonsDir = new File(Config.base(), "commons");
-		File webappsDir = new File(Config.base(), "servers/centerServer/webapps");
-		File workDir = new File(Config.base(), "servers/centerServer/work");
-		File extDir = new File(Config.base(), "commons/ext");
-		File storeDir = new File(Config.base(), "store");
-		File jarsDir = new File(Config.base(), "store/jars");
+
+//		File commons_dir = new File(Config.base(), PATH_COMMONS);
+//		File commons_ext_dir = new File(Config.base(), PATH_COMMONS_EXT);
+//		File webapps_dir = new File(Config.base(), PATH_WEBAPPS);
+//		File work_dir = new File(Config.base(), PATH_WORK);
+//		File store_dir = new File(Config.base(), PATH_STORE);
+//		File store_jars_dir = new File(Config.base(), PATH_STORE_JARS);
+//		File custom_dir = new File(Config.base(), PATH_CUSTOM);
+//		File custom_jars_dir = new File(Config.base(), PATH_CUSTOM_JARS);
 
 		if (BooleanUtils.isTrue(centerServer.getRedeploy())) {
-			cleanDirectory(webappsDir);
-			cleanDirectory(workDir);
-			createDeployDescriptor(x_program_center.class, webappsDir, workDir, storeDir, extDir, jarsDir);
+			cleanDirectory(Config.dir_servers_centerServer_webapps());
+			cleanDirectory(Config.dir_servers_centerServer_work());
+			createDeployDescriptor();
 		}
 		QueuedThreadPool threadPool = new QueuedThreadPool();
 		threadPool.setMinThreads(CENTERSERVER_THREAD_POOL_SIZE_MIN);
@@ -69,8 +77,8 @@ public class CenterServerTools extends JettySeverTools {
 		deployer.setContexts(contexts);
 
 		WebAppProvider webAppProvider = new WebAppProvider();
-		webAppProvider.setMonitoredDirName(webappsDir.getAbsolutePath());
-		webAppProvider.setDefaultsDescriptor(new File(commonsDir, "webdefault_c.xml").getAbsolutePath());
+		webAppProvider.setMonitoredDirName(Config.dir_servers_centerServer_webapps().getAbsolutePath());
+		webAppProvider.setDefaultsDescriptor(new File(Config.dir_commons(), "webdefault_c.xml").getAbsolutePath());
 		webAppProvider.setScanInterval(centerServer.getScanInterval());
 		webAppProvider.setExtractWars(true);
 		webAppProvider.setConfigurationManager(new PropertiesConfigurationManager());
@@ -96,4 +104,46 @@ public class CenterServerTools extends JettySeverTools {
 		logger.print("center server start completed on port:{}.", centerServer.getPort());
 		return server;
 	}
+
+//	private static ClassInfo getClassInfo() {
+//		try (ScanResult scanResult = // Assign scanResult in try-with-resources
+//				new ClassGraph().enableAnnotationInfo() // Create a new ClassGraph instance
+//						// .verbose() // If you want to enable logging to stderr
+//						.enableAllInfo() // Scan classes, methods, fields, annotations
+//						.whitelistPackages("com.x.base.core.project")
+//						// .whitelistPackages("com.xyz") // Scan com.xyz and subpackages
+//						.scan()) { // Perform the scan and return a ScanResult
+//			List<ClassInfo> classInfos = scanResult.getClassesWithAnnotation(Module.class.getName());
+//			for (ClassInfo info : classInfos) {
+//				if (StringUtils.equals(x_program_center.class.getName(), info.getName())) {
+//					return info;
+//				}
+//			}
+//			return null;
+//		}
+//	}
+
+	protected static void createDeployDescriptor() throws Exception {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+		if (Config.currentNode().getQuickStartWebApp()) {
+			buffer.append("<Configure class=\"org.eclipse.jetty.quickstart.QuickStartWebApp\">");
+			buffer.append("<Set name=\"autoPreconfigure\">true</Set>");
+		} else {
+			buffer.append("<Configure class=\"org.eclipse.jetty.webapp.WebAppContext\">");
+		}
+		buffer.append("<Set name=\"contextPath\">/" + x_program_center.class.getSimpleName() + "</Set>");
+		File war = new File(Config.dir_store(), x_program_center.class.getSimpleName() + ".war");
+		buffer.append("<Set name=\"war\">" + war.getAbsolutePath() + "</Set>");
+		String extraClasspath = calculateExtraClassPath(x_program_center.class);
+		buffer.append("<Set name=\"extraClasspath\">" + extraClasspath + "</Set>");
+		String tempDirectory = new File(Config.dir_servers_centerServer_work(), x_program_center.class.getSimpleName())
+				.getAbsolutePath();
+		buffer.append("<Set name=\"tempDirectory\">" + tempDirectory + "</Set>");
+		buffer.append("</Configure>");
+		File file = new File(Config.dir_servers_centerServer_webapps(),
+				x_program_center.class.getSimpleName() + ".xml");
+		FileUtils.write(file, buffer.toString(), DefaultCharset.charset);
+	}
+
 }

+ 44 - 0
o2server/x_program_center/aaa.json

@@ -0,0 +1,44 @@
+{
+	"com.x.base.core.project.x_component_assemble_control": [
+		{
+			"name": "组件",
+			"node": "127.0.0.1",
+			"contextPath": "/x_component_assemble_control",
+			"port": 20020,
+			"token": "bd115139-1717-4c6c-ba75-78637d8a7277",
+			"sslEnable": false,
+			"proxyHost": "",
+			"proxyPort": 20020,
+			"weight": 100,
+			"reportDate": "2019-02-07 22:07:54"
+		}
+	],
+	"com.x.base.core.project.x_general_assemble_control": [
+		{
+			"name": "公共模块",
+			"node": "127.0.0.1",
+			"contextPath": "/x_general_assemble_control",
+			"port": 20020,
+			"token": "a7c3b168-d029-4068-87bb-9294f44653c2",
+			"sslEnable": false,
+			"proxyHost": "",
+			"proxyPort": 20020,
+			"weight": 100,
+			"reportDate": "2019-02-07 22:07:58"
+		}
+	],
+	"com.x.base.core.project.x_query_assemble_designer": [
+		{
+			"name": "数据查询设计",
+			"node": "127.0.0.1",
+			"contextPath": "/x_query_assemble_designer",
+			"port": 20020,
+			"token": "07c888af-5ed0-4b87-8829-13cb2c1d16db",
+			"sslEnable": false,
+			"proxyHost": "",
+			"proxyPort": 20020,
+			"weight": 100,
+			"reportDate": "2019-02-07 22:07:57"
+		}
+	]
+}

+ 39 - 19
o2server/x_program_center/src/main/java/com/x/program/center/Context.java

@@ -14,7 +14,6 @@ import javax.persistence.criteria.Root;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 
-import org.apache.commons.lang3.reflect.FieldUtils;
 import org.apache.openjpa.enhance.PCRegistry;
 import org.quartz.CronScheduleBuilder;
 import org.quartz.DateBuilder;
@@ -32,10 +31,10 @@ import org.quartz.impl.matchers.EverythingMatcher;
 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.StorageType;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.AbstractContext;
 import com.x.base.core.project.Applications;
+import com.x.base.core.project.Deployable;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.StorageMappings;
 import com.x.base.core.project.jaxrs.WrapClearCacheRequest;
@@ -85,6 +84,12 @@ public class Context extends AbstractContext {
 		return this.clazz;
 	}
 
+	private Deployable clazzInstance;
+
+	public Deployable clazzInstance() {
+		return this.clazzInstance;
+	}
+
 	/* 随机令牌 */
 	private volatile String token;
 
@@ -92,6 +97,20 @@ public class Context extends AbstractContext {
 		return this.token;
 	}
 
+	/* contextPath */
+	private volatile String contextPath;
+
+	public String contextPath() {
+		return this.contextPath;
+	}
+
+	/* name */
+	private volatile String name;
+
+	public String name() {
+		return this.name;
+	}
+
 	/* Applications资源 */
 	private volatile Applications applications;
 
@@ -143,25 +162,25 @@ public class Context extends AbstractContext {
 
 	private Context() throws Exception {
 		SslTools.ignoreSsl();
-		// SLF4JBridgeHandler.removeHandlersForRootLogger();
-		// SLF4JBridgeHandler.install();
-		// Logger.getLogger(QuartzScheduler.class.getName()).setLevel(Level.WARNING);
 		this.applications = new Applications();
 		this.token = UUID.randomUUID().toString();
 		this.queues = new ArrayList<AbstractQueue<?>>();
 		this.scheduler = new StdSchedulerFactory(SchedulerFactoryProperties.concrete()).getScheduler();
 		this.scheduler.getListenerManager().addJobListener(new JobReportListener(), EverythingMatcher.allJobs());
 		this.scheduler.start();
-
 	}
 
 	public static Context concrete(ServletContextEvent servletContextEvent) throws Exception {
 		ServletContext servletContext = servletContextEvent.getServletContext();
 		Context context = new Context();
+		context.contextPath = servletContext.getContextPath();
+		context.clazz = Class.forName(servletContext.getInitParameter(INITPARAMETER_PORJECT));
+		context.clazzInstance = (Deployable) context.clazz.newInstance();
+		context.name = getName(context.clazz);
 		context.path = servletContext.getRealPath("");
 		context.servletContext = servletContext;
 		context.servletContextName = servletContext.getServletContextName();
-		context.clazz = Class.forName("com.x.base.core.project." + context.servletContextName);
+		context.clazz = Class.forName(servletContextEvent.getServletContext().getInitParameter(INITPARAMETER_PORJECT));
 		context.initDatas();
 		context.initStorages();
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
@@ -218,23 +237,24 @@ public class Context extends AbstractContext {
 	}
 
 	private void initDatas() throws Exception {
-		@SuppressWarnings("unchecked")
-		List<String> containerEntities = (List<String>) FieldUtils.readStaticField(clazz, "containerEntities");
-		if (ListTools.isNotEmpty(containerEntities)) {
-			logger.print("{} loading datas, entity size:{}.", this.clazz.getName(), containerEntities.size());
-			EntityManagerContainerFactory.init(path, Config.dataMappings());
-		}
+		logger.print("{} loading datas, entity size:{}.", this.clazz.getName(),
+				clazzInstance.dependency().containerEntities.size());
+		EntityManagerContainerFactory.init(path, Config.dataMappings());
 	}
 
 	private void initStorages() throws Exception {
-		@SuppressWarnings("unchecked")
-		List<StorageType> usedStorageTypes = (List<StorageType>) FieldUtils.readStaticField(clazz, "usedStorageTypes");
-		if (ListTools.isNotEmpty(usedStorageTypes)) {
-			logger.print("{} loading storages, type size:{}.", this.clazz.getName(), usedStorageTypes.size());
-			this.storageMappings = Config.storageMappings();
-		}
+		this.storageMappings = Config.storageMappings();
 	}
 
+//	private void initStorages() throws Exception {
+//		@SuppressWarnings("unchecked")
+//		List<StorageType> usedStorageTypes = (List<StorageType>) FieldUtils.readStaticField(clazz, "usedStorageTypes");
+//		if (ListTools.isNotEmpty(usedStorageTypes)) {
+//			logger.print("{} loading storages, type size:{}.", this.clazz.getName(), usedStorageTypes.size());
+//			this.storageMappings = Config.storageMappings();
+//		}
+//	}
+
 	private void cleanupSchedule(EntityManagerContainer emc) throws Exception {
 		List<Schedule> list = emc.listAll(Schedule.class);
 		if (!list.isEmpty()) {

+ 7 - 8
o2server/x_program_center/src/main/java/com/x/program/center/ReportQueue.java

@@ -2,7 +2,6 @@ package com.x.program.center;
 
 import java.util.Date;
 import java.util.List;
-import java.util.Objects;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -10,8 +9,6 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
-import org.apache.commons.lang3.reflect.FieldUtils;
-
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.Application;
@@ -37,25 +34,27 @@ public class ReportQueue extends AbstractQueue<Report> {
 	@Override
 	protected void execute(Report report) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Class<?> clz = Class.forName(report.getClassName());
+			// Class<?> clz = Class.forName(report.getClassName());
 			Business business = new Business(emc);
-			Application application = ThisApplication.context().applications().get(clz, report.getToken());
+			Application application = ThisApplication.context().applications().get(report.getClassName(),
+					report.getToken());
 			if (null != application) {
 				application.setReportDate(new Date());
 			} else {
 				ApplicationServer applicationServer = Config.nodes().applicationServers().get(report.getNode());
 				application = new Application();
-				application.setName(Objects.toString(FieldUtils.readStaticField(clz, "name")));
+				application.setName(report.getName());
+				application.setDependency(report.getDependency());
 				application.setNode(report.getNode());
 				application.setPort(applicationServer.getPort());
-				application.setContext("/" + clz.getSimpleName());
+				application.setContextPath(report.getContextPath());
 				application.setToken(report.getToken());
 				application.setWeight((null == report.getWeight()) ? 100 : report.getWeight());
 				application.setSslEnable(report.getSslEnable());
 				application.setReportDate(new Date());
 				application.setProxyPort(applicationServer.getProxyPort());
 				application.setProxyHost(applicationServer.getProxyHost());
-				ThisApplication.context().applications().add(clz, application);
+				ThisApplication.context().applications().add(report.getClassName(), application);
 				ThisApplication.context().applications().setToken(StringTools.uniqueToken());
 			}
 			if (ListTools.isNotEmpty(report.getScheduleLocalRequestList())) {

+ 17 - 3
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/cachedispatch/ActionDispatch.java

@@ -23,8 +23,8 @@ class ActionDispatch extends BaseAction {
 		ActionResult<Wo> result = new ActionResult<>();
 		logger.debug("receive dispatch cache request: {}", XGsonBuilder.toJson(jsonElement));
 		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
-		findApplicationWithEntity(wi.getClassName()).stream().forEach(c -> {
-			List<Application> apps = ThisApplication.context().applications().get(c.getName());
+		for (String str : ThisApplication.context().applications().listContainEntity(wi.getClassName())) {
+			List<Application> apps = ThisApplication.context().applications().get(str);
 			if (ListTools.isNotEmpty(apps)) {
 				apps.stream().forEach(o -> {
 					String url = o.getUrlRoot() + "cache";
@@ -36,7 +36,21 @@ class ActionDispatch extends BaseAction {
 					}
 				});
 			}
-		});
+		}
+		// findApplicationWithEntity(wi.getClassName()).stream().forEach(c -> {
+//			List<Application> apps = ThisApplication.context().applications().get(c.getName());
+//			if (ListTools.isNotEmpty(apps)) {
+//				apps.stream().forEach(o -> {
+//					String url = o.getUrlRoot() + "cache";
+//					logger.debug("dispatch cache request to : {}", url);
+//					try {
+//						CipherConnectionAction.put(effectivePerson.getDebugger(), url, wi);
+//					} catch (Exception e) {
+//						e.printStackTrace();
+//					}
+//				});
+//			}
+//		});
 		Wo wo = new Wo();
 		wo.setValue(true);
 		result.setData(wo);

+ 67 - 44
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/cachedispatch/BaseAction.java

@@ -1,55 +1,78 @@
 package com.x.program.center.jaxrs.cachedispatch;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang3.reflect.FieldUtils;
-
-import com.x.base.core.project.AssembleA;
-import com.x.base.core.project.Packages;
-import com.x.base.core.project.ServiceA;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-
-import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
-import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
 
 abstract class BaseAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
+
 	private static ConcurrentHashMap<String, List<Class<?>>> entityInApplicationMap = null;
 
-	static List<Class<?>> findApplicationWithEntity(String name) {
-		if (null == entityInApplicationMap) {
-			synchronized (BaseAction.class) {
-				if (null == entityInApplicationMap) {
-					entityInApplicationMap = new ConcurrentHashMap<String, List<Class<?>>>();
-					List<String> classes = new ArrayList<>();
-					ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
-					classes.addAll(scanResult.getNamesOfSubclassesOf(AssembleA.class));
-					classes.addAll(scanResult.getNamesOfSubclassesOf(ServiceA.class));
-					classes.stream().forEach(s -> {
-						Class<?> clz;
-						try {
-							clz = Class.forName(s);
-							((List<String>) FieldUtils.readStaticField(clz, "containerEntities")).stream()
-									.forEach(o -> {
-										List<Class<?>> list = entityInApplicationMap.get(o);
-										if (null == list) {
-											list = new ArrayList<Class<?>>();
-											entityInApplicationMap.put(o, list);
-										}
-										list.add(clz);
-									});
-						} catch (Exception e) {
-							e.printStackTrace();
-						}
-					});
-				}
-			}
-		}
-		List<Class<?>> list = entityInApplicationMap.get(name);
-		if (null == list) {
-			list = new ArrayList<Class<?>>();
-		}
-		return list;
-	}
+
+	
+
+//	static List<Class<?>> findApplicationWithEntity(String name) {
+//		
+//		
+//		
+//		if (null == entityInApplicationMap) {
+//			synchronized (BaseAction.class) {
+//				if (null == entityInApplicationMap) {
+//					entityInApplicationMap = new ConcurrentHashMap<String, List<Class<?>>>();
+//					try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+//						List<ClassInfo> list = new ArrayList<>();
+//						list.addAll(scanResult.getSubclasses(AssembleA.class.getName()));
+//						list.addAll(scanResult.getSubclasses(ServiceA.class.getName()));
+//						for (ClassInfo info : list) {
+//							Class<?> clz = Class.forName(info.getName());
+//							Deployable deployable = (Deployable) clz.newInstance();
+//							deployable.dependency().containerEntities.forEach(o -> {
+//								List<Class<?>> os = entityInApplicationMap.get(o);
+//								if (null == os) {
+//									os = new ArrayList<Class<?>>();
+//									entityInApplicationMap.put(o, os);
+//								}
+//								os.add(clz);
+//							});
+//						}
+//					} catch (Exception e) {
+//						logger.error(e);
+//					}
+////					ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
+////					classes.addAll(scanResult.getNamesOfSubclassesOf(AssembleA.class));
+////					classes.addAll(scanResult.getNamesOfSubclassesOf(ServiceA.class));
+////					classes.stream().forEach(s -> {
+////						Class<?> clz;
+////						try {
+////							clz = Class.forName(s);
+////							Deployable deployable = (Deployable) clz.newInstance();
+////							deployable.dependency().containerEntities.forEach(o -> {
+////								List<Class<?>> list = entityInApplicationMap.get(o);
+////								if (null == list) {
+////									list = new ArrayList<Class<?>>();
+////									entityInApplicationMap.put(o, list);
+////								}
+////								list.add(clz);
+////							});
+////						} catch (Exception e) {
+////							e.printStackTrace();
+////						}
+////					});
+//				}
+//			}
+//		}
+//		List<Class<?>> list = entityInApplicationMap.get(name);
+//		if (null == list) {
+//			return new ArrayList<Class<?>>();
+//		} else {
+//			List<Class<?>> os = new ArrayList<>();
+//			os.addAll(list);
+//			return os;
+//		}
+//	}
 }

+ 28 - 19
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/distribute/BaseAction.java

@@ -2,13 +2,13 @@ package com.x.program.center.jaxrs.distribute;
 
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -17,17 +17,16 @@ import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.project.Application;
 import com.x.base.core.project.AssembleA;
-import com.x.base.core.project.Packages;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.Node;
 import com.x.base.core.project.config.WebServer;
-import com.x.base.core.project.config.WebServers;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.program.center.ThisApplication;
 
-import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
-import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ScanResult;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
@@ -151,7 +150,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 			WoAssemble wrap = new WoAssemble();
 			Application application = ThisApplication.context().applications().randomWithWeight(o);
 			if (null != application) {
-				wrap.setContext(application.getContext());
+				wrap.setContext(application.getContextPath());
 				wrap.setHost(StringUtils.isNotEmpty(source) ? source : this.getHost(request));
 				wrap.setPort(application.getPort());
 				wrap.setName(application.getName());
@@ -167,7 +166,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 			WoAssemble wrap = new WoAssemble();
 			Application application = ThisApplication.context().applications().randomWithWeight(o);
 			if (null != application) {
-				wrap.setContext(application.getContext());
+				wrap.setContext(application.getContextPath());
 				wrap.setHost(application.getProxyHost());
 				wrap.setPort(application.getProxyPort());
 				wrap.setName(application.getName());
@@ -183,7 +182,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 			WoAssemble wrap = new WoAssemble();
 			Application application = ThisApplication.context().applications().randomWithWeight(o);
 			if (null != application) {
-				wrap.setContext(application.getContext());
+				wrap.setContext(application.getContextPath());
 				wrap.setHost(application.getNode());
 				wrap.setPort(application.getPort());
 				wrap.setName(application.getName());
@@ -198,19 +197,29 @@ abstract class BaseAction extends StandardJaxrsAction {
 		if (null == assembles) {
 			synchronized (BaseAction.class) {
 				if (null == assembles) {
-					ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
-					List<String> assembleList = scanResult.getNamesOfSubclassesOf(AssembleA.class);
-					List<String> list = new ArrayList<>();
-					list.addAll(assembleList);
-					Collections.sort(list, new Comparator<String>() {
-						public int compare(String s1, String s2) {
-							return s1.compareTo(s2);
+					try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+						assembles = new CopyOnWriteArrayList<Class<? extends AssembleA>>();
+						List<ClassInfo> list = new ArrayList<>();
+						list.addAll(scanResult.getSubclasses(AssembleA.class.getName()));
+						list = list.stream().sorted(Comparator.comparing(ClassInfo::getName))
+								.collect(Collectors.toList());
+						for (ClassInfo info : list) {
+							assembles.add((Class<AssembleA>) Class.forName(info.getName()));
 						}
-					});
-					assembles = new CopyOnWriteArrayList<Class<? extends AssembleA>>();
-					for (String str : list) {
-						assembles.add((Class<AssembleA>) Class.forName(str));
 					}
+//					ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
+//					List<String> assembleList = scanResult.getNamesOfSubclassesOf(AssembleA.class);
+//					List<String> list = new ArrayList<>();
+//					list.addAll(assembleList);
+//					Collections.sort(list, new Comparator<String>() {
+//						public int compare(String s1, String s2) {
+//							return s1.compareTo(s2);
+//						}
+//					});
+//					assembles = new CopyOnWriteArrayList<Class<? extends AssembleA>>();
+//					for (String str : list) {
+//						assembles.add((Class<AssembleA>) Class.forName(str));
+//					}
 				}
 			}
 		}

+ 4 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/ActionList.java

@@ -28,15 +28,15 @@ class ActionList extends BaseAction {
 			for (Application o : en.getValue()) {
 				if (fromProxy) {
 					if (this.isUndefindHost(o.getProxyHost())) {
-						wo.getUrlList().add("http://" + this.getHost(request) + ":" + o.getProxyPort() + o.getContext()
-								+ "/jest/index.html");
+						wo.getUrlList().add("http://" + this.getHost(request) + ":" + o.getProxyPort()
+								+ o.getContextPath() + "/jest/index.html");
 					} else {
-						wo.getUrlList().add("http://" + o.getProxyHost() + ":" + o.getProxyPort() + o.getContext()
+						wo.getUrlList().add("http://" + o.getProxyHost() + ":" + o.getProxyPort() + o.getContextPath()
 								+ "/jest/index.html");
 					}
 				} else {
 					wo.getUrlList()
-							.add("http://" + o.getNode() + ":" + o.getPort() + o.getContext() + "/jest/index.html");
+							.add("http://" + o.getNode() + ":" + o.getPort() + o.getContextPath() + "/jest/index.html");
 				}
 			}
 			wos.add(wo);

+ 14 - 17
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/BaseAction.java

@@ -2,13 +2,13 @@ package com.x.program.center.jaxrs.jest;
 
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -17,7 +17,6 @@ import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.project.Application;
 import com.x.base.core.project.AssembleA;
-import com.x.base.core.project.Packages;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.Node;
 import com.x.base.core.project.config.WebServer;
@@ -26,8 +25,9 @@ import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.program.center.ThisApplication;
 
-import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
-import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ScanResult;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
@@ -129,7 +129,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 			WoAssemble wrap = new WoAssemble();
 			Application application = ThisApplication.context().applications().randomWithWeight(o);
 			if (null != application) {
-				wrap.setContext(application.getContext());
+				wrap.setContext(application.getContextPath());
 				if (this.isUndefindHost(application.getNode())) {
 					wrap.setHost(this.getHost(request));
 				} else {
@@ -149,7 +149,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 			WoAssemble wrap = new WoAssemble();
 			Application application = ThisApplication.context().applications().randomWithWeight(o);
 			if (null != application) {
-				wrap.setContext(application.getContext());
+				wrap.setContext(application.getContextPath());
 				if (this.isUndefindHost(application.getProxyHost())) {
 					wrap.setHost(this.getHost(request));
 				} else {
@@ -168,18 +168,15 @@ abstract class BaseAction extends StandardJaxrsAction {
 		if (null == assembles) {
 			synchronized (BaseAction.class) {
 				if (null == assembles) {
-					ScanResult scanResult = new FastClasspathScanner(Packages.PREFIX).scan();
-					List<String> assembleList = scanResult.getNamesOfSubclassesOf(AssembleA.class);
-					List<String> list = new ArrayList<>();
-					list.addAll(assembleList);
-					Collections.sort(list, new Comparator<String>() {
-						public int compare(String s1, String s2) {
-							return s1.compareTo(s2);
+					try (ScanResult scanResult = new ClassGraph().enableAllInfo().scan()) {
+						assembles = new CopyOnWriteArrayList<Class<? extends AssembleA>>();
+						List<ClassInfo> list = new ArrayList<>();
+						list.addAll(scanResult.getSubclasses(AssembleA.class.getName()));
+						list = list.stream().sorted(Comparator.comparing(ClassInfo::getName))
+								.collect(Collectors.toList());
+						for (ClassInfo info : list) {
+							assembles.add((Class<AssembleA>) Class.forName(info.getName()));
 						}
-					});
-					assembles = new CopyOnWriteArrayList<Class<? extends AssembleA>>();
-					for (String str : list) {
-						assembles.add((Class<AssembleA>) Class.forName(str));
 					}
 				}
 			}

+ 1 - 1
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/schedule/ActionFire.java

@@ -73,7 +73,7 @@ class ActionFire extends BaseAction {
 			String url = app.getUrlRoot()
 					+ Applications.joinQueryUri("fireschedule", "classname", schedule.getClassName());
 			CipherConnectionAction.get(effectivePerson.getDebugger(), url);
-			logger.info("fire schedule node: {}, application: {}, task: {}.", app.getNode(), app.getContext(),
+			logger.info("fire schedule node: {}, application: {}, task: {}.", app.getNode(), app.getContextPath(),
 					schedule.getClassName());
 		} else {
 			logger.info("can not fire schedule application: {}, task: {}.", schedule.getApplication(),

+ 1 - 1
o2server/x_program_center/src/main/java/com/x/program/center/schedule/FireSchedule.java

@@ -81,7 +81,7 @@ public class FireSchedule implements Job {
 								+ Applications.joinQueryUri("fireschedule", "classname", latest.getClassName());
 						CipherConnectionAction.get(false, url);
 						logger.info("fire schedule node: {}, application: {}, task: {}.", app.getNode(),
-								app.getContext(), latest.getClassName());
+								app.getContextPath(), latest.getClassName());
 					} else {
 						logger.info("can not fire schedule application: {}, task: {}.", latest.getApplication(),
 								latest.getClassName());

+ 1 - 1
o2server/x_program_center_core_entity/src/main/java/com/x/program/center/core/entity/validation/Meta.java

@@ -114,7 +114,7 @@ public class Meta extends SliceJpaObject {
 	private Date dateValue;
 
 	public static final String timeValue_FIELDNAME = "timeValue";
-	@Temporal(TemporalType.DATE)
+	@Temporal(TemporalType.TIME)
 	@FieldDescribe("时间值.")
 	@CheckPersist(allowEmpty = true)
 	@Column(name = ColumnNamePrefix + timeValue_FIELDNAME)

+ 302 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/DynamicEntity.java

@@ -0,0 +1,302 @@
+package com.x.query.assemble.designer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.x.base.core.project.gson.GsonPropertyObject;
+
+public class DynamicEntity extends GsonPropertyObject {
+
+	public static final String TABLE_PREFIX = "QRY_DYN_";
+	public static final String CLASS_PACKAGE = "com.x.query.dynamic.entity";
+	public static final String FIELDNAME_SUFFIX = "_FIELDNAME";
+
+	private String name;
+
+	private List<StringField> stringFields;
+	private List<IntegerField> integerFields;
+	private List<LongField> longFields;
+	private List<DoubleField> doubleFields;
+	private List<BooleanField> booleanFields;
+	private List<DateField> dateFields;
+	private List<TimeField> timeFields;
+	private List<DateTimeField> dateTimeFields;
+
+	private List<StringField> listStringFields;
+	private List<IntegerField> listIntegerFields;
+	private List<LongField> listLongFields;
+	private List<DoubleField> listDoubleFields;
+	private List<BooleanField> listBooleanFields;
+	private List<DateField> listDateFields;
+	private List<TimeField> listTimeFields;
+	private List<DateTimeField> listDateTimeFields;
+
+	private List<StringLobField> stringLobFields;
+	private List<StringMapField> stringMapFields;
+
+	public void addStringField(String name, String description) {
+		StringField field = new StringField();
+		field.setName(name);
+		field.setDescription(description);
+		this.stringFields.add(field);
+	}
+
+	public String tableName() throws Exception {
+		if (StringUtils.isEmpty(name)) {
+			throw new Exception("name is empty.");
+		}
+		return TABLE_PREFIX + StringUtils.upperCase(name);
+	}
+
+	public String classSimpleName() throws Exception {
+		if (StringUtils.isEmpty(name)) {
+			throw new Exception("name is empty.");
+		}
+		return StringUtils.capitalize(name);
+	}
+
+	public String className() throws Exception {
+		if (StringUtils.isEmpty(name)) {
+			throw new Exception("name is empty.");
+		}
+		return CLASS_PACKAGE + StringUtils.lowerCase(name);
+	}
+
+	public DynamicEntity() {
+		this.stringFields = new ArrayList<>();
+		this.integerFields = new ArrayList<>();
+		this.longFields = new ArrayList<>();
+		this.doubleFields = new ArrayList<>();
+		this.booleanFields = new ArrayList<>();
+		this.dateFields = new ArrayList<>();
+		this.timeFields = new ArrayList<>();
+		this.dateTimeFields = new ArrayList<>();
+
+		this.listStringFields = new ArrayList<>();
+		this.listIntegerFields = new ArrayList<>();
+		this.listLongFields = new ArrayList<>();
+		this.listDoubleFields = new ArrayList<>();
+		this.listBooleanFields = new ArrayList<>();
+		this.listDateFields = new ArrayList<>();
+		this.listTimeFields = new ArrayList<>();
+		this.listDateTimeFields = new ArrayList<>();
+
+		this.stringLobFields = new ArrayList<>();
+		this.stringMapFields = new ArrayList<>();
+	}
+
+	public DynamicEntity(String name) {
+		this();
+		this.name = name;
+	}
+
+	public static abstract class Field {
+		private String name;
+		private String description;
+
+		public String fieldName() {
+			return this.name + FIELDNAME_SUFFIX;
+		}
+
+		public String getName() {
+			return name;
+		}
+
+		public void setName(String name) {
+			this.name = name;
+		}
+
+		public String getDescription() {
+			return description;
+		}
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+	}
+
+	public static class StringField extends Field {
+	}
+
+	public static class IntegerField extends Field {
+	}
+
+	public static class LongField extends Field {
+	}
+
+	public static class DoubleField extends Field {
+	}
+
+	public static class BooleanField extends Field {
+	}
+
+	public static class DateField extends Field {
+	}
+
+	public static class TimeField extends Field {
+	}
+
+	public static class DateTimeField extends Field {
+	}
+
+	public static class StringLobField extends Field {
+	}
+
+	public static class StringMapField extends Field {
+	}
+
+	public List<StringField> getStringFields() {
+		return stringFields;
+	}
+
+	public void setStringFields(List<StringField> stringFields) {
+		this.stringFields = stringFields;
+	}
+
+	public List<IntegerField> getIntegerFields() {
+		return integerFields;
+	}
+
+	public void setIntegerFields(List<IntegerField> integerFields) {
+		this.integerFields = integerFields;
+	}
+
+	public List<LongField> getLongFields() {
+		return longFields;
+	}
+
+	public void setLongFields(List<LongField> longFields) {
+		this.longFields = longFields;
+	}
+
+	public List<DoubleField> getDoubleFields() {
+		return doubleFields;
+	}
+
+	public void setDoubleFields(List<DoubleField> doubleFields) {
+		this.doubleFields = doubleFields;
+	}
+
+	public List<BooleanField> getBooleanFields() {
+		return booleanFields;
+	}
+
+	public void setBooleanFields(List<BooleanField> booleanFields) {
+		this.booleanFields = booleanFields;
+	}
+
+	public List<DateField> getDateFields() {
+		return dateFields;
+	}
+
+	public void setDateFields(List<DateField> dateFields) {
+		this.dateFields = dateFields;
+	}
+
+	public List<TimeField> getTimeFields() {
+		return timeFields;
+	}
+
+	public void setTimeFields(List<TimeField> timeFields) {
+		this.timeFields = timeFields;
+	}
+
+	public List<DateTimeField> getDateTimeFields() {
+		return dateTimeFields;
+	}
+
+	public void setDateTimeFields(List<DateTimeField> dateTimeFields) {
+		this.dateTimeFields = dateTimeFields;
+	}
+
+	public List<StringField> getListStringFields() {
+		return listStringFields;
+	}
+
+	public void setListStringFields(List<StringField> listStringFields) {
+		this.listStringFields = listStringFields;
+	}
+
+	public List<IntegerField> getListIntegerFields() {
+		return listIntegerFields;
+	}
+
+	public void setListIntegerFields(List<IntegerField> listIntegerFields) {
+		this.listIntegerFields = listIntegerFields;
+	}
+
+	public List<LongField> getListLongFields() {
+		return listLongFields;
+	}
+
+	public void setListLongFields(List<LongField> listLongFields) {
+		this.listLongFields = listLongFields;
+	}
+
+	public List<DoubleField> getListDoubleFields() {
+		return listDoubleFields;
+	}
+
+	public void setListDoubleFields(List<DoubleField> listDoubleFields) {
+		this.listDoubleFields = listDoubleFields;
+	}
+
+	public List<BooleanField> getListBooleanFields() {
+		return listBooleanFields;
+	}
+
+	public void setListBooleanFields(List<BooleanField> listBooleanFields) {
+		this.listBooleanFields = listBooleanFields;
+	}
+
+	public List<DateField> getListDateFields() {
+		return listDateFields;
+	}
+
+	public void setListDateFields(List<DateField> listDateFields) {
+		this.listDateFields = listDateFields;
+	}
+
+	public List<TimeField> getListTimeFields() {
+		return listTimeFields;
+	}
+
+	public void setListTimeFields(List<TimeField> listTimeFields) {
+		this.listTimeFields = listTimeFields;
+	}
+
+	public List<DateTimeField> getListDateTimeFields() {
+		return listDateTimeFields;
+	}
+
+	public void setListDateTimeFields(List<DateTimeField> listDateTimeFields) {
+		this.listDateTimeFields = listDateTimeFields;
+	}
+
+	public List<StringLobField> getStringLobFields() {
+		return stringLobFields;
+	}
+
+	public void setStringLobFields(List<StringLobField> stringLobFields) {
+		this.stringLobFields = stringLobFields;
+	}
+
+	public List<StringMapField> getStringMapFields() {
+		return stringMapFields;
+	}
+
+	public void setStringMapFields(List<StringMapField> stringMapFields) {
+		this.stringMapFields = stringMapFields;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+}

+ 367 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/DynamicEntityBuilder.java

@@ -0,0 +1,367 @@
+package com.x.query.assemble.designer;
+
+import java.io.File;
+import java.util.Date;
+
+import javax.lang.model.element.Modifier;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.openjpa.persistence.jdbc.Index;
+
+import com.squareup.javapoet.AnnotationSpec;
+import com.squareup.javapoet.FieldSpec;
+import com.squareup.javapoet.JavaFile;
+import com.squareup.javapoet.MethodSpec;
+import com.squareup.javapoet.TypeSpec;
+import com.squareup.javapoet.TypeSpec.Builder;
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.entity.SliceJpaObject;
+import com.x.base.core.entity.annotation.CheckPersist;
+import com.x.base.core.entity.annotation.ContainerEntity;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.tools.ListTools;
+import com.x.query.assemble.designer.DynamicEntity.BooleanField;
+import com.x.query.assemble.designer.DynamicEntity.DateField;
+import com.x.query.assemble.designer.DynamicEntity.DateTimeField;
+import com.x.query.assemble.designer.DynamicEntity.DoubleField;
+import com.x.query.assemble.designer.DynamicEntity.Field;
+import com.x.query.assemble.designer.DynamicEntity.IntegerField;
+import com.x.query.assemble.designer.DynamicEntity.LongField;
+import com.x.query.assemble.designer.DynamicEntity.StringField;
+import com.x.query.assemble.designer.DynamicEntity.TimeField;
+
+public class DynamicEntityBuilder {
+
+	public static final String FIELDNAME_SUFFIX = "_FIELDNAME";
+
+	private DynamicEntity dynamicEntity;
+	private File dir;
+
+	public DynamicEntityBuilder(DynamicEntity dynamicEntity, File dir) {
+
+		this.dynamicEntity = dynamicEntity;
+		this.dir = dir;
+
+	}
+
+	public JavaFile build() throws Exception {
+
+		AnnotationSpec annotationSpec_entity = AnnotationSpec.builder(Entity.class).build();
+		AnnotationSpec annotationSpec_containerEntity = AnnotationSpec.builder(ContainerEntity.class).build();
+		AnnotationSpec annotationSpec_table = AnnotationSpec.builder(Table.class)
+				.addMember("name", "\"" + dynamicEntity.tableName() + "\"")
+				.addMember("uniqueConstraints", "{@javax.persistence.UniqueConstraint(name = \""
+						+ dynamicEntity.tableName()
+						+ "\" + com.x.base.core.entity.JpaObject.IndexNameMiddle  + com.x.base.core.entity.JpaObject.DefaultUniqueConstraintSuffix, columnNames = { com.x.base.core.entity.JpaObject.IDCOLUMN, com.x.base.core.entity.JpaObject.CREATETIMECOLUMN, com.x.base.core.entity.JpaObject.UPDATETIMECOLUMN, com.x.base.core.entity.JpaObject.SEQUENCECOLUMN }) }")
+				.build();
+		AnnotationSpec annotationSpec_inheritance = AnnotationSpec.builder(Inheritance.class)
+				.addMember("strategy", "javax.persistence.InheritanceType.TABLE_PER_CLASS").build();
+
+		// private static final long serialVersionUID = 6387104721461689291L;
+		FieldSpec fieldSpec_serialVersionUID = FieldSpec
+				.builder(long.class, "serialVersionUID", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
+				.initializer("1L").build();
+		// private static final String TABLE =
+		// PersistenceProperties.Validation.Meta.table;
+		FieldSpec fieldSpec_TABLE = FieldSpec
+				.builder(String.class, "TABLE", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
+				.initializer("\"" + dynamicEntity.tableName() + "\"").build();
+
+		Builder builder = TypeSpec.classBuilder(dynamicEntity.classSimpleName()).superclass(SliceJpaObject.class)
+				.addModifiers(Modifier.PUBLIC).addAnnotation(annotationSpec_entity)
+				.addAnnotation(annotationSpec_containerEntity).addAnnotation(annotationSpec_inheritance)
+				.addAnnotation(annotationSpec_table).addField(fieldSpec_serialVersionUID).addField(fieldSpec_TABLE);
+
+		this.createIdField(builder);
+		this.createOnPersistMethod(builder);
+		this.createStringFields(builder);
+		this.createIntegerFields(builder);
+		this.createLongFields(builder);
+		this.createDoubleFields(builder);
+		this.createBooleanFields(builder);
+		this.createDateFields(builder);
+		this.createTimeFields(builder);
+		this.createDateTimeFields(builder);
+
+		TypeSpec typeSpec = builder.build();
+
+		JavaFile javaFile = JavaFile.builder(DynamicEntity.CLASS_PACKAGE, typeSpec).build();
+
+		javaFile.writeTo(dir);
+		return javaFile;
+	}
+
+	private void createOnPersistMethod(Builder builder) {
+		MethodSpec method = MethodSpec.methodBuilder("onPersist").addModifiers(Modifier.PUBLIC).returns(void.class)
+				.addException(Exception.class).build();
+		builder.addMethod(method);
+	}
+
+	private void createIdField(Builder builder) {
+//		public String getId() {
+//			return id;
+//		}
+//		public void setId(String id) {
+//			this.id = id;
+//		}
+//		@FieldDescribe("数据库主键,自动生成.")
+//		@Id
+//		@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
+//		private String id = createId();
+		AnnotationSpec fieldDescribe = AnnotationSpec.builder(FieldDescribe.class).addMember("value", "\"数据库主键,自动生成.\"")
+				.build();
+		AnnotationSpec id = AnnotationSpec.builder(Id.class).build();
+		AnnotationSpec column = AnnotationSpec.builder(Column.class).addMember("length", "length_id")
+				.addMember("name", "ColumnNamePrefix + id_FIELDNAME").build();
+		MethodSpec get = MethodSpec.methodBuilder("getId").addModifiers(Modifier.PUBLIC).returns(String.class)
+				.addStatement("return this.id").build();
+		MethodSpec set = MethodSpec.methodBuilder("setId").addModifiers(Modifier.PUBLIC).returns(void.class)
+				.addParameter(String.class, "id").addStatement("this.id = id").build();
+		FieldSpec fieldSpec = FieldSpec.builder(String.class, JpaObject.id_FIELDNAME, Modifier.PRIVATE)
+				.initializer("createId()").addAnnotation(fieldDescribe).addAnnotation(id).addAnnotation(column).build();
+		builder.addField(fieldSpec).addMethod(set).addMethod(get);
+	}
+
+	private void createStringFields(Builder builder) {
+		for (StringField field : ListTools.trim(dynamicEntity.getStringFields(), true, true)) {
+			this.createStringField(builder, field);
+		}
+	}
+
+	private void createStringField(Builder builder, StringField field) {
+//		public static final String stringValue_FIELDNAME = "stringValue";
+//		@FieldDescribe("文本字段.")
+//		@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + stringValue_FIELDNAME)
+//		@Index(name = TABLE + IndexNameMiddle + stringValue_FIELDNAME)
+//		@CheckPersist(allowEmpty = true)
+//		private String stringValue;
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class).addMember("length", "length_255B")
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(String.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(String.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(String.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createIntegerFields(Builder builder) {
+		for (IntegerField field : ListTools.trim(dynamicEntity.getIntegerFields(), true, true)) {
+			this.createIntegerField(builder, field);
+		}
+	}
+
+	private void createIntegerField(Builder builder, IntegerField field) {
+//		public static final String integerValue_FIELDNAME = "integerValue";
+//		@FieldDescribe("整型.")
+//		@CheckPersist(allowEmpty = true)
+//		@Index(name = TABLE + IndexNameMiddle + integerValue_FIELDNAME)
+//		@Column(name = ColumnNamePrefix + integerValue_FIELDNAME)
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Integer.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Integer.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Integer.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createLongFields(Builder builder) {
+		for (LongField field : ListTools.trim(dynamicEntity.getLongFields(), true, true)) {
+			this.createLongField(builder, field);
+		}
+	}
+
+	private void createLongField(Builder builder, LongField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Long.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Long.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Long.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createDoubleFields(Builder builder) {
+		for (DoubleField field : ListTools.trim(dynamicEntity.getDoubleFields(), true, true)) {
+			this.createDoubleField(builder, field);
+		}
+	}
+
+	private void createDoubleField(Builder builder, DoubleField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Double.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Double.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Double.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createBooleanFields(Builder builder) {
+		for (BooleanField field : ListTools.trim(dynamicEntity.getBooleanFields(), true, true)) {
+			this.createBooleanField(builder, field);
+		}
+	}
+
+	private void createBooleanField(Builder builder, BooleanField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Boolean.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Boolean.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Boolean.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createDateFields(Builder builder) {
+		for (DateField field : ListTools.trim(dynamicEntity.getDateFields(), true, true)) {
+			this.createDateField(builder, field);
+		}
+	}
+
+	private void createDateField(Builder builder, DateField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
+				.addMember("value", "javax.persistence.Temporal.DATE").build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Date.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Date.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createTimeFields(Builder builder) {
+		for (TimeField field : ListTools.trim(dynamicEntity.getTimeFields(), true, true)) {
+			this.createTimeField(builder, field);
+		}
+	}
+
+	private void createTimeField(Builder builder, TimeField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
+				.addMember("value", "javax.persistence.Temporal.TIME").build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Date.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Date.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private void createDateTimeFields(Builder builder) {
+		for (DateTimeField field : ListTools.trim(dynamicEntity.getDateTimeFields(), true, true)) {
+			this.createDateTimeField(builder, field);
+		}
+	}
+
+	private void createDateTimeField(Builder builder, DateTimeField field) {
+
+		AnnotationSpec column = AnnotationSpec.builder(Column.class)
+				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
+
+		AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
+				.addMember("value", "javax.persistence.Temporal.TIMESTAMP").build();
+
+		FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
+				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
+				.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
+		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(Date.class).addStatement("return this." + field.getName())
+				.build();
+		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
+				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Date.class, field.getName())
+				.addStatement("this." + field.getName() + " = " + field.getName()).build();
+		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
+
+	}
+
+	private FieldSpec fieldName(Field field) {
+		FieldSpec spec = FieldSpec
+				.builder(String.class, field.fieldName(), Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
+				.initializer("\"" + field.getName() + "\"").build();
+		return spec;
+	}
+
+	private AnnotationSpec fieldDescribe(Field field) {
+		AnnotationSpec spec = AnnotationSpec.builder(FieldDescribe.class)
+				.addMember("value", "\"" + field.getDescription() + "\"").build();
+		return spec;
+	}
+
+	private AnnotationSpec checkPersist(Field field) {
+		AnnotationSpec spec = AnnotationSpec.builder(CheckPersist.class).addMember("allowEmpty", "true").build();
+		return spec;
+	}
+
+	private AnnotationSpec index(Field field) {
+		AnnotationSpec spec = AnnotationSpec.builder(Index.class)
+				.addMember("name", "TABLE + IndexNameMiddle + " + field.fieldName()).build();
+		return spec;
+	}
+
+}

+ 2 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/ActionApplication.java

@@ -12,6 +12,7 @@ import com.x.query.assemble.designer.jaxrs.output.OutputAction;
 import com.x.query.assemble.designer.jaxrs.query.QueryAction;
 import com.x.query.assemble.designer.jaxrs.reveal.RevealAction;
 import com.x.query.assemble.designer.jaxrs.stat.StatAction;
+import com.x.query.assemble.designer.jaxrs.table.TableAction;
 import com.x.query.assemble.designer.jaxrs.view.ViewAction;
 
 @ApplicationPath("jaxrs")
@@ -26,6 +27,7 @@ public class ActionApplication extends AbstractActionApplication {
 		classes.add(NeuralAction.class);
 		classes.add(OutputAction.class);
 		classes.add(InputAction.class);
+		classes.add(TableAction.class);
 		return classes;
 	}
 

+ 10 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/TableJaxrsFilter.java

@@ -0,0 +1,10 @@
+package com.x.query.assemble.designer.jaxrs;
+
+import javax.servlet.annotation.WebFilter;
+
+import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
+
+@WebFilter(urlPatterns = "/jaxrs/table/*", asyncSupported = true)
+public class TableJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
+
+}

+ 6 - 6
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionCreateModel.java

@@ -42,12 +42,12 @@ class ActionCreateModel extends BaseAction {
 		private static final long serialVersionUID = -5237741099036357033L;
 
 		static WrapCopier<Wi, Model> copier = WrapCopierFactory.wi(Wi.class, Model.class,
-				ListTools.toList(Model.id_FIELDNAME, Model.neuralNetworkType_FIELDNAME, Model.dataType_FIELDNAME,
-						Model.name_FIELDNAME, Model.description_FIELDNAME, Model.alias_FIELDNAME,
-						Model.inValueScriptText_FIELDNAME, Model.outValueScriptText_FIELDNAME,
-						Model.attachmentScriptText_FIELDNAME, Model.processList_FIELDNAME,
-						Model.applicationList_FIELDNAME, Model.inValueCount_FIELDNAME, Model.outValueCount_FIELDNAME,
-						Model.maxResult_FIELDNAME, Model.propertyMap_FIELDNAME, Model.analyzeType_FIELDNAME),
+				ListTools.toList(Model.neuralNetworkType_FIELDNAME, Model.dataType_FIELDNAME, Model.name_FIELDNAME,
+						Model.description_FIELDNAME, Model.alias_FIELDNAME, Model.inValueScriptText_FIELDNAME,
+						Model.outValueScriptText_FIELDNAME, Model.attachmentScriptText_FIELDNAME,
+						Model.processList_FIELDNAME, Model.applicationList_FIELDNAME, Model.inValueCount_FIELDNAME,
+						Model.outValueCount_FIELDNAME, Model.maxResult_FIELDNAME, Model.propertyMap_FIELDNAME,
+						Model.analyzeType_FIELDNAME),
 				JpaObject.FieldsUnmodifyExcludeId);
 
 	}

+ 2 - 2
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionListModel.java

@@ -13,6 +13,7 @@ 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.organization.OrganizationDefinition;
+import com.x.base.core.project.tools.ListTools;
 import com.x.query.assemble.designer.Business;
 import com.x.query.core.entity.neural.Model;
 
@@ -39,8 +40,7 @@ class ActionListModel extends BaseAction {
 		private static final long serialVersionUID = -6541538280679110474L;
 
 		static WrapCopier<Model, Wo> copier = WrapCopierFactory.wo(Model.class, Wo.class, null,
-				JpaObject.FieldsInvisible);
-
+				ListTools.toList(JpaObject.FieldsInvisible, Model.nnet_FIELDNAME, Model.intermediateNnet_FIELDNAME));
 	}
 
 }

+ 94 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/ActionCompile.java

@@ -0,0 +1,94 @@
+package com.x.query.assemble.designer.jaxrs.table;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.openjpa.ant.PCEnhancerTask;
+import org.apache.openjpa.enhance.PCEnhancer;
+
+import com.sun.jna.Native.ffi_callback;
+import com.x.base.core.project.config.Config;
+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.tools.DefaultCharset;
+import com.x.base.core.project.tools.JarTools;
+import com.x.query.assemble.designer.DynamicEntity;
+import com.x.query.assemble.designer.DynamicEntityBuilder;
+
+class ActionCompile extends BaseAction {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		DynamicEntity dynamicEntity = new DynamicEntity("test1");
+
+		dynamicEntity.addStringField("abc", "测试");
+
+		File src = new File(Config.dir_local_temp(), "dynamic/src");
+		File target = new File(Config.dir_local_temp(), "dynamic/target");
+		FileUtils.forceMkdir(src);
+		FileUtils.cleanDirectory(src);
+		FileUtils.forceMkdir(target);
+		FileUtils.cleanDirectory(target);
+		DynamicEntityBuilder builder = new DynamicEntityBuilder(dynamicEntity, src);
+		builder.build();
+
+		List<File> classPath = new ArrayList<>();
+		classPath.addAll(FileUtils.listFiles(Config.dir_commons_ext(), FileFilterUtils.suffixFileFilter(".jar"),
+				DirectoryFileFilter.INSTANCE));
+		classPath.addAll(FileUtils.listFiles(Config.dir_store_jars(), FileFilterUtils.suffixFileFilter(".jar"),
+				DirectoryFileFilter.INSTANCE));
+
+		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+		StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, DefaultCharset.charset_utf_8);
+		fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(target));
+		fileManager.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(src));
+		fileManager.setLocation(StandardLocation.CLASS_PATH, classPath);
+		Iterable<JavaFileObject> res = fileManager.list(StandardLocation.SOURCE_PATH, DynamicEntity.CLASS_PACKAGE,
+				EnumSet.of(JavaFileObject.Kind.SOURCE), true);
+		compiler.getTask(null, fileManager, null, null, null, res).call();
+
+		URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+		Class<?> urlClass = URLClassLoader.class;
+		Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class });
+		method.setAccessible(true);
+
+		method.invoke(urlClassLoader, new Object[] { target.toURI().toURL() });
+
+		Collection<File> files = FileUtils.listFiles(target, FileFilterUtils.suffixFileFilter(".class"),
+				DirectoryFileFilter.INSTANCE);
+		for (File f : files) {
+			PCEnhancer.main(new String[] { f.getAbsolutePath() });
+		}
+		fileManager.close();
+
+		File jar = new File(Config.dir_dynamic_jars(true), "x_query_dynamic_entity.jar");
+		JarTools.jar(target, jar);
+
+		Wo wo = new Wo();
+		wo.setValue(true);
+		result.setData(wo);
+		return result;
+
+	}
+
+	public static class Wo extends WrapBoolean {
+
+	}
+
+}

+ 7 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/BaseAction.java

@@ -0,0 +1,7 @@
+package com.x.query.assemble.designer.jaxrs.table;
+
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+
+abstract class BaseAction extends StandardJaxrsAction {
+
+}

+ 46 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/TableAction.java

@@ -0,0 +1,46 @@
+package com.x.query.assemble.designer.jaxrs.table;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import com.x.base.core.project.annotation.JaxrsDescribe;
+import com.x.base.core.project.annotation.JaxrsMethodDescribe;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.http.HttpMediaType;
+import com.x.base.core.project.jaxrs.ResponseFactory;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+
+@Path("table")
+@JaxrsDescribe("表")
+public class TableAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(TableAction.class);
+
+	@JaxrsMethodDescribe(value = "根据query列示stat对象.", action = ActionCompile.class)
+	@GET
+	@Path("compile")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void compile(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
+		ActionResult<ActionCompile.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionCompile().execute(effectivePerson);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
+	}
+
+}

+ 8 - 0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/package-info.java

@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author zhour
+ *
+ */
+package com.x.query.assemble.designer.jaxrs.table;

+ 20 - 0
o2server/x_query_assemble_designer/src/test/java/com/x/query/assemble/designer/test/TestClient.java

@@ -0,0 +1,20 @@
+package com.x.query.assemble.designer.test;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.junit.Test;
+
+public class TestClient {
+	@Test
+	public void test() {
+		Collection<File> files = FileUtils.listFiles(new File("d:/aaa"), FileFilterUtils.suffixFileFilter(".java"),
+				DirectoryFileFilter.INSTANCE);
+		for (File f : files) {
+			System.out.println(f.getAbsolutePath());
+		}
+	}
+}

+ 8 - 0
o2server/x_query_assemble_designer/src/test/java/com/x/query/assemble/designer/test/package-info.java

@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author zhour
+ *
+ */
+package com.x.query.assemble.designer.test;

+ 4 - 4
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionListCalculate.java

@@ -20,14 +20,14 @@ class ActionListCalculate extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionListCalculate.class);
 
-	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String projectFlag, String workId)
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String modelFlag, String workId)
 			throws Exception {
-		logger.debug(effectivePerson, "projectFlag:{}, workId:{}.", projectFlag, workId);
+		logger.debug(effectivePerson, "modelFlag:{}, workId:{}.", modelFlag, workId);
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<List<Wo>> result = new ActionResult<>();
-			Model model = emc.flag(projectFlag, Model.class);
+			Model model = emc.flag(modelFlag, Model.class);
 			if (null == model) {
-				throw new ExceptionEntityNotExist(projectFlag, Model.class);
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			Work work = emc.flag(workId, Work.class);
 			if (null == work) {

+ 5 - 5
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/NeuralAction.java

@@ -29,18 +29,18 @@ public class NeuralAction extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(NeuralAction.class);
 
-	@JaxrsMethodDescribe(value = "获取指定的Application信息,并在Control段附带其操作权限.", action = ActionListCalculate.class)
+	@JaxrsMethodDescribe(value = "神经网络计算.", action = ActionListCalculate.class)
 	@GET
-	@Path("calculate/project/{projectFlag}/work/{workId}")
+	@Path("list/calculate/model/{modelFlag}/work/{workId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void calculate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag,
+	public void listCalculate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("项目标识") @PathParam("modelFlag") String modelFlag,
 			@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
 		ActionResult<List<ActionListCalculate.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionListCalculate().execute(effectivePerson, projectFlag, workId);
+			result = new ActionListCalculate().execute(effectivePerson, modelFlag, workId);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);

+ 2 - 2
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionCalculateWithWork.java → o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionListCalculateWithWork.java

@@ -42,9 +42,9 @@ import com.x.query.service.processing.helper.LanguageProcessingHelper;
 
 import net.sf.ehcache.Element;
 
-class ActionCalculateWithWork extends BaseAction {
+class ActionListCalculateWithWork extends BaseAction {
 
-	private static Logger logger = LoggerFactory.getLogger(ActionCalculateWithWork.class);
+	private static Logger logger = LoggerFactory.getLogger(ActionListCalculateWithWork.class);
 
 	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String modelFlag, String workId) throws Exception {
 		logger.debug(effectivePerson, "modelFlag:{}, workId:{}.", modelFlag, workId);

+ 4 - 4
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/NeuralAction.java

@@ -102,18 +102,18 @@ public class NeuralAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
 	}
 
-	@JaxrsMethodDescribe(value = "计算输入工作ID进行计算.", action = ActionCalculateWithWork.class)
+	@JaxrsMethodDescribe(value = "计算输入工作ID进行计算.", action = ActionListCalculateWithWork.class)
 	@GET
 	@Path("list/calculate/model/{modelFlag}/work/{workId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void calculateWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+	public void listCalculateWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag,
 			@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
-		ActionResult<List<ActionCalculateWithWork.Wo>> result = new ActionResult<>();
+		ActionResult<List<ActionListCalculateWithWork.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionCalculateWithWork().execute(effectivePerson, modelFlag, workId);
+			result = new ActionListCalculateWithWork().execute(effectivePerson, modelFlag, workId);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);

+ 10 - 4
o2server/x_query_service_processing/src/test/java/com/x/query/service/processing/test/TestClient.java

@@ -2,6 +2,7 @@ package com.x.query.service.processing.test;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.IOException;
 import java.util.zip.Deflater;
 
 import org.apache.commons.io.FileUtils;
@@ -15,6 +16,9 @@ import org.junit.Test;
 import org.neuroph.core.NeuralNetwork;
 import org.neuroph.nnet.learning.MomentumBackpropagation;
 
+import com.x.base.core.project.tools.ByteTools;
+import com.x.base.core.project.tools.DefaultCharset;
+
 public class TestClient {
 
 	@Test
@@ -65,9 +69,11 @@ public class TestClient {
 	}
 
 	@Test
-	public void test5() {
-		MomentumBackpropagation m = new MomentumBackpropagation();
-		System.out.println(m.getLearningRate());
-		System.out.println(m.getMomentum());
+	public void test5() throws Exception {
+		String str = FileUtils.readFileToString(new File("d:/code.txt"), DefaultCharset.charset);
+		byte[] bs = ByteTools.decompressBase64String(str);
+		System.out.println(bs.length);
+		String s = ByteTools.compressBase64String(bs);
+		System.out.println(s.length());
 	}
 }