Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public class NettyHttpServerEngine implements ServerEngine {
private boolean sessionSupport;

// TODO need to setup configuration about them
private EventLoopGroup bossGroup = new NioEventLoopGroup();
private EventLoopGroup workerGroup = new NioEventLoopGroup();
private EventLoopGroup bossGroup;
private EventLoopGroup workerGroup;

public NettyHttpServerEngine() {

Expand All @@ -104,20 +104,11 @@ public NettyHttpServerEngine(
this.port = port;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

@PostConstruct
public void finalizeConfig() {
// need to check if we need to any other thing other than Setting the TLSServerParameter
}


/**
* This method is used to programmatically set the TLSServerParameters.
* This method may only be called by the factory.
Expand All @@ -130,7 +121,6 @@ public void setTlsServerParameters(TLSServerParameters params) {
* This method returns the programmatically set TLSServerParameters, not
* the TLSServerParametersType, which is the JAXB generated type used
* in SpringConfiguration.
* @return
*/
public TLSServerParameters getTlsServerParameters() {
return tlsServerParameters;
Expand All @@ -145,6 +135,12 @@ public ThreadingParameters getThreadingParameters() {
}

protected Channel startServer() {
if (bossGroup == null) {
bossGroup = new NioEventLoopGroup();
}
if (workerGroup == null) {
workerGroup = new NioEventLoopGroup();
}

final ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(bossGroup, workerGroup)
Expand All @@ -161,7 +157,7 @@ protected Channel startServer() {
// Start the servletPipeline's timer
servletPipeline.start();
bootstrap.childHandler(servletPipeline);
InetSocketAddress address = null;
InetSocketAddress address;
if (host == null) {
address = new InetSocketAddress(port);
} else {
Expand All @@ -184,10 +180,8 @@ protected void checkRegistedContext(URL url) {
throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url, registedPath));
}
}

}


@Override
public void addServant(URL url, NettyHttpHandler handler) {
checkRegistedContext(url);
Expand Down Expand Up @@ -220,7 +214,6 @@ public void removeServant(URL url) {
}
}
registedPaths.remove(url.getPath());

}

@Override
Expand Down Expand Up @@ -248,9 +241,13 @@ public void shutdown() {
serverChannel.close();
}

bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();

// shutdown executors
if (bossGroup != null) {
bossGroup.shutdownGracefully();
}
if (workerGroup != null) {
workerGroup.shutdownGracefully();
}
}

public int getReadIdleTime() {
Expand Down Expand Up @@ -300,4 +297,36 @@ public void setHost(String host) {
public String getHost() {
return host;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

public void setBossGroup(EventLoopGroup bossGroup) {
if (this.bossGroup == null) {
this.bossGroup = bossGroup;
} else {
throw new IllegalStateException("bossGroup is already defined");
}
}

public EventLoopGroup getBossGroup() {
return bossGroup;
}

public void setWorkerGroup(EventLoopGroup workerGroup) {
if (this.workerGroup == null) {
this.workerGroup = workerGroup;
} else {
throw new IllegalStateException("workerGroup is already defined");
}
}

public EventLoopGroup getWorkerGroup() {
return workerGroup;
}
}