cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: setter for bossGroup and workerGroup This closes #274
Date Thu, 25 May 2017 19:30:51 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 1523ba650 -> 35ab874f8


setter for bossGroup and workerGroup
This closes #274


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/35ab874f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/35ab874f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/35ab874f

Branch: refs/heads/master
Commit: 35ab874f8a1b2ad4fe045e48465c9bdeb46f685f
Parents: 1523ba6
Author: Maxim Samoylych <msamoylych@sberbank-tele.com>
Authored: Thu May 25 14:47:06 2017 +0300
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu May 25 15:26:56 2017 -0400

----------------------------------------------------------------------
 .../netty/server/NettyHttpServerEngine.java     | 67 ++++++++++++++------
 1 file changed, 48 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/35ab874f/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
index 5eabf3d..878f5b4 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
@@ -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() {
 
@@ -104,20 +104,11 @@ public class NettyHttpServerEngine implements ServerEngine {
         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.
@@ -130,7 +121,6 @@ public class NettyHttpServerEngine implements ServerEngine {
      * 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;
@@ -145,6 +135,12 @@ public class NettyHttpServerEngine implements ServerEngine {
     }
 
     protected Channel startServer() {
+        if (bossGroup == null) {
+            bossGroup = new NioEventLoopGroup();
+        }
+        if (workerGroup == null) {
+            workerGroup = new NioEventLoopGroup();
+        }
 
         final ServerBootstrap bootstrap = new ServerBootstrap();
         bootstrap.group(bossGroup, workerGroup)
@@ -161,7 +157,7 @@ public class NettyHttpServerEngine implements ServerEngine {
         // Start the servletPipeline's timer
         servletPipeline.start();
         bootstrap.childHandler(servletPipeline);
-        InetSocketAddress address = null;
+        InetSocketAddress address;
         if (host == null) {
             address = new InetSocketAddress(port);
         } else {
@@ -184,10 +180,8 @@ public class NettyHttpServerEngine implements ServerEngine {
                 throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url,
registedPath));
             }
         }
-
     }
 
-
     @Override
     public void addServant(URL url, NettyHttpHandler handler) {
         checkRegistedContext(url);
@@ -220,7 +214,6 @@ public class NettyHttpServerEngine implements ServerEngine {
             }
         }
         registedPaths.remove(url.getPath());
-
     }
 
     @Override
@@ -248,9 +241,13 @@ public class NettyHttpServerEngine implements ServerEngine {
             serverChannel.close();
         }
 
-        bossGroup.shutdownGracefully();
-        workerGroup.shutdownGracefully();
-
+        // shutdown executors
+        if (bossGroup != null) {
+            bossGroup.shutdownGracefully();
+        }
+        if (workerGroup != null) {
+            workerGroup.shutdownGracefully();
+        }
     }
 
     public int getReadIdleTime() {
@@ -300,4 +297,36 @@ public class NettyHttpServerEngine implements ServerEngine {
     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;
+    }
 }


Mime
View raw message