原生编译:netty spi 接口注册
This commit is contained in:
@@ -23,13 +23,6 @@
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-lib</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--solon aot start(用于 aot 时注册 native 元信息)-->
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</dependency>
|
||||
<!--solon aot end-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
+6
@@ -12,6 +12,7 @@ import io.netty.handler.timeout.IdleStateHandler;
|
||||
import org.dromara.neutrinoproxy.client.core.*;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.*;
|
||||
import org.dromara.neutrinoproxy.core.aot.NeutrinoCoreRuntimeNativeRegistrar;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.DefaultDispatcher;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
@@ -204,4 +205,9 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NeutrinoCoreRuntimeNativeRegistrar neutrinoCoreRuntimeNativeRegistrar() {
|
||||
return new NeutrinoCoreRuntimeNativeRegistrar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
<artifactId>neutrino-proxy-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!--solon aot start(用于 aot 时注册 native 元信息)-->
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</dependency>
|
||||
<!--solon aot end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package org.dromara.neutrinoproxy.core.aot;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
import org.noear.solon.aot.RuntimeNativeRegistrar;
|
||||
import org.noear.solon.aot.hint.MemberCategory;
|
||||
import org.noear.solon.core.AppContext;
|
||||
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/23 21:33
|
||||
*/
|
||||
public class NeutrinoCoreRuntimeNativeRegistrar implements RuntimeNativeRegistrar {
|
||||
@Override
|
||||
public void register(AppContext context, RuntimeNativeMetadata metadata) {
|
||||
Set<Class<?>> channelInboundClasses = ClassUtil.scanPackageBySuper("org.dromara.neutrinoproxy", SimpleChannelInboundHandler.class);
|
||||
for (Class<?> clazz : channelInboundClasses) {
|
||||
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
|
||||
Set<Class<?>> selectorProviderClasses = ClassUtil.scanPackageBySuper("org.dromara.neutrinoproxy", SelectorProvider.class);
|
||||
for (Class<?> selectorProviderClass : selectorProviderClasses) {
|
||||
metadata.registerReflection(selectorProviderClass, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
metadata.registerReflection(ProxyMessage.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
metadata.registerReflection(ProxyMessage.UdpBaseInfo.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
}
|
||||
@@ -55,13 +55,6 @@
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--solon aot start(用于 aot 时注册 native 元信息)-->
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</dependency>
|
||||
<!--solon aot end-->
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -9,10 +9,10 @@ import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.handler.traffic.ChannelTrafficShapingHandler;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.aot.NeutrinoCoreRuntimeNativeRegistrar;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.DefaultDispatcher;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -128,4 +128,9 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
return new NioEventLoopGroup(proxyConfig.getTunnel().getWorkThreadCount());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NeutrinoCoreRuntimeNativeRegistrar neutrinoCoreRuntimeNativeRegistrar() {
|
||||
return new NeutrinoCoreRuntimeNativeRegistrar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user