mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-07 17:28:27 +08:00
更新pom依赖
更新jdk基础依赖为jdk17 更新spring-boot依赖为3 重新整理配置文件DefaultConfig, KoTimeConfig, KoTimeRunner, LoadConfig 更新界面容量显示为易读, 调整显示样式
This commit is contained in:
parent
5965c682b4
commit
00ada5121b
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ rebel.xml
|
|||||||
target/
|
target/
|
||||||
.txlcn
|
.txlcn
|
||||||
*.log
|
*.log
|
||||||
/.idea/
|
|
||||||
|
|||||||
29
pom.xml
29
pom.xml
@ -6,35 +6,41 @@
|
|||||||
|
|
||||||
<groupId>cn.langpy</groupId>
|
<groupId>cn.langpy</groupId>
|
||||||
<artifactId>ko-time</artifactId>
|
<artifactId>ko-time</artifactId>
|
||||||
<version>2.4.4</version>
|
<version>3.0.0</version>
|
||||||
<name>KoTime</name>
|
<name>KoTime</name>
|
||||||
|
|
||||||
<description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description>
|
<description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU Lesser General Public License v2.1</name>
|
<name>GNU Lesser General Public License v2.1</name>
|
||||||
<url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
|
<url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<url>https://gitee.com/huoyo/ko-time</url>
|
<url>https://gitee.com/huoyo/ko-time</url>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<tag>master</tag>
|
<tag>master</tag>
|
||||||
<url>https://gitee.com/huoyo/ko-time.git</url>
|
<url>https://gitee.com/huoyo/ko-time.git</url>
|
||||||
<connection>scm:git:https://gitee.com/huoyo/ko-time.git</connection>
|
<connection>scm:git:https://gitee.com/huoyo/ko-time.git</connection>
|
||||||
<developerConnection>scm:git:https://gitee.com/huoyo/ko-time.git</developerConnection>
|
<developerConnection>scm:git:https://gitee.com/huoyo/ko-time.git</developerConnection>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<aspecttj.version>1.9.9.1</aspecttj.version>
|
<aspecttj.version>1.9.9.1</aspecttj.version>
|
||||||
<tomcat.version>9.0.43</tomcat.version>
|
<tomcat.version>10.1.12</tomcat.version>
|
||||||
<spring-context.version>5.3.24</spring-context.version>
|
<spring-context.version>6.0.11</spring-context.version>
|
||||||
<spring-web.version>5.3.24</spring-web.version>
|
<spring-web.version>6.0.11</spring-web.version>
|
||||||
<spring-webmvc.version>5.3.24</spring-webmvc.version>
|
<spring-webmvc.version>6.0.11</spring-webmvc.version>
|
||||||
<spring-boot.version>2.7.4</spring-boot.version>
|
<spring-boot.version>3.1.3</spring-boot.version>
|
||||||
<spring-redis.version>2.6.2</spring-redis.version>
|
<spring-redis.version>3.1.3</spring-redis.version>
|
||||||
<spring-mail.version>2.7.3</spring-mail.version>
|
<spring-mail.version>3.1.3</spring-mail.version>
|
||||||
<fastjson.version>2.0.9</fastjson.version>
|
<fastjson.version>2.0.9</fastjson.version>
|
||||||
<oshi-core.version>6.2.2</oshi-core.version>
|
<oshi-core.version>6.2.2</oshi-core.version>
|
||||||
<byte-agent.version>1.12.13</byte-agent.version>
|
<byte-agent.version>1.12.13</byte-agent.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
@ -100,12 +106,14 @@
|
|||||||
<version>${oshi-core.version}</version>
|
<version>${oshi-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<name>ZhangChang</name>
|
<name>ZhangChang</name>
|
||||||
<email>1729913829@qq.com</email>
|
<email>1729913829@qq.com</email>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -113,8 +121,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>17</source>
|
||||||
<target>1.8</target>
|
<target>17</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -175,6 +183,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
<id>snapshots</id>
|
<id>snapshots</id>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package cn.langpy.kotime.config;
|
|||||||
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,43 +10,177 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "ko-time")
|
@ConfigurationProperties(prefix = "ko-time")
|
||||||
|
@Lazy(value = false)
|
||||||
public class DefaultConfig {
|
public class DefaultConfig {
|
||||||
private Boolean enable;
|
/**
|
||||||
private String language;
|
* to enable kotime
|
||||||
|
*/
|
||||||
|
private Boolean enable = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to select language for viewer, chinese
|
||||||
|
*/
|
||||||
|
private String language = "chinese";
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private String logLanguage;
|
private String logLanguage;
|
||||||
private Boolean logEnable;
|
|
||||||
private Boolean versionNotice;
|
/**
|
||||||
private Double threshold;
|
* false
|
||||||
private Double discardRate;
|
* to print log in console
|
||||||
private String pointcut;
|
*/
|
||||||
private Boolean exceptionEnable;
|
private Boolean logEnable = false;
|
||||||
private Boolean paramAnalyse;
|
|
||||||
private String saver;
|
/**
|
||||||
|
* "defaultValue": true,
|
||||||
|
* "description": "to enable version-notice",
|
||||||
|
*/
|
||||||
|
private Boolean versionNotice = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* red will appear if avgRunTime>threshold
|
||||||
|
*/
|
||||||
|
private Double threshold = 800.0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data will be discard if Math.random()<discard-rate
|
||||||
|
*/
|
||||||
|
private Double discardRate = 0.3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pointcut for aop
|
||||||
|
* execution(* com.example..*.*(..))
|
||||||
|
*/
|
||||||
|
private String pointcut = "execution(* com.example..*.*(..))";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to enable exception listener
|
||||||
|
* "defaultValue": false,
|
||||||
|
*/
|
||||||
|
private Boolean exceptionEnable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the charger of analysing params
|
||||||
|
*/
|
||||||
|
private Boolean paramAnalyse = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a place to store data
|
||||||
|
* memory
|
||||||
|
*/
|
||||||
|
private String saver = "memory";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datasource
|
||||||
|
*/
|
||||||
private String dataSource;
|
private String dataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StringRedisTemplate‘s bean
|
||||||
|
*/
|
||||||
private String redisTemplate;
|
private String redisTemplate;
|
||||||
private Integer threadNum;
|
|
||||||
private String contextPath;
|
/**
|
||||||
|
* number of thread to store data
|
||||||
|
*/
|
||||||
|
private Integer threadNum = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* server url for static resources
|
||||||
|
* http://localhost:8080
|
||||||
|
*/
|
||||||
|
private String contextPath = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dataPrefix
|
||||||
|
*/
|
||||||
private String dataPrefix;
|
private String dataPrefix;
|
||||||
private Boolean dataReset;
|
|
||||||
private Boolean authEnable;
|
/**
|
||||||
|
* to delete all data
|
||||||
|
*/
|
||||||
|
private Boolean dataReset = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to enable authentication
|
||||||
|
*/
|
||||||
|
private Boolean authEnable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* userName for authentication
|
||||||
|
*/
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* password for authentication
|
||||||
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* static token of html
|
||||||
|
*/
|
||||||
private String staticToken;
|
private String staticToken;
|
||||||
|
|
||||||
private Long authExpire;
|
/**
|
||||||
|
* expire within 43200 s
|
||||||
|
*/
|
||||||
|
private Long authExpire = 43200L;
|
||||||
|
|
||||||
private Boolean mailEnable;
|
/**
|
||||||
private String mailHost;
|
* to enable email
|
||||||
private Integer mailPort;
|
*/
|
||||||
private String mailProtocol;
|
private Boolean mailEnable = false;
|
||||||
private String mailEncoding;
|
|
||||||
|
/**
|
||||||
|
* host of email
|
||||||
|
*/
|
||||||
|
private String mailHost = "smtp.qq.com";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* port of email
|
||||||
|
*/
|
||||||
|
private Integer mailPort = 587;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* protocol of email
|
||||||
|
*/
|
||||||
|
private String mailProtocol = "smtp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* encoding of email
|
||||||
|
*/
|
||||||
|
private String mailEncoding = "UTF-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sender of email
|
||||||
|
*/
|
||||||
private String mailUser;
|
private String mailUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* code of email
|
||||||
|
*/
|
||||||
private String mailCode;
|
private String mailCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* receivers of email
|
||||||
|
*/
|
||||||
private String mailReceivers;
|
private String mailReceivers;
|
||||||
private Integer mailThreshold;
|
|
||||||
private String mailScope;
|
/**
|
||||||
private String propertyFile;
|
* trigger thresold of email
|
||||||
|
*/
|
||||||
|
private Integer mailThreshold = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trigger scope of email
|
||||||
|
*/
|
||||||
|
private String mailScope = "Controller";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dynamic.properties
|
||||||
|
*/
|
||||||
|
private String propertyFile = "dynamic.properties";
|
||||||
|
|
||||||
public String getPropertyFile() {
|
public String getPropertyFile() {
|
||||||
return propertyFile;
|
return propertyFile;
|
||||||
|
|||||||
36
src/main/java/cn/langpy/kotime/config/KoTimeConfig.java
Normal file
36
src/main/java/cn/langpy/kotime/config/KoTimeConfig.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package cn.langpy.kotime.config;
|
||||||
|
|
||||||
|
import cn.langpy.kotime.handler.RunTimeHandler;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ccz
|
||||||
|
* @date 2024-7-5 03:16:56
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class KoTimeConfig {
|
||||||
|
private static Logger log = Logger.getLogger(KoTimeConfig.class.toString());
|
||||||
|
|
||||||
|
@Value("${koTime.pointcut:execution(* cn.langpy.kotime.controller.KoTimeController.*(..))}")
|
||||||
|
private String pointcut;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DefaultConfig defaultConfig;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AspectJExpressionPointcutAdvisor configurabledvisor() {
|
||||||
|
log.info("kotime=>loading method listener");
|
||||||
|
AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
|
||||||
|
String cutRange = defaultConfig.getPointcut() == null ? pointcut : defaultConfig.getPointcut();
|
||||||
|
cutRange = cutRange + " && !@annotation(cn.langpy.kotime.annotation.KoListener)";
|
||||||
|
advisor.setExpression(cutRange);
|
||||||
|
advisor.setAdvice(new RunTimeHandler());
|
||||||
|
return advisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/main/java/cn/langpy/kotime/config/KoTimeRunner.java
Normal file
23
src/main/java/cn/langpy/kotime/config/KoTimeRunner.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package cn.langpy.kotime.config;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ccz
|
||||||
|
* @date 2024-7-5 03:17:13
|
||||||
|
*/
|
||||||
|
@ComponentScan("cn.langpy.kotime")
|
||||||
|
@AutoConfiguration
|
||||||
|
public class KoTimeRunner implements ApplicationRunner {
|
||||||
|
@Resource
|
||||||
|
private LoadConfig loadConfig;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
loadConfig.initConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,30 +1,27 @@
|
|||||||
package cn.langpy.kotime.config;
|
package cn.langpy.kotime.config;
|
||||||
|
|
||||||
import cn.langpy.kotime.annotation.KoListener;
|
import cn.langpy.kotime.annotation.KoListener;
|
||||||
import cn.langpy.kotime.handler.RunTimeHandler;
|
|
||||||
import cn.langpy.kotime.handler.InvokedHandler;
|
import cn.langpy.kotime.handler.InvokedHandler;
|
||||||
import cn.langpy.kotime.service.GraphService;
|
import cn.langpy.kotime.service.GraphService;
|
||||||
import cn.langpy.kotime.service.InvokedQueue;
|
import cn.langpy.kotime.service.InvokedQueue;
|
||||||
import cn.langpy.kotime.util.Common;
|
import cn.langpy.kotime.util.Common;
|
||||||
import cn.langpy.kotime.util.Context;
|
import cn.langpy.kotime.util.Context;
|
||||||
import cn.langpy.kotime.util.DataBaseException;
|
import cn.langpy.kotime.util.DataBaseException;
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
|
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.*;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -32,8 +29,7 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* zhangchang
|
* zhangchang
|
||||||
*/
|
*/
|
||||||
@ComponentScan("cn.langpy.kotime")
|
@Component
|
||||||
@Configuration
|
|
||||||
public class LoadConfig {
|
public class LoadConfig {
|
||||||
private static Logger log = Logger.getLogger(LoadConfig.class.toString());
|
private static Logger log = Logger.getLogger(LoadConfig.class.toString());
|
||||||
|
|
||||||
@ -56,7 +52,6 @@ public class LoadConfig {
|
|||||||
@Value("${server.servlet.context-path:}")
|
@Value("${server.servlet.context-path:}")
|
||||||
private String serverContext;
|
private String serverContext;
|
||||||
|
|
||||||
|
|
||||||
@Value("${ko-time.mail-enable:false}")
|
@Value("${ko-time.mail-enable:false}")
|
||||||
private Boolean mailEnable;
|
private Boolean mailEnable;
|
||||||
|
|
||||||
@ -65,8 +60,6 @@ public class LoadConfig {
|
|||||||
@Resource
|
@Resource
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void initConfig() {
|
public void initConfig() {
|
||||||
DefaultConfig config = improveConfig();
|
DefaultConfig config = improveConfig();
|
||||||
|
|
||||||
@ -215,15 +208,4 @@ public class LoadConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AspectJExpressionPointcutAdvisor configurabledvisor() {
|
|
||||||
log.info("kotime=>loading method listener");
|
|
||||||
AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
|
|
||||||
String cutRange = defaultConfig.getPointcut() == null ? pointcut : defaultConfig.getPointcut();
|
|
||||||
cutRange = cutRange + " && !@annotation(cn.langpy.kotime.annotation.KoListener)";
|
|
||||||
advisor.setExpression(cutRange);
|
|
||||||
advisor.setAdvice(new RunTimeHandler());
|
|
||||||
return advisor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import cn.langpy.kotime.service.ThreadUsageService;
|
|||||||
import cn.langpy.kotime.util.Context;
|
import cn.langpy.kotime.util.Context;
|
||||||
import cn.langpy.kotime.util.InvalidAuthInfoException;
|
import cn.langpy.kotime.util.InvalidAuthInfoException;
|
||||||
import cn.langpy.kotime.util.KoUtil;
|
import cn.langpy.kotime.util.KoUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -18,8 +20,6 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -44,6 +44,7 @@ public class KoTimeController {
|
|||||||
private final String metricFlowJsText = getResourceText("kostatic/Metricflow.js");
|
private final String metricFlowJsText = getResourceText("kostatic/Metricflow.js");
|
||||||
private final String jQueryJsText = getResourceText("kostatic/JQuery.min.js");
|
private final String jQueryJsText = getResourceText("kostatic/JQuery.min.js");
|
||||||
private final String uiKitIconsJs = getResourceText("kostatic/uikit-icons.js");
|
private final String uiKitIconsJs = getResourceText("kostatic/uikit-icons.js");
|
||||||
|
private final String KoTimeUtil = getResourceText("kostatic/util.js");
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ -81,7 +82,7 @@ public class KoTimeController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public void index(String kotoken, String test,String charset, String language,HttpServletResponse response, HttpServletRequest request) {
|
public void index(String kotoken, String test, String charset, String language, HttpServletResponse response, HttpServletRequest request) {
|
||||||
if (!Context.getConfig().getEnable()) {
|
if (!Context.getConfig().getEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -95,7 +96,7 @@ public class KoTimeController {
|
|||||||
if (!StringUtils.hasText(charset)) {
|
if (!StringUtils.hasText(charset)) {
|
||||||
charset = "utf-8";
|
charset = "utf-8";
|
||||||
}
|
}
|
||||||
response.setContentType("text/html;charset="+charset);
|
response.setContentType("text/html;charset=" + charset);
|
||||||
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName(language));
|
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName(language));
|
||||||
try (
|
try (
|
||||||
InputStream inputStream = classPathResource.getInputStream();
|
InputStream inputStream = classPathResource.getInputStream();
|
||||||
@ -132,6 +133,8 @@ public class KoTimeController {
|
|||||||
line = line.replace("staticTokenVisitValue", staticTokenVisit + "");
|
line = line.replace("staticTokenVisitValue", staticTokenVisit + "");
|
||||||
} else if (line.indexOf("staticTokenValue") > -1) {
|
} else if (line.indexOf("staticTokenValue") > -1) {
|
||||||
line = line.replace("staticTokenValue", "'" + kotoken + "'");
|
line = line.replace("staticTokenValue", "'" + kotoken + "'");
|
||||||
|
} else if (line.indexOf("KoTimeUtil") > -1) {
|
||||||
|
line = line.replace("KoTimeUtil", KoTimeUtil);
|
||||||
}
|
}
|
||||||
stringBuilder.append(line + "\n");
|
stringBuilder.append(line + "\n");
|
||||||
}
|
}
|
||||||
@ -377,7 +380,7 @@ public class KoTimeController {
|
|||||||
threads = threads.stream().sorted(COMPARATOR).collect(Collectors.toList());
|
threads = threads.stream().sorted(COMPARATOR).collect(Collectors.toList());
|
||||||
|
|
||||||
Map<String, Long> stateCounting = threads.stream().collect(Collectors.groupingBy(ThreadInfo::getState, Collectors.counting()));
|
Map<String, Long> stateCounting = threads.stream().collect(Collectors.groupingBy(ThreadInfo::getState, Collectors.counting()));
|
||||||
stateCounting.put("all",(long)threads.size());
|
stateCounting.put("all", (long) threads.size());
|
||||||
|
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("statistics", stateCounting);
|
map.put("statistics", stateCounting);
|
||||||
@ -399,17 +402,17 @@ public class KoTimeController {
|
|||||||
Properties dynamicProperties = Context.getDynamicProperties();
|
Properties dynamicProperties = Context.getDynamicProperties();
|
||||||
for (String line : textSplit) {
|
for (String line : textSplit) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (line.length()==0 || line.startsWith("#") || line.startsWith("//")) {
|
if (line.length() == 0 || line.startsWith("#") || line.startsWith("//")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int i = line.indexOf("=");
|
int i = line.indexOf("=");
|
||||||
if (i<1) {
|
if (i < 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String propertyStr = line.substring(0, i).trim();
|
String propertyStr = line.substring(0, i).trim();
|
||||||
String valueStr = line.substring(i+1).trim();
|
String valueStr = line.substring(i + 1).trim();
|
||||||
log.info("updated property: "+propertyStr+"=("+dynamicProperties.get(propertyStr)+"->"+valueStr+")");
|
log.info("updated property: " + propertyStr + "=(" + dynamicProperties.get(propertyStr) + "->" + valueStr + ")");
|
||||||
dynamicProperties.setProperty(propertyStr,valueStr);
|
dynamicProperties.setProperty(propertyStr, valueStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -426,8 +429,8 @@ public class KoTimeController {
|
|||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (String key : dynamicProperties.stringPropertyNames()) {
|
for (String key : dynamicProperties.stringPropertyNames()) {
|
||||||
String value = dynamicProperties.getProperty(key);
|
String value = dynamicProperties.getProperty(key);
|
||||||
if (value!=null) {
|
if (value != null) {
|
||||||
stringBuilder.append(key+"="+value+"\n");
|
stringBuilder.append(key + "=" + value + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.put("data", stringBuilder.toString());
|
map.put("data", stringBuilder.toString());
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
cn.langpy.kotime.config.KoTimeRunner
|
||||||
10
src/main/resources/kostatic/util.js
Normal file
10
src/main/resources/kostatic/util.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function getSize(size) {
|
||||||
|
let sizes = [' Bytes', ' KB', ' MB', ' GB',
|
||||||
|
' TB', ' PB', ' EB', ' ZB', ' YB'];
|
||||||
|
|
||||||
|
for (let i = 1; i < sizes.length; i++) {
|
||||||
|
if (size < Math.pow(1024, i))
|
||||||
|
return (Math.round((size / Math.pow(1024, i - 1)) * 100) / 100) + sizes[i - 1];
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user