This commit is contained in:
crusader 2018-04-24 19:31:09 +09:00
parent d106b06371
commit 2e72227a4f

View File

@ -6,6 +6,7 @@ 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.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import io.netty.bootstrap.ServerBootstrap;
@ -22,6 +23,11 @@ import io.netty.channel.nio.NioEventLoopGroup;
*/
public abstract class Server {
private static final Logger logger = LoggerFactory.getLogger(Server.class);
public static final String CHANNEL_CLASS = "SERVER_CHANNEL_CLASS";
public static final String CHANNEL_OPTIONS = "SERVER_CHANNEL_OPTIONS";
public static final String CHANNEL_HANDLER = "SERVER_CHANNEL_HANDLER";
public static final String CHANNEL_INITIALIZER = "SERVER_CHANNEL_INITIALIZER";
public static final String SOCKET_ADDRESS = "SERVER_SOCKET_ADDRESS";
@Value("${server.netty.thread.count.boss}")
protected int threadCountBoss;
@ -29,15 +35,19 @@ public abstract class Server {
protected int threadCountWorker;
@Autowired
@Qualifier(CHANNEL_CLASS)
protected Class<? extends ServerChannel> channelClass;
@Autowired
@Qualifier(CHANNEL_OPTIONS)
protected List<ChannelOptionItem<?>> channelOptions;
@Autowired
@Qualifier(CHANNEL_HANDLER)
protected ChannelHandler channelHandler;
@Autowired
@Qualifier(CHANNEL_INITIALIZER)
protected ChannelInitializer<?> channelInitializer;
@Autowired
@Qualifier(SOCKET_ADDRESS)
protected SocketAddress address;
public void start() throws Exception {