Repository: camel
Updated Branches:
  refs/heads/master 2a41b2327 -> 0ec853096


CAMEL-10565: configure host options in undertow


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0ec85309
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0ec85309
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0ec85309

Branch: refs/heads/master
Commit: 0ec853096a41909bc613066a825f2a8f23ec4854
Parents: 2a41b23
Author: Nicola Ferraro <ni.ferr...@gmail.com>
Authored: Fri Mar 24 13:13:00 2017 +0100
Committer: Nicola Ferraro <ni.ferr...@gmail.com>
Committed: Fri Mar 24 13:13:07 2017 +0100

----------------------------------------------------------------------
 .../src/main/docs/undertow-component.adoc       |  3 +-
 .../component/undertow/DefaultUndertowHost.java | 23 +++++
 .../component/undertow/UndertowComponent.java   | 16 +++-
 .../component/undertow/UndertowHostOptions.java | 90 ++++++++++++++++++++
 .../UndertowComponentConfiguration.java         | 65 ++++++++++++++
 5 files changed, 195 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0ec85309/components/camel-undertow/src/main/docs/undertow-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/docs/undertow-component.adoc 
b/components/camel-undertow/src/main/docs/undertow-component.adoc
index d85d7c2..68fdea4 100644
--- a/components/camel-undertow/src/main/docs/undertow-component.adoc
+++ b/components/camel-undertow/src/main/docs/undertow-component.adoc
@@ -38,7 +38,7 @@ You can append query options to the URI in the following 
format,
 
 
 // component options: START
-The Undertow component supports 3 options which are listed below.
+The Undertow component supports 4 options which are listed below.
 
 
 
@@ -47,6 +47,7 @@ The Undertow component supports 3 options which are listed 
below.
 | Name | Description | Default | Type
 | **undertowHttpBinding** (advanced) | To use a custom HttpBinding to control 
the mapping between Camel message and HttpClient. |  | UndertowHttpBinding
 | **sslContextParameters** (security) | To configure security using 
SSLContextParameters |  | SSLContextParameters
+| **hostOptions** (advanced) | To configure common options such as thread 
pools |  | UndertowHostOptions
 | **resolveProperty Placeholders** (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |=======================================================================
 // component options: END

http://git-wip-us.apache.org/repos/asf/camel/blob/0ec85309/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
----------------------------------------------------------------------
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
index f77b18c..88ef8a1 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
@@ -17,8 +17,10 @@
 package org.apache.camel.component.undertow;
 
 import java.net.URI;
+
 import io.undertow.Undertow;
 import io.undertow.server.HttpHandler;
+
 import org.apache.camel.component.undertow.handlers.CamelRootHandler;
 import org.apache.camel.component.undertow.handlers.NotFoundHandler;
 import org.slf4j.Logger;
@@ -31,12 +33,18 @@ public class DefaultUndertowHost implements UndertowHost {
     private static final Logger LOG = 
LoggerFactory.getLogger(DefaultUndertowHost.class);
 
     private UndertowHostKey key;
+    private UndertowHostOptions options;
     private CamelRootHandler rootHandler;
     private Undertow undertow;
     private String hostString;
 
     public DefaultUndertowHost(UndertowHostKey key) {
+        this(key, null);
+    }
+
+    public DefaultUndertowHost(UndertowHostKey key, UndertowHostOptions 
options) {
         this.key = key;
+        this.options = options;
         rootHandler = new CamelRootHandler(new NotFoundHandler());
     }
 
@@ -55,6 +63,21 @@ public class DefaultUndertowHost implements UndertowHost {
                 builder.addHttpListener(key.getPort(), key.getHost());
             }
 
+            if (options != null) {
+                if (options.getIoThreads() != null) {
+                    builder.setIoThreads(options.getIoThreads());
+                }
+                if (options.getWorkerThreads() != null) {
+                    builder.setWorkerThreads(options.getWorkerThreads());
+                }
+                if (options.getBufferSize() != null) {
+                    builder.setBufferSize(options.getBufferSize());
+                }
+                if (options.getDirectBuffers() != null) {
+                    builder.setDirectBuffers(options.getDirectBuffers());
+                }
+            }
+
             undertow = builder.setHandler(rootHandler).build();
             LOG.info("Starting Undertow server on {}://{}:{}", 
key.getSslContext() != null ? "https" : "http", key.getHost(), key.getPort());
             undertow.start();

http://git-wip-us.apache.org/repos/asf/camel/blob/0ec85309/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 494d5ec..09d2ee0 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -57,6 +57,8 @@ public class UndertowComponent extends UriEndpointComponent 
implements RestConsu
     private UndertowHttpBinding undertowHttpBinding;
     @Metadata(label = "security")
     private SSLContextParameters sslContextParameters;
+    @Metadata(label = "advanced")
+    private UndertowHostOptions hostOptions;
 
     public UndertowComponent() {
         super(UndertowEndpoint.class);
@@ -287,7 +289,7 @@ public class UndertowComponent extends UriEndpointComponent 
implements RestConsu
     }
 
     protected UndertowHost createUndertowHost(UndertowHostKey key) {
-        return new DefaultUndertowHost(key);
+        return new DefaultUndertowHost(key, hostOptions);
     }
 
     public UndertowHttpBinding getUndertowHttpBinding() {
@@ -312,4 +314,16 @@ public class UndertowComponent extends 
UriEndpointComponent implements RestConsu
         this.sslContextParameters = sslContextParameters;
     }
 
+
+    public UndertowHostOptions getHostOptions() {
+        return hostOptions;
+    }
+
+    /**
+     * To configure common options, such as thread pools
+     */
+    public void setHostOptions(UndertowHostOptions hostOptions) {
+        this.hostOptions = hostOptions;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0ec85309/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHostOptions.java
----------------------------------------------------------------------
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHostOptions.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHostOptions.java
new file mode 100644
index 0000000..fb50ba9
--- /dev/null
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHostOptions.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.undertow;
+
+/**
+ * Options to configure an Undertow host.
+ */
+public final class UndertowHostOptions {
+
+    /**
+     * The number of worker threads to use in a Undertow host.
+     */
+    private Integer workerThreads;
+
+    /**
+     * The number of io threads to use in a Undertow host.
+     */
+    private Integer ioThreads;
+
+    /**
+     * The buffer size of the Undertow host.
+     */
+    private Integer bufferSize;
+
+    /**
+     * Set if the Undertow host should use direct buffers.
+     */
+    private Boolean directBuffers;
+
+    public UndertowHostOptions() {
+    }
+
+    public Integer getWorkerThreads() {
+        return workerThreads;
+    }
+
+    public void setWorkerThreads(Integer workerThreads) {
+        this.workerThreads = workerThreads;
+    }
+
+    public Integer getIoThreads() {
+        return ioThreads;
+    }
+
+    public void setIoThreads(Integer ioThreads) {
+        this.ioThreads = ioThreads;
+    }
+
+    public Integer getBufferSize() {
+        return bufferSize;
+    }
+
+    public void setBufferSize(Integer bufferSize) {
+        this.bufferSize = bufferSize;
+    }
+
+    public Boolean getDirectBuffers() {
+        return directBuffers;
+    }
+
+    public void setDirectBuffers(Boolean directBuffers) {
+        this.directBuffers = directBuffers;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("UndertowHostOptions{");
+        sb.append("workerThreads=").append(workerThreads);
+        sb.append(", ioThreads=").append(ioThreads);
+        sb.append(", bufferSize=").append(bufferSize);
+        sb.append(", directBuffers=").append(directBuffers);
+        sb.append('}');
+        return sb.toString();
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0ec85309/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
----------------------------------------------------------------------
diff --git 
a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
index 959d7e3..04f494e 100644
--- 
a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
@@ -42,6 +42,10 @@ public class UndertowComponentConfiguration {
     @NestedConfigurationProperty
     private SSLContextParameters sslContextParameters;
     /**
+     * To configure common options such as thread pools
+     */
+    private UndertowHostOptionsNestedConfiguration hostOptions;
+    /**
      * Whether the component should resolve property placeholders on itself 
when
      * starting. Only properties which are of String type can use property
      * placeholders.
@@ -65,6 +69,15 @@ public class UndertowComponentConfiguration {
         this.sslContextParameters = sslContextParameters;
     }
 
+    public UndertowHostOptionsNestedConfiguration getHostOptions() {
+        return hostOptions;
+    }
+
+    public void setHostOptions(
+            UndertowHostOptionsNestedConfiguration hostOptions) {
+        this.hostOptions = hostOptions;
+    }
+
     public Boolean getResolvePropertyPlaceholders() {
         return resolvePropertyPlaceholders;
     }
@@ -73,4 +86,56 @@ public class UndertowComponentConfiguration {
             Boolean resolvePropertyPlaceholders) {
         this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
     }
+
+    public static class UndertowHostOptionsNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = 
org.apache.camel.component.undertow.UndertowHostOptions.class;
+        /**
+         * The number of worker threads to use in a Undertow host.
+         */
+        private Integer workerThreads;
+        /**
+         * The number of io threads to use in a Undertow host.
+         */
+        private Integer ioThreads;
+        /**
+         * The buffer size of the Undertow host.
+         */
+        private Integer bufferSize;
+        /**
+         * Set if the Undertow host should use direct buffers.
+         */
+        private Boolean directBuffers;
+
+        public Integer getWorkerThreads() {
+            return workerThreads;
+        }
+
+        public void setWorkerThreads(Integer workerThreads) {
+            this.workerThreads = workerThreads;
+        }
+
+        public Integer getIoThreads() {
+            return ioThreads;
+        }
+
+        public void setIoThreads(Integer ioThreads) {
+            this.ioThreads = ioThreads;
+        }
+
+        public Integer getBufferSize() {
+            return bufferSize;
+        }
+
+        public void setBufferSize(Integer bufferSize) {
+            this.bufferSize = bufferSize;
+        }
+
+        public Boolean getDirectBuffers() {
+            return directBuffers;
+        }
+
+        public void setDirectBuffers(Boolean directBuffers) {
+            this.directBuffers = directBuffers;
+        }
+    }
 }
\ No newline at end of file

Reply via email to