diff --git a/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java b/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java index cd08911..948786b 100644 --- a/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java +++ b/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java @@ -18,7 +18,9 @@ import com.loafle.overflow.container.server.handler.RPCServerHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelInitializer; @@ -34,6 +36,8 @@ import io.netty.handler.logging.LoggingHandler; * ContainerConfiguration */ @Configuration +@ComponentScan(basePackages = { "com.loafle.overflow" }) +@PropertySource({ "classpath:netty.properties"}) public class ContainerConfiguration { @Autowired @Qualifier(Container.PIPELINE_CHANNEL_HANDLERS) @@ -42,20 +46,17 @@ public class ContainerConfiguration { @Autowired(required=false) private Gson gson; - @Bean() - @Qualifier(Server.CHANNEL_CLASS) + @Bean(Server.CHANNEL_CLASS) public Class channelClass() { return NioServerSocketChannel.class; } - @Bean - @Qualifier(Server.CHANNEL_OPTIONS) + @Bean(Server.CHANNEL_OPTIONS) public List> channelOptions() { return Arrays.asList(new Server.ChannelOptionItem<>(ChannelOption.SO_BACKLOG, 100)); } - @Bean - @Qualifier(Server.CHANNEL_HANDLER) + @Bean(Server.CHANNEL_HANDLER) public ChannelHandler channelHandler() { return new LoggingHandler(LogLevel.INFO); } @@ -74,8 +75,7 @@ public class ContainerConfiguration { return new POJORPCRegistry(); } - @Bean - @Qualifier(Server.CHANNEL_INITIALIZER) + @Bean(Server.CHANNEL_INITIALIZER) public ChannelInitializer channelInitializer() { return new ChannelInitializer() { @Override @@ -90,8 +90,7 @@ public class ContainerConfiguration { }; } - @Bean - @Qualifier(Server.SOCKET_ADDRESS) + @Bean(Server.SOCKET_ADDRESS) public SocketAddress address() { return new InetSocketAddress("127.0.0.1", 60000); } diff --git a/src/main/resources/netty.properties b/src/main/resources/netty.properties new file mode 100644 index 0000000..d59d276 --- /dev/null +++ b/src/main/resources/netty.properties @@ -0,0 +1,2 @@ +server.netty.thread.count.boss=1 +server.netty.thread.count.worker=10 \ No newline at end of file