diff --git a/o2server/.gitignore b/o2server/.gitignore index 0533942be358f75755a08784b57662dfde0f4eb0..3302ac7ebe8efc05a3afa703715d1c772a89906e 100644 --- a/o2server/.gitignore +++ b/o2server/.gitignore @@ -1,7 +1,9 @@ .project /.settings/ /local/ +/localSample/ /config/ +/configSample/ /logs/ /target/ /x_build_and_scratch/ @@ -11,4 +13,7 @@ command.swap /node_modules/ package-lock.json **/src/main/resources/META-INF/persistence.xml +**/src/main/resources/META-INF/x_persistence.xml **/*_.java +**/src/main/webapp/describe/ +console.jar diff --git a/o2server/package.xml b/o2server/build.xml similarity index 73% rename from o2server/package.xml rename to o2server/build.xml index 4c4070fa1b306945c6d19aca5b86707052dac264..d0d064c3c052ad00e4258fdad1e448fa2a47c93a 100644 --- a/o2server/package.xml +++ b/o2server/build.xml @@ -1,9 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/o2server/build_common.xml b/o2server/build_common.xml new file mode 100644 index 0000000000000000000000000000000000000000..1abccf1be6f9f9b8525563025c5e5ac4da3d9253 --- /dev/null +++ b/o2server/build_common.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/o2server/console.jar b/o2server/console.jar deleted file mode 100644 index 71cd92ef93dce7687ffd693ba4748c85ef4bad31..0000000000000000000000000000000000000000 Binary files a/o2server/console.jar and /dev/null differ diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java new file mode 100644 index 0000000000000000000000000000000000000000..6d2631acac15ed1af8dfdf214cbea37fbd566103 --- /dev/null +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java @@ -0,0 +1,145 @@ +package com.x.base.core.project.build; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.commons.lang3.reflect.MethodUtils; + +import com.google.gson.JsonElement; +import com.x.base.core.project.Packages; +import com.x.base.core.project.annotation.FieldDescribe; +import com.x.base.core.project.config.AppStyle; +import com.x.base.core.project.config.CenterServer; +import com.x.base.core.project.config.Collect; +import com.x.base.core.project.config.ConfigObject; +import com.x.base.core.project.config.Dingding; +import com.x.base.core.project.config.DumpRestoreData; +import com.x.base.core.project.config.DumpRestoreStorage; +import com.x.base.core.project.config.ExternalDataSource; +import com.x.base.core.project.config.LogLevel; +import com.x.base.core.project.config.Meeting; +import com.x.base.core.project.config.Messages; +import com.x.base.core.project.config.Node; +import com.x.base.core.project.config.Person; +import com.x.base.core.project.config.ProcessPlatform; +import com.x.base.core.project.config.Qiyeweixin; +import com.x.base.core.project.config.Query; +import com.x.base.core.project.config.Token; +import com.x.base.core.project.config.Vfs; +import com.x.base.core.project.config.WorkTime; +import com.x.base.core.project.config.ZhengwuDingding; +import com.x.base.core.project.gson.XGsonBuilder; +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.FileTools; + +import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; +import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult; + +public class CreateConfigSample { + + private static Logger logger = LoggerFactory.getLogger(CreateConfigSample.class); + + public static void main(String... args) throws Exception { + File base = new File(args[0]); + File dir = new File(base, "configSample"); + FastClasspathScanner scanner = new FastClasspathScanner(Packages.PREFIX); + ScanResult scanResult = scanner.scan(); + List> classes = new ArrayList>(); + classes.add(AppStyle.class); + classes.add(CenterServer.class); + classes.add(Collect.class); + classes.add(Dingding.class); + classes.add(DumpRestoreData.class); + classes.add(DumpRestoreStorage.class); + classes.add(LogLevel.class); + classes.add(Meeting.class); + classes.add(Messages.class); + classes.add(Node.class); + classes.add(Person.class); + classes.add(ProcessPlatform.class); + classes.add(Qiyeweixin.class); + classes.add(Query.class); + classes.add(Token.class); + classes.add(Vfs.class); + classes.add(WorkTime.class); + classes.add(ZhengwuDingding.class); + classes.add(ExternalDataSource.class); + + Collections.sort(classes, new Comparator>() { + public int compare(Class c1, Class c2) { + return c1.getCanonicalName().compareTo(c2.getCanonicalName()); + } + }); + for (Class cls : classes) { + Object o = MethodUtils.invokeStaticMethod(cls, "defaultInstance", null); + Map map = new LinkedHashMap(); + map = XGsonBuilder.convert(o, map.getClass()); + map = describe(cls, map); + String name = StringUtils.lowerCase(cls.getSimpleName().substring(0, 1)) + cls.getSimpleName().substring(1) + + ".json"; + File file = new File(dir, name); + logger.print("create file:{}.", file.getAbsoluteFile()); + FileUtils.write(file, XGsonBuilder.toJson(map), DefaultCharset.charset); + } + convertExternalDataSource2ExternalDataSources(dir); + renameNode(dir); + } + + private static void convertExternalDataSource2ExternalDataSources(File dir) throws Exception, IOException { + File file_externalDataSource = new File(dir, "externalDataSource.json"); + File file_externalDataSources = new File(dir, "externalDataSources.json"); + JsonElement jsonElement = XGsonBuilder.instance().fromJson( + FileUtils.readFileToString(file_externalDataSource, DefaultCharset.charset), JsonElement.class); + List list = new ArrayList<>(); + list.add(jsonElement); + FileUtils.writeStringToFile(file_externalDataSources, XGsonBuilder.toJson(list), DefaultCharset.charset); + file_externalDataSource.delete(); + } + + private static void renameNode(File dir) throws Exception, IOException { + File file_node = new File(dir, "node.json"); + File file_node_local = new File(dir, "node_127.0.0.1.json"); + if (file_node_local.exists()) { + file_node_local.delete(); + } + FileUtils.moveFile(file_node, file_node_local); + } + + private static Map describe(Class cls, Map map) + throws Exception { + for (Field field : FieldUtils.getFieldsListWithAnnotation(cls, FieldDescribe.class)) { + map.put("###" + field.getName(), field.getAnnotation(FieldDescribe.class).value() + "###"); + if (ConfigObject.class.isAssignableFrom(field.getType())) { + Object o = MethodUtils.invokeStaticMethod(field.getType(), "defaultInstance", null); + Map m = new LinkedHashMap(); + m = XGsonBuilder.convert(o, m.getClass()); + map.put(field.getName(), describe(field.getType(), m)); + } else if (List.class.isAssignableFrom(field.getType())) { + ParameterizedType parameterized = (ParameterizedType) field.getGenericType(); + Class actualClass = (Class) parameterized.getActualTypeArguments()[0]; + if (ConfigObject.class.isAssignableFrom(actualClass)) { + Object o = MethodUtils.invokeStaticMethod(actualClass, "defaultInstance", null); + Map m = new LinkedHashMap(); + m = XGsonBuilder.convert(o, m.getClass()); + List list = new ArrayList<>(); + list.add(describe(actualClass, m)); + map.put(field.getName(), list); + } + } + } + return map; + } +} diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateLocalSample.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateLocalSample.java new file mode 100644 index 0000000000000000000000000000000000000000..41614fc956aede6c4a50ed2b9d1a690f9409db3a --- /dev/null +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateLocalSample.java @@ -0,0 +1,21 @@ +package com.x.base.core.project.build; + +import java.io.File; + +import org.apache.commons.io.FileUtils; + +import com.x.base.core.project.logger.Logger; +import com.x.base.core.project.logger.LoggerFactory; +import com.x.base.core.project.tools.DefaultCharset; + +public class CreateLocalSample { + + private static Logger logger = LoggerFactory.getLogger(CreateLocalSample.class); + + public static void main(String... args) throws Exception { + File base = new File(args[0]); + File dir = new File(base, "localSample"); + File node_cfg = new File(dir, "node.cfg"); + FileUtils.write(node_cfg, "127.0.0.1", DefaultCharset.charset); + } +} diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateManifestCfg.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateManifestCfg.java new file mode 100644 index 0000000000000000000000000000000000000000..1c1a5af32b76ec9099c4416b15b32bdd79be933d --- /dev/null +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateManifestCfg.java @@ -0,0 +1,91 @@ +package com.x.base.core.project.build; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; + +import com.x.base.core.project.logger.Logger; +import com.x.base.core.project.logger.LoggerFactory; + +public class CreateManifestCfg { + + private static Logger logger = LoggerFactory.getLogger(CreateManifestCfg.class); + + public static void main(String[] args) throws Exception { + File base = new File(args[0]); + CreateManifestCfg creator = new CreateManifestCfg(); + creator.commonsExt(base); + creator.storeJars(base); + creator.store(base); + } + + public void store(File base) throws Exception { + File dir = new File(base, "store"); + if ((!dir.exists()) || (!dir.isDirectory())) { + throw new Exception("error"); + } + List names = new ArrayList<>(); + for (File o : dir.listFiles()) { + if ((!StringUtils.equals(o.getName(), "manifest.cfg")) && (!StringUtils.equals(o.getName(), "jars")) + && (!StringUtils.equals(o.getName(), ".gitignore"))) { + if (StringUtils.isNotEmpty(o.getName())) { + if ((!StringUtils.equals("x_report_assemble_control.war", o.getName())) + && (!StringUtils.equals("x_strategydeploy_assemble_control.war", o.getName()))) { + names.add(o.getName()); + } + } + } + } + names = names.stream().sorted().collect(Collectors.toList()); + File file = new File(dir, "manifest.cfg"); + logger.print("create manifest.cfg, path:{}.", file.getAbsolutePath()); + FileUtils.writeLines(file, names); + } + + public void storeJars(File base) throws Exception { + File dir = new File(base, "store/jars"); + if ((!dir.exists()) || (!dir.isDirectory())) { + throw new Exception("error"); + } + List names = new ArrayList<>(); + for (File o : dir.listFiles()) { + if ((!StringUtils.equals(o.getName(), "manifest.cfg")) + && (!StringUtils.equals(o.getName(), ".gitignore"))) { + if (StringUtils.isNotEmpty(o.getName())) { + if ((!StringUtils.equals("x_report_core_entity.jar", o.getName())) + && (!StringUtils.equals("x_strategydeploy_core_entity.jar", o.getName()))) { + names.add(o.getName()); + } + } + } + } + names = names.stream().sorted().collect(Collectors.toList()); + File file = new File(dir, "manifest.cfg"); + logger.print("create manifest.cfg, path:{}.", file.getAbsolutePath()); + FileUtils.writeLines(file, names); + } + + public void commonsExt(File base) throws Exception { + File dir = new File(base, "commons/ext"); + if ((!dir.exists()) || (!dir.isDirectory())) { + throw new Exception("error"); + } + List names = new ArrayList<>(); + for (File o : dir.listFiles()) { + if ((!StringUtils.equals(o.getName(), "manifest.cfg")) + && (!StringUtils.equals(o.getName(), ".gitignore"))) { + if (StringUtils.isNotEmpty(o.getName())) { + names.add(o.getName()); + } + } + } + names = names.stream().sorted().collect(Collectors.toList()); + File file = new File(dir, "manifest.cfg"); + logger.print("create manifest.cfg, path:{}.", file.getAbsolutePath()); + FileUtils.writeLines(file, names); + } +} \ No newline at end of file