This commit is contained in:
crusader 2018-04-24 11:51:31 +09:00
parent 57eda39031
commit 90dda2f964

View File

@ -29,12 +29,12 @@ public abstract class Server {
protected int threadCountWorker;
@Autowired
protected List<Class<? extends ServerChannel>> channelClasses;
protected Class<? extends ServerChannel> channelClass;
@Autowired
protected List<ChannelOptionItem<?>> channelOptions;
@Autowired
protected List<ChannelHandler> channelHandlers;
protected ChannelHandler channelHandler;
@Autowired
protected ChannelInitializer<?> channelInitializer;
@Autowired
@ -48,20 +48,16 @@ public abstract class Server {
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup);
if (null != this.channelClasses) {
for (Class<? extends ServerChannel> channelClass : this.channelClasses) {
serverBootstrap.channel(channelClass);
}
if (null != this.channelClass) {
serverBootstrap = serverBootstrap.channel(this.channelClass);
}
if (null != this.channelOptions) {
for (ChannelOptionItem<?> optionItem : this.channelOptions) {
optionItem.setOption(serverBootstrap);
}
}
if (null != this.channelHandlers) {
for (ChannelHandler channelHandler : this.channelHandlers) {
serverBootstrap.handler(channelHandler);
}
if (null != this.channelHandler) {
serverBootstrap.handler(this.channelHandler);
}
serverBootstrap.childHandler(this.channelInitializer);