diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java index c390bc51175a3ba578a5c95edc0705bacbda6870..164fccf33b6ecdd9e9deec6af890b0d3c9dd8515 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java @@ -36,12 +36,6 @@ public abstract class StorageObject extends SliceJpaObject { synchronized (StorageObject.class) { if (FILESYSTEMANAGERINSTANCE == null) { StandardFileSystemManager fs = new StandardFileSystemManager(); - // DefaultFileSystemManager fs = new - // DefaultFileSystemManager(); - // File file = new File(Config.base(), "local/temp/vfs"); - // FileUtils.forceMkdir(file); - // fs.setTemporaryFileStore(new - // DefaultFileReplicator(file)); fs.setFilesCache(new NullFilesCache()); fs.setCacheStrategy(CacheStrategy.ON_RESOLVE); fs.init(); diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/Context.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/Context.java index 6e2ff3fa5e0520b67df013f35577f14b8e5ac93c..8025f0a8f5b241305521a484415b50ea99485bf1 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/Context.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/Context.java @@ -8,7 +8,6 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletRequest; -import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.openjpa.enhance.PCRegistry; import org.quartz.CronScheduleBuilder; import org.quartz.DateBuilder; @@ -26,7 +25,6 @@ import org.quartz.impl.matchers.EverythingMatcher; 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.project.config.Config; import com.x.base.core.project.config.DataMappings; import com.x.base.core.project.config.StorageMappings; @@ -97,13 +95,33 @@ public class Context extends AbstractContext { return this.clazz; } - /** 随机令牌 */ + private Deployable clazzInstance; + + public Deployable clazzInstance() { + return this.clazzInstance; + } + + /* 随机令牌 */ private volatile String token; public String token() { return this.token; } + /* contextPath */ + private volatile String contextPath; + + public String contextPath() { + return this.contextPath; + } + + /* title */ + private volatile String name; + + public String name() { + return this.name; + } + /* Storage资源 */ private volatile StorageMappings storageMappings; @@ -170,15 +188,17 @@ public class Context extends AbstractContext { } public static Context concrete(ServletContextEvent servletContextEvent) throws Exception { - /** 强制忽略ssl服务器认证 */ - // HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); + /* 强制忽略ssl服务器认证 */ SslTools.ignoreSsl(); 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(Packages.com_x_base_core_project_dot + context.servletContextName); context.weight = Config.currentNode().getApplication().weight(context.clazz); context.sslEnable = Config.currentNode().getApplication().getSslEnable(); context.initDatasFromCenters(); @@ -262,10 +282,9 @@ public class Context extends AbstractContext { } private void initDatasFromCenters() throws Exception { - @SuppressWarnings("unchecked") - List containerEntities = (List) FieldUtils.readStaticField(clazz, "containerEntities"); - if (ListTools.isNotEmpty(containerEntities)) { - logger.print("{} loading datas, entity size:{}.", this.clazz.getName(), containerEntities.size()); + if (ListTools.isNotEmpty(clazzInstance.dependency.containerEntities)) { + logger.print("{} loading datas, entity size:{}.", this.clazz.getName(), + clazzInstance.dependency.containerEntities.size()); DataMappings dataMappings = null; do { try { @@ -282,10 +301,9 @@ public class Context extends AbstractContext { } private void initStoragesFromCenters() throws Exception { - @SuppressWarnings("unchecked") - List usedStorageTypes = (List) FieldUtils.readStaticField(clazz, "usedStorageTypes"); - if (ListTools.isNotEmpty(usedStorageTypes)) { - logger.print("{} loading storages, type size:{}.", this.clazz.getName(), usedStorageTypes.size()); + if (ListTools.isNotEmpty(clazzInstance.dependency.storageTypes)) { + logger.print("{} loading storages, type size:{}.", this.clazz.getName(), + clazzInstance.dependency.storageTypes.size()); StorageMappings storageMappings = null; do { try { diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/ServiceA.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/ServiceA.java index 94292f314fe70f5104a2a2ecb40d64c3c6d1fc63..350a088d6bf1473022c145d63362cb109cfeb7a4 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/ServiceA.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/ServiceA.java @@ -1,169 +1,5 @@ package com.x.base.core.project; -import java.io.File; -import java.util.Collection; -import java.util.TreeMap; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.WildcardFileFilter; -import org.apache.commons.lang3.StringUtils; - -import com.x.base.core.project.gson.XGsonBuilder; -import com.x.base.core.project.tools.JarTools; - public abstract class ServiceA extends Deployable { - private File concreteStructure(String distPath, String repositoryPath) throws Exception { - File dir = new File(distPath, this.getName()); - FileUtils.forceMkdir(dir); - FileUtils.cleanDirectory(dir); - File webInf = new File(dir, "WEB-INF"); - FileUtils.forceMkdir(webInf); - File lib = new File(webInf, "lib"); - FileUtils.forceMkdir(lib); - File classes = new File(webInf, "classes"); - FileUtils.forceMkdir(classes); - File metaInf = new File(classes, "META-INF"); - FileUtils.forceMkdir(metaInf); - this.copyPersistence(metaInf, repositoryPath); - this.copyJar_independent(lib, repositoryPath); - this.extractJar(classes, repositoryPath); - this.extractZip(dir, repositoryPath); - this.createWebXml(webInf); - return dir; - } - - private void createCenterServerFile(File metaInf, String host, Integer port, String cipher) throws Exception { - TreeMap map = new TreeMap<>(); - map.put("host", StringUtils.trimToEmpty(host)); - map.put("port", null != port ? port : 20080); - map.put("cipher", cipher); - FileUtils.writeStringToFile(new File(metaInf, "centerServer.json"), XGsonBuilder.toJson(map)); - } - - private void createConfigFile(File metaInf, String configApplicationServer) throws Exception { - TreeMap map = new TreeMap<>(); - map.put("applicationServer", StringUtils.trimToEmpty(configApplicationServer)); - FileUtils.writeStringToFile(new File(metaInf, "config.json"), XGsonBuilder.toJson(map)); - } - - private void copyJar_independent(File lib, String repositoryPath) throws Exception { - File repositoryLib = new File(repositoryPath); - FileUtils.copyDirectory(repositoryLib, lib, new WildcardFileFilter("x_base_core*.jar")); - FileUtils.copyDirectory(repositoryLib, lib, new WildcardFileFilter("x_common_core*.jar")); - FileUtils.copyDirectory(new File(repositoryLib, "openjpa"), lib, new WildcardFileFilter("*.jar")); - FileUtils.copyDirectory(new File(repositoryLib, "ehcache"), lib, new WildcardFileFilter("*.jar")); - FileUtils.copyDirectory(new File(repositoryLib, "slf4j"), lib, new WildcardFileFilter("*.jar")); - } - - private void copyPersistence(File metaInf, String repositoryPath) throws Exception { - FileUtils.copyFile(new File(repositoryPath, "x_persistence_" + this.getName() + ".xml"), - new File(metaInf, "x_persistence.xml"), false); - } - - private void createWebXml(File webInf) throws Exception { - String xml = "" + "" + "" + this.getName() - + ""; - xml += druid_servlet; - xml += druid_servlet_mapping; - xml += druid_filter; - xml += druid_filter_mapping; - xml += ""; - File file = new File(webInf, "web.xml"); - FileUtils.writeStringToFile(file, xml, "UTF-8"); - } - - private void extractJar(File classes, String repositoryPath) throws Exception { - File repositoryLib = new File(repositoryPath); - Collection files = FileUtils.listFiles(repositoryLib, new WildcardFileFilter(this.getName() + "*.jar"), - null); - JarTools.unjar(files.iterator().next(), "", classes, true); - } - - private void extractZip(File dir, String repositoryPath) throws Exception { - File file = new File(repositoryPath, this.getName() + ".zip"); - JarTools.unjar(file, "", dir, true); - } - - @Override - public String pack(String distPath, String repositoryPath) throws Exception { - File dir = this.concreteStructure(distPath, repositoryPath); - custom(dir, repositoryPath); - File war = new File(distPath, this.getName() + ".war"); - JarTools.jar(dir, war); - return war.getAbsolutePath(); - } - - protected abstract void custom(File dir, String repositoryPath) throws Exception; - - protected String getName() { - return StringUtils.replace(this.getClass().getSimpleName(), ".", "_"); - } - - public class Argument { - private String distPath; - private String repositoryPath; - private String resourcesPath; - private String centerHost; - private Integer centerPort; - private String centerCipher; - private String configApplicationServer; - - public String getDistPath() { - return distPath; - } - - public void setDistPath(String distPath) { - this.distPath = distPath; - } - - public String getRepositoryPath() { - return repositoryPath; - } - - public void setRepositoryPath(String repositoryPath) { - this.repositoryPath = repositoryPath; - } - - public String getResourcesPath() { - return resourcesPath; - } - - public void setResourcesPath(String resourcesPath) { - this.resourcesPath = resourcesPath; - } - - public String getCenterHost() { - return centerHost; - } - - public void setCenterHost(String centerHost) { - this.centerHost = centerHost; - } - - public Integer getCenterPort() { - return centerPort; - } - - public void setCenterPort(Integer centerPort) { - this.centerPort = centerPort; - } - - public String getCenterCipher() { - return centerCipher; - } - - public void setCenterCipher(String centerCipher) { - this.centerCipher = centerCipher; - } - - public String getConfigApplicationServer() { - return configApplicationServer; - } - - public void setConfigApplicationServer(String configApplicationServer) { - this.configApplicationServer = configApplicationServer; - } - - } + } diff --git a/o2server/x_collaboration_service_message/src/main/webapp/WEB-INF/web.xml b/o2server/x_collaboration_service_message/src/main/webapp/WEB-INF/web.xml index 41fffe355a74af485bc1ab40fee3b7f0380f8cc2..ec3da51f09bb97dfd4e3bb3f88a3f4d691ded27b 100644 --- a/o2server/x_collaboration_service_message/src/main/webapp/WEB-INF/web.xml +++ b/o2server/x_collaboration_service_message/src/main/webapp/WEB-INF/web.xml @@ -2,4 +2,9 @@ x_collaboration_service_message + + project + com.x.base.core.project.x_collaboration_service_message + + diff --git a/o2server/x_component_assemble_control/src/main/webapp/WEB-INF/web.xml b/o2server/x_component_assemble_control/src/main/webapp/WEB-INF/web.xml index 3e12bf37cbd56d9ea0cce0b87a52a80afb23ed25..32426e1d385edc0de162d6bbb61244d37111afc9 100644 --- a/o2server/x_component_assemble_control/src/main/webapp/WEB-INF/web.xml +++ b/o2server/x_component_assemble_control/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,10 @@ - + x_component_assemble_control + + project + com.x.base.core.project.x_component_assemble_control + +