【优化】测试代码

This commit is contained in:
wxd-gaming
2024-08-01 20:58:18 +08:00
parent fb75af80b2
commit 64e8d23a32
26 changed files with 376 additions and 54 deletions

View File

@@ -6,51 +6,48 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="robotsr" />
<module name="wxdgaming.boot.batis.mongodb" />
<module name="wxdgaming.boot.convert" />
<module name="wxdgaming.boot.jscript" />
<module name="wxdgaming.chargame.server-scripts" />
<module name="gamesr-script" />
<module name="wxdgaming.chargame.client" />
<module name="wxdgaming-reactor" />
<module name="wxdgaming.chargame.server" />
<module name="wxdgaming.boot.batis.redis" />
<module name="wxdgaming.boot.holder" />
<module name="web-script" />
<module name="wxdgaming.boot.net" />
<module name="web" />
<module name="wxdgaming.boot.batis" />
<module name="jetty" />
<module name="wxdgaming.boot.agent" />
<module name="gamesr" />
<module name="wxdgaming.boot.kotlin" />
<module name="wxdgaming.boot.batis.sql.sqlite" />
<module name="spring-lua" />
<module name="wxdgaming.boot.batis.sql.mysql" />
<module name="wxdgaming.boot.net.http.client.url" />
<module name="loginsr-script" />
<module name="robotsr-script" />
<module name="wxdgaming.boot.net.http" />
<module name="wxdgaming.boot.net.http.client.apache" />
<module name="wxdgaming.boot.net.http.client.jdk" />
<module name="wxdgaming.boot.starter" />
<module name="local-db" />
<module name="message" />
<module name="wxdgaming.boot.net.http.service.simple" />
<module name="wxdgaming.boot.assist" />
<module name="loginsr" />
<module name="wxdgaming.boot.batis.sql" />
<module name="wxdgaming.boot.logbus" />
<module name="wxdgaming.boot.lua" />
<module name="core" />
<module name="wxdgaming.boot.core" />
<module name="wxdgaming.boot.springstarter" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="core" target="21" />
<module name="gamesr" target="21" />
<module name="gamesr-script" target="21" />
<module name="jetty" target="21" />
<module name="local-db" target="21" />
<module name="loginsr" target="21" />
<module name="loginsr-script" target="21" />
<module name="message" target="21" />
<module name="robotsr" target="21" />
<module name="robotsr-script" target="21" />
<module name="web" target="21" />
<module name="web-script" target="21" />
<module name="wxdgaming-chargame" target="21" />
<module name="wxdgaming-mmoarpg" target="21" />
<module name="wxdgaming-reactor" target="21" />
<module name="wxdgaming.chargame.client" target="21" />
<module name="wxdgaming.chargame.server" target="21" />
<module name="wxdgaming.chargame.server-scripts" target="21" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
@@ -65,6 +62,7 @@
<module name="robotsr" options="--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
<module name="robotsr-script" options="--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
<module name="spring" options="" />
<module name="spring-lua" options="-parameters" />
<module name="web" options="--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
<module name="web-script" options="--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
<module name="wxdgaming-chargame" options="--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />

View File

@@ -1,17 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/../spring-lua/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/local-db/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/local-db/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.core/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.gamesr-script/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.gamesr-script/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.gamesr/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.gamesr/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.loginsr-script/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.loginsr-script/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.loginsr/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.loginsr/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.message/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.message/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.robotsr-script/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.robotsr-script/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.robotsr/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.robotsr/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.web-script/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.web-script/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.web/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../wxdgaming-mmoarpg/wxdgaming.mmo.web/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/wxdgaming.boot.springstarter/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/jetty/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/jetty/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming-reactor/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming-reactor/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.client/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.client/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.server-scripts/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.server-scripts/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.server/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming-chargame/wxdgaming.chargame.server/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming.boot/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming.boot/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../wxdgaming.boot/wxdgaming.boot.agent/src/main/java" charset="UTF-8" />

View File

@@ -6,6 +6,9 @@
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../../wxdgaming.boot/pom.xml" />
<option value="$PROJECT_DIR$/../spring-lua/pom.xml" />
<option value="$PROJECT_DIR$/../wxdgaming-mmoarpg/pom.xml" />
<option value="$PROJECT_DIR$/../../wxdgaming-chargame/pom.xml" />
</list>
</option>
</component>

View File

@@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/wxdgaming.boot.springstarter/wxdgaming.boot.springstarter.iml" filepath="$PROJECT_DIR$/wxdgaming.boot.springstarter/wxdgaming.boot.springstarter.iml" />
<module fileurl="file://$PROJECT_DIR$/../../wxdgaming.boot/wxdgaming.boot.iml" filepath="$PROJECT_DIR$/../../wxdgaming.boot/wxdgaming.boot.iml" />
</modules>
</component>
</project>

View File

@@ -2,6 +2,7 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../../wxdgaming-chargame" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../../wxdgaming.boot" vcs="Git" />
</component>
</project>

View File

@@ -52,6 +52,16 @@
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.45</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
@@ -95,7 +105,6 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.45</version>
</dependency>
<!--日志框架-->
<dependency>
@@ -161,18 +170,13 @@
<version>${wxdgaming.boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.7.0</version>
</dependency>
<dependency>
<groupId>org.luaj</groupId>
<artifactId>luaj-jse</artifactId>
<version>3.0.1</version>
<groupId>wxdgaming.boot</groupId>
<artifactId>wxdgaming.boot.lua</artifactId>
<version>${wxdgaming.boot.version}</version>
</dependency>
<dependency>
<groupId>wxdgaming.boot</groupId>
<artifactId>wxdgaming.boot.lua</artifactId>
<artifactId>wxdgaming.boot.net</artifactId>
<version>${wxdgaming.boot.version}</version>
</dependency>
</dependencies>

View File

@@ -1,7 +1,5 @@
package wxdgaming.boot.spring.starter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -10,7 +8,9 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import wxdgaming.boot.agent.loader.ClassDirLoader;
import wxdgaming.boot.agent.system.ReflectContext;
import wxdgaming.boot.spring.starter.config.SpringUtil;
import wxdgaming.boot.spring.starter.i.OnStart;
@EnableAsync
@EnableScheduling
@@ -32,6 +32,24 @@ public class BootStarter {
public static void reload() throws Exception {
ClassDirLoader classDirLoader = new ClassDirLoader("wxdgaming.boot.springstarter/target/test-classes", BootStarter.class.getClassLoader());
SpringUtil.loadClassLoader(classDirLoader, "wxdgaming.boot.springstarter.scripts");
ReflectContext
.Builder
.of(classDirLoader, "wxdgaming.boot")
.build()
.stream()
.sorted((o1, o2) -> SpringUtil.classComparator.compare(o1.getCls(), o2.getCls()))
.forEach(info -> {
Class<?> cls = info.getCls();
info.methodsWithAnnotated(OnStart.class).forEach(method -> {
Object bean = SpringUtil.getBean(cls);
System.out.println(cls + " - " + method.getName());
try {
method.invoke(bean);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
});
}
}

View File

@@ -18,7 +18,6 @@ import java.io.Serializable;
**/
@Slf4j
@Data
@Order(1)
@Component
@DependsOn(value = {"threadPoolConfig"})
@ConfigurationProperties(prefix = "database")

View File

@@ -0,0 +1,29 @@
package wxdgaming.boot.spring.starter.config;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import wxdgaming.boot.spring.starter.config.bean.TcpConfig;
/**
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2024-08-01 20:04
**/
@Slf4j
@Data
@Component
@DependsOn(value = {"threadPoolConfig"})
@ConfigurationProperties(prefix = "net-config")
public class NetConfig {
private TcpConfig tcpSocket;
private TcpConfig tcpSocket1;
private TcpConfig webSocket;
public NetConfig() {
System.out.println("\n" + this.getClass());
}
}

View File

@@ -32,6 +32,7 @@ import wxdgaming.boot.agent.system.ReflectContext;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
@@ -214,17 +215,20 @@ public class SpringUtil implements ApplicationContextAware, WebApplicationInitia
}
public static final Comparator<Class<?>> classComparator = (o1, o2) -> {
int o1Annotation = Optional.ofNullable(o1.getAnnotation(Order.class)).map(Order::value).orElse(999999);
int o2Annotation = Optional.ofNullable(o2.getAnnotation(Order.class)).map(Order::value).orElse(999999);
if (o1Annotation != o2Annotation) {
return Integer.compare(o1Annotation, o2Annotation);
}
return o1.getName().compareTo(o2.getName());
};
public static void loadClassLoader(ReflectContext context) {
List<Class<?>> list = context.classStream()
.filter(SpringUtil::hasSpringAnnotation)
.sorted((o1, o2) -> {
int o1Annotation = Optional.ofNullable(o1.getAnnotation(Order.class)).map(Order::value).orElse(999999);
int o2Annotation = Optional.ofNullable(o2.getAnnotation(Order.class)).map(Order::value).orElse(999999);
if (o1Annotation != o2Annotation) {
return Integer.compare(o1Annotation, o2Annotation);
}
return o1.getName().compareTo(o2.getName());
})
.sorted(classComparator)
.toList();
loadClassLoader(list);
}

View File

@@ -0,0 +1,55 @@
package wxdgaming.boot.spring.starter.config.bean;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import wxdgaming.boot.core.lang.ObjectBase;
import wxdgaming.boot.core.str.StringUtil;
import wxdgaming.boot.net.http.ssl.SslContextServer;
import wxdgaming.boot.net.http.ssl.SslProtocolType;
import javax.net.ssl.SSLContext;
import java.io.Serializable;
/**
* tcp网络配置
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2021-09-30 09:33
**/
@Getter
@Setter
@Accessors(chain = true)
public class TcpConfig extends ObjectBase implements Serializable {
@JSONField(ordinal = 1)
private String name = "";
/** 外网ip */
@JSONField(ordinal = 2)
private String wanIp = "0.0.0.0";
/** 内网ip */
@JSONField(ordinal = 3)
private String host = "";
/** 监听端口 */
@JSONField(ordinal = 4)
private int port = 0;
@JSONField(ordinal = 5)
private String sslProtocolType = null;
@JSONField(ordinal = 6)
private String jks = "";
@JSONField(ordinal = 7)
private String jksPwd = "";
public SslProtocolType sslProtocolType() throws Exception {
if (StringUtil.notEmptyOrNull(sslProtocolType)) {
return SslProtocolType.of(sslProtocolType);
}
return SslProtocolType.TLSV12;
}
public SSLContext sslContext() throws Exception {
return SslContextServer.sslContext(sslProtocolType(), jks, jksPwd);
}
}

View File

@@ -0,0 +1,15 @@
package wxdgaming.boot.spring.starter.i;
import java.lang.annotation.*;
/**
* 启动
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2024-08-01 20:24
*/
@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OnClose {
}

View File

@@ -0,0 +1,15 @@
package wxdgaming.boot.spring.starter.i;
import java.lang.annotation.*;
/**
* 启动
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2024-08-01 20:24
*/
@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OnStart {
}

View File

@@ -1,6 +1,5 @@
package wxdgaming.boot.spring.starter.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import wxdgaming.boot.spring.starter.BootStarter;
@@ -14,8 +13,6 @@ import wxdgaming.boot.spring.starter.BootStarter;
@RestController
public class GMController {
@Autowired LuaService luaService;
@GetMapping("/reload/jar")
public String reload_jar() throws Exception {
BootStarter.reload();
@@ -24,7 +21,6 @@ public class GMController {
@GetMapping("/reload/lua")
public String reload_lua() throws Exception {
luaService.init();
return "reload/lua";
}

View File

@@ -14,7 +14,6 @@ import wxdgaming.boot.spring.starter.config.DataBaseConfig;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:18
**/
@Order(100)
@Component
@ConditionalOnProperty(value = "database.mysql.dbHost")
public class MysqlService extends MysqlDataHelper implements Ordered {

View File

@@ -13,7 +13,6 @@ import wxdgaming.boot.spring.starter.config.DataBaseConfig;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:18
**/
@Order(101)
@Component
@ConditionalOnProperty(value = "database.mysql1.dbHost")
public class MysqlService1 extends MysqlDataHelper {

View File

@@ -13,7 +13,6 @@ import wxdgaming.boot.spring.starter.config.DataBaseConfig;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:18
**/
@Order(102)
@Component
@ConditionalOnProperty(value = "database.mysql2.dbHost")
public class MysqlService2 extends MysqlDataHelper {

View File

@@ -14,7 +14,6 @@ import wxdgaming.boot.spring.starter.config.DataBaseConfig;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:18
**/
@Order(103)
@Component
@ConditionalOnProperty(value = "database.mysql3.dbHost")
public class MysqlService3 extends MysqlDataHelper implements Ordered {

View File

@@ -13,7 +13,6 @@ import wxdgaming.boot.spring.starter.config.DataBaseConfig;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:19
**/
@Order(200)
@Component
@ConditionalOnProperty(value = "database.redis.dbHost")
public class RedisService extends RedisDataHelper {

View File

@@ -12,7 +12,6 @@ import wxdgaming.boot.batis.redis.RedisDataHelper;
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:19
**/
@Order(201)
@Component
@ConditionalOnProperty(value = "database.redis1.dbHost")
public class RedisService1 extends RedisDataHelper {

View File

@@ -0,0 +1,49 @@
package wxdgaming.boot.spring.starter.service.net;
import io.netty.buffer.ByteBuf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import wxdgaming.boot.net.ts.TcpServer;
import wxdgaming.boot.net.ts.TcpSession;
import wxdgaming.boot.spring.starter.config.NetConfig;
import wxdgaming.boot.spring.starter.config.bean.TcpConfig;
import wxdgaming.boot.spring.starter.i.OnClose;
import wxdgaming.boot.spring.starter.i.OnStart;
/**
* tcp server
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:20
**/
@Component
@ConditionalOnProperty(value = "net-config.tcpSocket.port")
public class TsService extends TcpServer<TcpSession> {
@Autowired
public TsService(NetConfig netConfig) throws Exception {
TcpConfig config = netConfig.getTcpSocket();
setName(config.getName())
.setHost(config.getHost())
.setWanIp(config.getWanIp())
.setPort(config.getPort())
.setSslType(config.sslProtocolType())
.setSslContext(config.sslContext())
.initBootstrap();
}
@Override public void read(TcpSession session, ByteBuf byteBuf) {
super.read(session, byteBuf);
}
@OnClose
@Override public void close() {
super.close();
}
@OnStart
@Override public void open() {
super.open();
}
}

View File

@@ -0,0 +1,49 @@
package wxdgaming.boot.spring.starter.service.net;
import io.netty.buffer.ByteBuf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import wxdgaming.boot.net.ts.TcpServer;
import wxdgaming.boot.net.ts.TcpSession;
import wxdgaming.boot.spring.starter.config.NetConfig;
import wxdgaming.boot.spring.starter.config.bean.TcpConfig;
import wxdgaming.boot.spring.starter.i.OnClose;
import wxdgaming.boot.spring.starter.i.OnStart;
/**
* tcp server
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 18:20
**/
@Component
@ConditionalOnProperty(value = "net-config.tcpSocket1.port")
public class TsService1 extends TcpServer<TcpSession> {
@Autowired
public TsService1(NetConfig netConfig) throws Exception {
TcpConfig config = netConfig.getTcpSocket1();
setName(config.getName())
.setHost(config.getHost())
.setWanIp(config.getWanIp())
.setPort(config.getPort())
.setSslType(config.sslProtocolType())
.setSslContext(config.sslContext())
.initBootstrap();
}
@Override public void read(TcpSession session, ByteBuf byteBuf) {
super.read(session, byteBuf);
}
@OnClose
@Override public void close() {
super.close();
}
@OnStart
@Override public void open() {
super.open();
}
}

View File

@@ -0,0 +1,44 @@
package wxdgaming.boot.spring.starter.service.net;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import wxdgaming.boot.net.web.ws.WebSession;
import wxdgaming.boot.net.web.ws.WebSocketServer;
import wxdgaming.boot.spring.starter.config.NetConfig;
import wxdgaming.boot.spring.starter.config.bean.TcpConfig;
import wxdgaming.boot.spring.starter.i.OnClose;
import wxdgaming.boot.spring.starter.i.OnStart;
/**
* web socket service
*
* @author: wxd-gaming(無心道, 15388152619)
* @version: 2023-12-11 17:49
**/
@Order(1)
@Component
@ConditionalOnProperty(value = "net-config.webSocket.port")
public class WsService extends WebSocketServer<WebSession> {
public WsService(NetConfig netConfig) throws Exception {
TcpConfig config = netConfig.getWebSocket();
setName(config.getName())
.setHost(config.getHost())
.setWanIp(config.getWanIp())
.setPort(config.getPort())
.setSslType(config.sslProtocolType())
.setSslContext(config.sslContext())
.initBootstrap();
}
@OnClose
@Override public void close() {
super.close();
}
@OnStart
@Override public void open() {
super.open();
}
}

View File

@@ -11,6 +11,5 @@ public class B1 implements AutoCloseable {
}
@Override public void close() throws Exception {
System.out.println("\n\nclose() " + this.getClass() + "\n\n");
}
}

View File

@@ -0,0 +1,21 @@
net-config:
tcpSocket:
name: "g1"
host: "*"
wanIp: "127.0.0.1"
port: 17000
tcpSocket1:
name: "g2"
host: "*"
wanIp: "127.0.0.1"
port: 17001
webSocket:
name: "g1"
host: "*"
wanIp: "127.0.0.1"
port: 18000
sslProtocolType: "TLSv1"
jks: "jks/wxdtest-1.8.jks"
jksPwd: "jks/wxdtest-1.8.jks.pwd"

View File

@@ -6,7 +6,7 @@ server:
spring:
profiles:
active: thread,db-mysql,db-redis
active: thread,db-mysql,db-redis,net
web:
resources:
chain: