ing
This commit is contained in:
parent
5305a64420
commit
68763a3c73
|
@ -3,6 +3,8 @@ package com.loafle.commons.server;
|
|||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
|
@ -19,13 +21,15 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
|||
* Server
|
||||
*/
|
||||
public abstract class Server {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Server.class);
|
||||
|
||||
@Value("${server.netty.thread.count.boss}")
|
||||
protected int threadCountBoss;
|
||||
@Value("${server.netty.thread.count.worker}")
|
||||
protected int threadCountWorker;
|
||||
|
||||
@Autowired
|
||||
protected List<Class<ServerChannel>> channelClasses;
|
||||
protected List<Class<? extends ServerChannel>> channelClasses;
|
||||
|
||||
@Autowired
|
||||
protected List<ChannelOptionItem<?>> channelOptions;
|
||||
|
@ -45,7 +49,7 @@ public abstract class Server {
|
|||
serverBootstrap.group(bossGroup, workerGroup);
|
||||
|
||||
if (null != this.channelClasses) {
|
||||
for (Class<ServerChannel> channelClass : this.channelClasses) {
|
||||
for (Class<? extends ServerChannel> channelClass : this.channelClasses) {
|
||||
serverBootstrap.channel(channelClass);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +72,7 @@ public abstract class Server {
|
|||
|
||||
f.channel().closeFuture().sync();
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.error("Server", e);
|
||||
} finally {
|
||||
this.onStop();
|
||||
bossGroup.shutdownGracefully();
|
||||
|
|
Loading…
Reference in New Issue
Block a user