mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
ProductEnvironment
This commit is contained in:
parent
5fea26f427
commit
bad2bf2fe8
@ -17,11 +17,7 @@
|
|||||||
|
|
||||||
package org.dromara.maxkey.web;
|
package org.dromara.maxkey.web;
|
||||||
|
|
||||||
import org.apache.commons.lang.SystemUtils;
|
|
||||||
import org.apache.commons.lang3.ArchUtils;
|
|
||||||
import org.apache.commons.lang3.arch.Processor;
|
|
||||||
import org.dromara.maxkey.configuration.ApplicationConfig;
|
import org.dromara.maxkey.configuration.ApplicationConfig;
|
||||||
import org.dromara.maxkey.util.PathUtils;
|
|
||||||
import org.dromara.mybatis.jpa.spring.MybatisJpaContext;
|
import org.dromara.mybatis.jpa.spring.MybatisJpaContext;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -42,10 +38,6 @@ import java.sql.Connection;
|
|||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InitApplicationContext .
|
* InitApplicationContext .
|
||||||
@ -56,12 +48,6 @@ public class InitializeContext extends HttpServlet {
|
|||||||
private static final Logger _logger = LoggerFactory.getLogger(InitializeContext.class);
|
private static final Logger _logger = LoggerFactory.getLogger(InitializeContext.class);
|
||||||
private static final long serialVersionUID = -797399138268601444L;
|
private static final long serialVersionUID = -797399138268601444L;
|
||||||
ApplicationContext applicationContext;
|
ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServletInfo() {
|
|
||||||
return super.getServletInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException {
|
public void init(ServletConfig config) throws ServletException {
|
||||||
@ -69,9 +55,6 @@ public class InitializeContext extends HttpServlet {
|
|||||||
WebContext.applicationContext = applicationContext;
|
WebContext.applicationContext = applicationContext;
|
||||||
|
|
||||||
MybatisJpaContext.init(applicationContext);
|
MybatisJpaContext.init(applicationContext);
|
||||||
|
|
||||||
// List Environment Variables
|
|
||||||
listEnvVars();
|
|
||||||
|
|
||||||
listProperties();
|
listProperties();
|
||||||
|
|
||||||
@ -179,56 +162,6 @@ public class InitializeContext extends HttpServlet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* listEnvVars.
|
|
||||||
*/
|
|
||||||
public void listEnvVars() {
|
|
||||||
_logger.debug("-----------------------------------------------------------");
|
|
||||||
_logger.debug("List Environment Variables ");
|
|
||||||
Map<String, String> map = System.getenv();
|
|
||||||
SortedSet<String> keyValueSet = new TreeSet<String>();
|
|
||||||
for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
|
|
||||||
String key = itr.next();
|
|
||||||
keyValueSet.add(key);
|
|
||||||
}
|
|
||||||
// out
|
|
||||||
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
|
|
||||||
String key = (String) it.next();
|
|
||||||
_logger.trace(key + " = {}" , map.get(key));
|
|
||||||
}
|
|
||||||
_logger.debug("APP_HOME" + " = {}" , PathUtils.getInstance().getAppPath());
|
|
||||||
|
|
||||||
Processor processor = ArchUtils.getProcessor();
|
|
||||||
if (Objects.isNull(processor)){
|
|
||||||
processor = new Processor(Processor.Arch.UNKNOWN, Processor.Type.UNKNOWN);
|
|
||||||
}
|
|
||||||
_logger.debug("OS : {}({} {}), version {}",
|
|
||||||
SystemUtils.OS_NAME,
|
|
||||||
SystemUtils.OS_ARCH,
|
|
||||||
processor.getType(),
|
|
||||||
SystemUtils.OS_VERSION
|
|
||||||
|
|
||||||
);
|
|
||||||
_logger.debug("COMPUTER: {}, USERNAME : {}",
|
|
||||||
map.get("COMPUTERNAME") ,
|
|
||||||
map.get("USERNAME")
|
|
||||||
);
|
|
||||||
_logger.debug("JAVA :");
|
|
||||||
_logger.debug("{} java version {}, class {}",
|
|
||||||
SystemUtils.JAVA_VENDOR,
|
|
||||||
SystemUtils.JAVA_VERSION,
|
|
||||||
SystemUtils.JAVA_CLASS_VERSION
|
|
||||||
);
|
|
||||||
_logger.debug("{} (build {}, {})",
|
|
||||||
SystemUtils.JAVA_VM_NAME,
|
|
||||||
SystemUtils.JAVA_VM_VERSION,
|
|
||||||
SystemUtils.JAVA_VM_INFO
|
|
||||||
);
|
|
||||||
|
|
||||||
_logger.debug("-----------------------------------------------------------");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* showLicense.
|
* showLicense.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,68 @@
|
|||||||
|
package org.dromara.maxkey.web;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.SystemUtils;
|
||||||
|
import org.apache.commons.lang3.ArchUtils;
|
||||||
|
import org.apache.commons.lang3.arch.Processor;
|
||||||
|
import org.dromara.maxkey.util.PathUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class ProductEnvironment {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProductEnvironment.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Environment Variables.
|
||||||
|
*/
|
||||||
|
public static void listEnvVars() {
|
||||||
|
logger.info("-----------------------------------------------------------");
|
||||||
|
logger.info("List Environment Variables ");
|
||||||
|
Map<String, String> map = System.getenv();
|
||||||
|
SortedSet<String> keyValueSet = new TreeSet<>();
|
||||||
|
for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
|
||||||
|
String key = itr.next();
|
||||||
|
keyValueSet.add(key);
|
||||||
|
}
|
||||||
|
// out
|
||||||
|
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
|
||||||
|
String key = it.next();
|
||||||
|
logger.trace("{} = {}" , key , map.get(key));
|
||||||
|
}
|
||||||
|
logger.debug("APP_HOME" + " = {}" , PathUtils.getInstance().getAppPath());
|
||||||
|
|
||||||
|
Processor processor = ArchUtils.getProcessor();
|
||||||
|
if (Objects.isNull(processor)){
|
||||||
|
processor = new Processor(Processor.Arch.UNKNOWN, Processor.Type.UNKNOWN);
|
||||||
|
}
|
||||||
|
logger.info("OS : {}({} {}), version {}",
|
||||||
|
SystemUtils.OS_NAME,
|
||||||
|
SystemUtils.OS_ARCH,
|
||||||
|
processor.getType(),
|
||||||
|
SystemUtils.OS_VERSION
|
||||||
|
|
||||||
|
);
|
||||||
|
logger.info("COMPUTER: {}, USERNAME : {}",
|
||||||
|
map.get("COMPUTERNAME") ,
|
||||||
|
map.get("USERNAME")
|
||||||
|
);
|
||||||
|
logger.info("JAVA :");
|
||||||
|
logger.info("{} java version {}, class {}",
|
||||||
|
SystemUtils.JAVA_VENDOR,
|
||||||
|
SystemUtils.JAVA_VERSION,
|
||||||
|
SystemUtils.JAVA_CLASS_VERSION
|
||||||
|
);
|
||||||
|
logger.info("{} (build {}, {})",
|
||||||
|
SystemUtils.JAVA_VM_NAME,
|
||||||
|
SystemUtils.JAVA_VM_VERSION,
|
||||||
|
SystemUtils.JAVA_VM_INFO
|
||||||
|
);
|
||||||
|
|
||||||
|
logger.info("-----------------------------------------------------------");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,6 +19,7 @@ package org.dromara.maxkey;
|
|||||||
|
|
||||||
import org.apache.ibatis.io.VFS;
|
import org.apache.ibatis.io.VFS;
|
||||||
import org.dromara.maxkey.web.InitializeContext;
|
import org.dromara.maxkey.web.InitializeContext;
|
||||||
|
import org.dromara.maxkey.web.ProductEnvironment;
|
||||||
import org.dromara.maxkey.web.WebContext;
|
import org.dromara.maxkey.web.WebContext;
|
||||||
import org.dromara.mybatis.jpa.starter.SpringBootVFS;
|
import org.dromara.mybatis.jpa.starter.SpringBootVFS;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
@ -45,6 +46,7 @@ public class MaxKeyApplication extends SpringBootServletInitializer {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
logger.info("Start MaxKey Application ...");
|
logger.info("Start MaxKey Application ...");
|
||||||
|
ProductEnvironment.listEnvVars();
|
||||||
|
|
||||||
VFS.addImplClass(SpringBootVFS.class);
|
VFS.addImplClass(SpringBootVFS.class);
|
||||||
ConfigurableApplicationContext applicationContext =
|
ConfigurableApplicationContext applicationContext =
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
package org.dromara.maxkey;
|
package org.dromara.maxkey;
|
||||||
|
|
||||||
import org.dromara.maxkey.web.InitializeContext;
|
import org.dromara.maxkey.web.InitializeContext;
|
||||||
|
import org.dromara.maxkey.web.ProductEnvironment;
|
||||||
import org.dromara.maxkey.web.WebContext;
|
import org.dromara.maxkey.web.WebContext;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
@ -63,7 +64,8 @@ public class MaxKeyMgtApplication extends SpringBootServletInitializer {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
logger.info("Start MaxKeyMgt Application ...");
|
logger.info("Start MaxKeyMgt Application ...");
|
||||||
|
ProductEnvironment.listEnvVars();
|
||||||
|
|
||||||
ConfigurableApplicationContext applicationContext =
|
ConfigurableApplicationContext applicationContext =
|
||||||
SpringApplication.run(MaxKeyMgtApplication.class, args);
|
SpringApplication.run(MaxKeyMgtApplication.class, args);
|
||||||
InitializeContext initWebContext = new InitializeContext(applicationContext);
|
InitializeContext initWebContext = new InitializeContext(applicationContext);
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package org.dromara.maxkey;
|
|||||||
|
|
||||||
|
|
||||||
import org.dromara.maxkey.web.InitializeContext;
|
import org.dromara.maxkey.web.InitializeContext;
|
||||||
|
import org.dromara.maxkey.web.ProductEnvironment;
|
||||||
import org.dromara.maxkey.web.WebContext;
|
import org.dromara.maxkey.web.WebContext;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
@ -59,7 +60,8 @@ public class MaxKeyOpenApiApplication extends SpringBootServletInitializer {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
logger.info("Start MaxKey OpenApi Application ...");
|
logger.info("Start MaxKey OpenApi Application ...");
|
||||||
|
ProductEnvironment.listEnvVars();
|
||||||
|
|
||||||
ConfigurableApplicationContext applicationContext =
|
ConfigurableApplicationContext applicationContext =
|
||||||
SpringApplication.run(MaxKeyOpenApiApplication.class, args);
|
SpringApplication.run(MaxKeyOpenApiApplication.class, args);
|
||||||
InitializeContext initWebContext = new InitializeContext(applicationContext);
|
InitializeContext initWebContext = new InitializeContext(applicationContext);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user