You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/06/12 09:33:02 UTC

[camel] branch master updated (de346fb -> ae2068f)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from de346fb  Upgrade Hazelcast to version 3.12.1
     new f2672e5  CAMEL-13634: Camel main - Allow to configure rest dsl configuration
     new 6ac1b1f  CAMEL-13634: Camel main - Allow to configure rest dsl configuration
     new ae2068f  CAMEL-13634: Camel main - Allow to configure rest dsl configuration

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/main/MainConfigurationProperties.java    |  22 +-
 .../java/org/apache/camel/main/MainSupport.java    |  19 +-
 .../camel/main/RestConfigurationProperties.java    | 342 +++++++++++++++++++++
 .../camel/support/PropertyBindingSupport.java      |  13 +-
 .../src/main/resources/application.properties      |   5 +
 5 files changed, 390 insertions(+), 11 deletions(-)
 create mode 100644 core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java


[camel] 03/03: CAMEL-13634: Camel main - Allow to configure rest dsl configuration

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ae2068f859e546bb89b7405a2f8c559f4beb01b1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 12 11:31:22 2019 +0200

    CAMEL-13634: Camel main - Allow to configure rest dsl configuration
---
 .../java/org/apache/camel/main/MainSupport.java    |  1 -
 .../camel/main/RestConfigurationProperties.java    | 68 ++++++++++++++++++++++
 .../camel/support/PropertyBindingSupport.java      | 13 +++--
 .../src/main/resources/application.properties      |  5 ++
 4 files changed, 80 insertions(+), 7 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index 459a95a..71d427c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -41,7 +41,6 @@ import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.rest.RestConfigurationDefinition;
 import org.apache.camel.spi.CamelBeanPostProcessor;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.EventNotifier;
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
index 9150315d..27a0899 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.main;
 
+import java.util.HashMap;
+
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.PatternHelper;
 
@@ -271,4 +273,70 @@ public class RestConfigurationProperties extends RestConfiguration {
         return this;
     }
 
+    /**
+     * Adds a component property
+     */
+    public RestConfigurationProperties withComponentProperty(String key, Object value) {
+        if (getComponentProperties() == null) {
+            setComponentProperties(new HashMap<>());
+        }
+        getComponentProperties().put(key, value);
+        return this;
+    }
+
+    /**
+     * Adds a endpoint property
+     */
+    public RestConfigurationProperties withEndpointProperty(String key, Object value) {
+        if (getEndpointProperties() == null) {
+            setEndpointProperties(new HashMap<>());
+        }
+        getEndpointProperties().put(key, value);
+        return this;
+    }
+
+    /**
+     * Adds a consumer property
+     */
+    public RestConfigurationProperties withConsumerProperty(String key, Object value) {
+        if (getConsumerProperties() == null) {
+            setConsumerProperties(new HashMap<>());
+        }
+        getConsumerProperties().put(key, value);
+        return this;
+    }
+
+    /**
+     * Adds a data format property
+     */
+    public RestConfigurationProperties withDataFormatProperty(String key, Object value) {
+        if (getDataFormatProperties() == null) {
+            setDataFormatProperties(new HashMap<>());
+        }
+        getDataFormatProperties().put(key, value);
+        return this;
+    }
+
+    /**
+     * Adds a api property
+     */
+    public RestConfigurationProperties withApiProperty(String key, Object value) {
+        if (getApiProperties() == null) {
+            setApiProperties(new HashMap<>());
+        }
+        getApiProperties().put(key, value);
+        return this;
+    }
+
+    /**
+     * Adds a CORS header property
+     */
+    public RestConfigurationProperties withCorsHeader(String key, String value) {
+        if (getCorsHeaders() == null) {
+            setCorsHeaders(new HashMap<>());
+        }
+        getCorsHeaders().put(key, value);
+        return this;
+    }
+
 }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index be3ee8f..081312f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -442,13 +442,14 @@ public final class PropertyBindingSupport {
                         Method method = findBestSetterMethod(newClass, part, fluentBuilder);
                         if (method != null) {
                             Class<?> parameterType = method.getParameterTypes()[0];
+                            Object instance = null;
                             if (parameterType != null && org.apache.camel.util.ObjectHelper.hasDefaultPublicNoArgConstructor(parameterType)) {
-                                Object instance = context.getInjector().newInstance(parameterType);
-                                if (instance != null) {
-                                    org.apache.camel.support.ObjectHelper.invokeMethod(method, newTarget, instance);
-                                    newTarget = instance;
-                                    newClass = newTarget.getClass();
-                                }
+                                instance = context.getInjector().newInstance(parameterType);
+                            }
+                            if (instance != null) {
+                                org.apache.camel.support.ObjectHelper.invokeMethod(method, newTarget, instance);
+                                newTarget = instance;
+                                newClass = newTarget.getClass();
                             }
                         }
                     } else {
diff --git a/examples/camel-example-main/src/main/resources/application.properties b/examples/camel-example-main/src/main/resources/application.properties
index 0c96fed..71ab7ab 100644
--- a/examples/camel-example-main/src/main/resources/application.properties
+++ b/examples/camel-example-main/src/main/resources/application.properties
@@ -34,6 +34,11 @@ camel.component.quartz2.start-delayed-seconds = 3
 ### camel.hystrix.group-key=myGroup
 ### camel.hystrix.execution-timeout-in-milliseconds=5000
 
+# to configure Rest DSL (global and you need to add camel-undertow to the classpath)
+### camel.rest.component=undertow
+### camel.rest.port=8080
+### camel.rest.component-properties[host-options.buffer-size]=8192
+
 # you can configure whether OS environment should override (=2 which is default) or as fallback (=1)
 ### camel.component.properties.environment-variable-mode=1
 


[camel] 02/03: CAMEL-13634: Camel main - Allow to configure rest dsl configuration

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6ac1b1f3ed4d637a83f8d60032efa3b12fe1629d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 12 10:44:12 2019 +0200

    CAMEL-13634: Camel main - Allow to configure rest dsl configuration
---
 .../camel/main/RestConfigurationProperties.java    | 386 ++-------------------
 1 file changed, 32 insertions(+), 354 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
index 6e1237a..9150315d 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
@@ -16,46 +16,16 @@
  */
 package org.apache.camel.main;
 
+import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.PatternHelper;
 
 /**
  * Global configuration for Rest DSL.
  */
-public class RestConfigurationProperties {
+public class RestConfigurationProperties extends RestConfiguration {
 
     private final MainConfigurationProperties parent;
 
-    private String component;
-    private String apiComponent;
-    private String producerComponent;
-    private String scheme;
-    private String host;
-    private String apiHost;
-    private Boolean useXForwardHeaders;
-    private String port;
-    private String producerApiDoc;
-    private String contextPath;
-    private String apiContextPath;
-    private String apiContextRouteId;
-    private String apiContextIdPattern;
-    private Boolean apiContextListing;
-    private Boolean apiVendorExtension;
-    private String hostNameResolver;
-    private String bindingMode;
-    private Boolean skipBindingOnErrorCode;
-    private Boolean clientRequestValidation;
-    private Boolean enableCORS;
-    private String jsonDataFormat;
-    private String xmlDataFormat;
-
-    // TODO: Do these later
-//    private List<RestPropertyDefinition> componentProperties = new ArrayList<>();
-//    private List<RestPropertyDefinition> endpointProperties = new ArrayList<>();
-//    private List<RestPropertyDefinition> consumerProperties = new ArrayList<>();
-//    private List<RestPropertyDefinition> dataFormatProperties = new ArrayList<>();
-//    private List<RestPropertyDefinition> apiProperties = new ArrayList<>();
-//    private List<RestPropertyDefinition> corsHeaders = new ArrayList<>();
-
     public RestConfigurationProperties(MainConfigurationProperties parent) {
         this.parent = parent;
     }
@@ -67,299 +37,7 @@ public class RestConfigurationProperties {
     // getter and setters
     // --------------------------------------------------------------
 
-    public String getComponent() {
-        return component;
-    }
-
-    /**
-     * The Camel Rest component to use for the REST transport (consumer), such as restlet, spark-rest.
-     * If no component has been explicit configured, then Camel will lookup if there is a Camel component
-     * that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry.
-     * If either one is found, then that is being used.
-     */
-    public void setComponent(String component) {
-        this.component = component;
-    }
-
-    public String getApiComponent() {
-        return apiComponent;
-    }
-
-    /**
-     * The name of the Camel component to use as the REST API (such as swagger)
-     */
-    public void setApiComponent(String apiComponent) {
-        this.apiComponent = apiComponent;
-    }
-
-    public String getProducerComponent() {
-        return producerComponent;
-    }
-
-    /**
-     * Sets the name of the Camel component to use as the REST producer
-     */
-    public void setProducerComponent(String producerComponent) {
-        this.producerComponent = producerComponent;
-    }
-
-    public String getScheme() {
-        return scheme;
-    }
-
-    /**
-     * The scheme to use for exposing the REST service. Usually http or https is supported.
-     * <p/>
-     * The default value is http
-     */
-    public void setScheme(String scheme) {
-        this.scheme = scheme;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    /**
-     * The hostname to use for exposing the REST service.
-     */
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public String getApiHost() {
-        return apiHost;
-    }
-
-    /**
-     * To use an specific hostname for the API documentation (eg swagger)
-     * <p/>
-     * This can be used to override the generated host with this configured hostname
-     */
-    public void setApiHost(String apiHost) {
-        this.apiHost = apiHost;
-    }
-
-    public Boolean getUseXForwardHeaders() {
-        return useXForwardHeaders;
-    }
-
-    /**
-     * Whether to use X-Forward headers for Host and related setting.
-     * <p/>
-     * The default value is true.
-     */
-    public void setUseXForwardHeaders(Boolean useXForwardHeaders) {
-        this.useXForwardHeaders = useXForwardHeaders;
-    }
-
-    public String getPort() {
-        return port;
-    }
-
-    /**
-     * The port number to use for exposing the REST service.
-     * Notice if you use servlet component then the port number configured here does not apply,
-     * as the port number in use is the actual port number the servlet component is using.
-     * eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf
-     * that uses port 8181 by default etc. Though in those situations setting the port number here,
-     * allows tooling and JMX to know the port number, so its recommended to set the port number
-     * to the number that the servlet engine uses.
-     */
-    public void setPort(String port) {
-        this.port = port;
-    }
-
-    public String getProducerApiDoc() {
-        return producerApiDoc;
-    }
-
-    /**
-     * Sets the location of the api document (swagger api) the REST producer will use
-     * to validate the REST uri and query parameters are valid accordingly to the api document.
-     * This requires adding camel-swagger-java to the classpath, and any miss configuration
-     * will let Camel fail on startup and report the error(s).
-     * <p/>
-     * The location of the api document is loaded from classpath by default, but you can use
-     * <tt>file:</tt> or <tt>http:</tt> to refer to resources to load from file or http url.
-     */
-    public void setProducerApiDoc(String producerApiDoc) {
-        this.producerApiDoc = producerApiDoc;
-    }
-
-    public String getContextPath() {
-        return contextPath;
-    }
-
-    /**
-     * Sets a leading context-path the REST services will be using.
-     * <p/>
-     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
-     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
-     * that includes a HTTP server.
-     */
-    public void setContextPath(String contextPath) {
-        this.contextPath = contextPath;
-    }
-
-    public String getApiContextPath() {
-        return apiContextPath;
-    }
-
-    /**
-     * Sets a leading API context-path the REST API services will be using.
-     * <p/>
-     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
-     * is deployed using a context-path.
-     */
-    public void setApiContextPath(String apiContextPath) {
-        this.apiContextPath = apiContextPath;
-    }
-
-    public String getApiContextRouteId() {
-        return apiContextRouteId;
-    }
-
-    /**
-     * Sets the route id to use for the route that services the REST API.
-     * <p/>
-     * The route will by default use an auto assigned route id.
-     */
-    public void setApiContextRouteId(String apiContextRouteId) {
-        this.apiContextRouteId = apiContextRouteId;
-    }
-
-    public String getApiContextIdPattern() {
-        return apiContextIdPattern;
-    }
-
-    /**
-     * Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.
-     * <p/>
-     * The pattern <tt>#name#</tt> refers to the CamelContext name, to match on the current CamelContext only.
-     * For any other value, the pattern uses the rules from {@link PatternHelper#matchPattern(String, String)}
-     */
-    public void setApiContextIdPattern(String apiContextIdPattern) {
-        this.apiContextIdPattern = apiContextIdPattern;
-    }
-
-    public Boolean getApiContextListing() {
-        return apiContextListing;
-    }
-
-    /**
-     * Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover
-     * these contexts, if <tt>false</tt> then only the current CamelContext is in use.
-     */
-    public void setApiContextListing(Boolean apiContextListing) {
-        this.apiContextListing = apiContextListing;
-    }
-
-    public Boolean getApiVendorExtension() {
-        return apiVendorExtension;
-    }
-
-    /**
-     * Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information
-     * as vendor extension (eg keys starting with x-) such as route ids, class names etc.
-     * Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs.
-     */
-    public void setApiVendorExtension(Boolean apiVendorExtension) {
-        this.apiVendorExtension = apiVendorExtension;
-    }
-
-    public String getHostNameResolver() {
-        return hostNameResolver;
-    }
-
-    /**
-     * If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using.
-     * The possible values are: allLocalIp, localIp, localHostName
-     */
-    public void setHostNameResolver(String hostNameResolver) {
-        this.hostNameResolver = hostNameResolver;
-    }
-
-    public String getBindingMode() {
-        return bindingMode;
-    }
-
-    /**
-     * Sets the binding mode to use.
-     * <p/>
-     * The possible values are: auto, off, json, xml, json_xml
-     * The default value is off
-     */
-    public void setBindingMode(String bindingMode) {
-        this.bindingMode = bindingMode;
-    }
-
-    public Boolean getSkipBindingOnErrorCode() {
-        return skipBindingOnErrorCode;
-    }
-
-    /**
-     * Whether to skip binding on output if there is a custom HTTP error code header.
-     * This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
-     */
-    public void setSkipBindingOnErrorCode(Boolean skipBindingOnErrorCode) {
-        this.skipBindingOnErrorCode = skipBindingOnErrorCode;
-    }
-
-    public Boolean getClientRequestValidation() {
-        return clientRequestValidation;
-    }
-
-    /**
-     * Whether to enable validation of the client request to check whether the Content-Type and Accept headers from
-     * the client is supported by the Rest-DSL configuration of its consumes/produces settings.
-     * <p/>
-     * This can be turned on, to enable this check. In case of validation error, then HTTP Status codes 415 or 406 is returned.
-     * <p/>
-     * The default value is false.
-     */
-    public void setClientRequestValidation(Boolean clientRequestValidation) {
-        this.clientRequestValidation = clientRequestValidation;
-    }
-
-    public Boolean getEnableCORS() {
-        return enableCORS;
-    }
-
-    /**
-     * Whether to enable CORS headers in the HTTP response.
-     * <p/>
-     * The default value is false.
-     */
-    public void setEnableCORS(Boolean enableCORS) {
-        this.enableCORS = enableCORS;
-    }
-
-    public String getJsonDataFormat() {
-        return jsonDataFormat;
-    }
-
-    /**
-     * Name of specific json data format to use.
-     * By default json-jackson will be used.
-     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
-     */
-    public void setJsonDataFormat(String jsonDataFormat) {
-        this.jsonDataFormat = jsonDataFormat;
-    }
-
-    public String getXmlDataFormat() {
-        return xmlDataFormat;
-    }
-
-    /**
-     * Name of specific XML data format to use.
-     * By default jaxb will be used.
-     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
-     */
-    public void setXmlDataFormat(String xmlDataFormat) {
-        this.xmlDataFormat = xmlDataFormat;
-    }
+    // these are inherited from the parent class
 
 
     // fluent builders
@@ -372,7 +50,7 @@ public class RestConfigurationProperties {
      * If either one is found, then that is being used.
      */
     public RestConfigurationProperties withComponent(String component) {
-        this.component = component;
+        setComponent(component);
         return this;
     }
 
@@ -380,7 +58,7 @@ public class RestConfigurationProperties {
      * The name of the Camel component to use as the REST API (such as swagger)
      */
     public RestConfigurationProperties withApiComponent(String apiComponent) {
-        this.apiComponent = apiComponent;
+        setApiComponent(apiComponent);
         return this;
     }
 
@@ -388,7 +66,7 @@ public class RestConfigurationProperties {
      * Sets the name of the Camel component to use as the REST producer
      */
     public RestConfigurationProperties withProducerComponent(String producerComponent) {
-        this.producerComponent = producerComponent;
+        setProducerComponent(producerComponent);
         return this;
     }
 
@@ -398,7 +76,7 @@ public class RestConfigurationProperties {
      * The default value is http
      */
     public RestConfigurationProperties withScheme(String scheme) {
-        this.scheme = scheme;
+        setScheme(scheme);
         return this;
     }
 
@@ -406,7 +84,7 @@ public class RestConfigurationProperties {
      * The hostname to use for exposing the REST service.
      */
     public RestConfigurationProperties withHost(String host) {
-        this.host = host;
+        setHost(host);
         return this;
     }
 
@@ -416,7 +94,7 @@ public class RestConfigurationProperties {
      * This can be used to override the generated host with this configured hostname
      */
     public RestConfigurationProperties withApiHost(String apiHost) {
-        this.apiHost = apiHost;
+        setApiHost(apiHost);
         return this;
     }
 
@@ -425,8 +103,8 @@ public class RestConfigurationProperties {
      * <p/>
      * The default value is true.
      */
-    public RestConfigurationProperties withUseXForwardHeaders(Boolean useXForwardHeaders) {
-        this.useXForwardHeaders = useXForwardHeaders;
+    public RestConfigurationProperties withUseXForwardHeaders(boolean useXForwardHeaders) {
+        setUseXForwardHeaders(useXForwardHeaders);
         return this;
     }
 
@@ -439,8 +117,8 @@ public class RestConfigurationProperties {
      * allows tooling and JMX to know the port number, so its recommended to set the port number
      * to the number that the servlet engine uses.
      */
-    public RestConfigurationProperties withPort(String port) {
-        this.port = port;
+    public RestConfigurationProperties withPort(int port) {
+        setPort(port);
         return this;
     }
 
@@ -454,7 +132,7 @@ public class RestConfigurationProperties {
      * <tt>file:</tt> or <tt>http:</tt> to refer to resources to load from file or http url.
      */
     public RestConfigurationProperties withProducerApiDoc(String producerApiDoc) {
-        this.producerApiDoc = producerApiDoc;
+        setProducerApiDoc(producerApiDoc);
         return this;
     }
 
@@ -466,7 +144,7 @@ public class RestConfigurationProperties {
      * that includes a HTTP server.
      */
     public RestConfigurationProperties withContextPath(String contextPath) {
-        this.contextPath = contextPath;
+        setContextPath(contextPath);
         return this;
     }
 
@@ -477,7 +155,7 @@ public class RestConfigurationProperties {
      * is deployed using a context-path.
      */
     public RestConfigurationProperties withApiContextPath(String apiContextPath) {
-        this.apiContextPath = apiContextPath;
+        setApiContextPath(apiContextPath);
         return this;
     }
 
@@ -487,7 +165,7 @@ public class RestConfigurationProperties {
      * The route will by default use an auto assigned route id.
      */
     public RestConfigurationProperties withApiContextRouteId(String apiContextRouteId) {
-        this.apiContextRouteId = apiContextRouteId;
+        setApiContextRouteId(apiContextRouteId);
         return this;
     }
 
@@ -498,7 +176,7 @@ public class RestConfigurationProperties {
      * For any other value, the pattern uses the rules from {@link PatternHelper#matchPattern(String, String)}
      */
     public RestConfigurationProperties withApiContextIdPattern(String apiContextIdPattern) {
-        this.apiContextIdPattern = apiContextIdPattern;
+        setApiContextIdPattern(apiContextIdPattern);
         return this;
     }
 
@@ -506,8 +184,8 @@ public class RestConfigurationProperties {
      * Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover
      * these contexts, if <tt>false</tt> then only the current CamelContext is in use.
      */
-    public RestConfigurationProperties withApiContextListing(Boolean apiContextListing) {
-        this.apiContextListing = apiContextListing;
+    public RestConfigurationProperties withApiContextListing(boolean apiContextListing) {
+        setApiContextListing(apiContextListing);
         return this;
     }
 
@@ -516,8 +194,8 @@ public class RestConfigurationProperties {
      * as vendor extension (eg keys starting with x-) such as route ids, class names etc.
      * Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs.
      */
-    public RestConfigurationProperties withApiVendorExtension(Boolean apiVendorExtension) {
-        this.apiVendorExtension = apiVendorExtension;
+    public RestConfigurationProperties withApiVendorExtension(boolean apiVendorExtension) {
+        setApiVendorExtension(apiVendorExtension);
         return this;
     }
 
@@ -526,7 +204,7 @@ public class RestConfigurationProperties {
      * The possible values are: allLocalIp, localIp, localHostName
      */
     public RestConfigurationProperties withHostNameResolver(String hostNameResolver) {
-        this.hostNameResolver = hostNameResolver;
+        setHostNameResolver(hostNameResolver);
         return this;
     }
 
@@ -537,7 +215,7 @@ public class RestConfigurationProperties {
      * The default value is off
      */
     public RestConfigurationProperties withBindingMode(String bindingMode) {
-        this.bindingMode = bindingMode;
+        setBindingMode(bindingMode);
         return this;
     }
 
@@ -545,8 +223,8 @@ public class RestConfigurationProperties {
      * Whether to skip binding on output if there is a custom HTTP error code header.
      * This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
      */
-    public RestConfigurationProperties withSkipBindingOnErrorCode(Boolean skipBindingOnErrorCode) {
-        this.skipBindingOnErrorCode = skipBindingOnErrorCode;
+    public RestConfigurationProperties withSkipBindingOnErrorCode(boolean skipBindingOnErrorCode) {
+        setSkipBindingOnErrorCode(skipBindingOnErrorCode);
         return this;
     }
 
@@ -558,8 +236,8 @@ public class RestConfigurationProperties {
      * <p/>
      * The default value is false.
      */
-    public RestConfigurationProperties withClientRequestValidation(Boolean clientRequestValidation) {
-        this.clientRequestValidation = clientRequestValidation;
+    public RestConfigurationProperties withClientRequestValidation(boolean clientRequestValidation) {
+        setClientRequestValidation(clientRequestValidation);
         return this;
     }
 
@@ -568,8 +246,8 @@ public class RestConfigurationProperties {
      * <p/>
      * The default value is false.
      */
-    public RestConfigurationProperties withEnableCORS(Boolean enableCORS) {
-        this.enableCORS = enableCORS;
+    public RestConfigurationProperties withEnableCORS(boolean enableCORS) {
+        setEnableCORS(enableCORS);
         return this;
     }
 
@@ -579,7 +257,7 @@ public class RestConfigurationProperties {
      * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
      */
     public RestConfigurationProperties withJsonDataFormat(String jsonDataFormat) {
-        this.jsonDataFormat = jsonDataFormat;
+        setJsonDataFormat(jsonDataFormat);
         return this;
     }
 
@@ -589,7 +267,7 @@ public class RestConfigurationProperties {
      * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
      */
     public RestConfigurationProperties withXmlDataFormat(String xmlDataFormat) {
-        this.xmlDataFormat = xmlDataFormat;
+        setXmlDataFormat(xmlDataFormat);
         return this;
     }
 


[camel] 01/03: CAMEL-13634: Camel main - Allow to configure rest dsl configuration

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f2672e5d1728cef1f81bbcdeb35bc85957cdbf3c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 12 10:40:46 2019 +0200

    CAMEL-13634: Camel main - Allow to configure rest dsl configuration
---
 .../camel/main/MainConfigurationProperties.java    |  22 +-
 .../java/org/apache/camel/main/MainSupport.java    |  20 +-
 .../camel/main/RestConfigurationProperties.java    | 596 +++++++++++++++++++++
 3 files changed, 633 insertions(+), 5 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index eb1d255..ba00f22 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -30,6 +30,24 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
 
     // extended configuration
     private final HystrixConfigurationProperties hystrixConfigurationProperties = new HystrixConfigurationProperties(this);
+    private final RestConfigurationProperties restConfigurationProperties = new RestConfigurationProperties(this);
+
+    // extended
+    // --------------------------------------------------------------
+
+    /**
+     * To configure Hystrix EIP
+     */
+    public HystrixConfigurationProperties hystrix() {
+        return hystrixConfigurationProperties;
+    }
+
+    /**
+     * To configure Rest DSL
+     */
+    public RestConfigurationProperties rest() {
+        return restConfigurationProperties;
+    }
 
     // getter and setters
     // --------------------------------------------------------------
@@ -201,8 +219,4 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
         return this;
     }
 
-    public HystrixConfigurationProperties hystrix() {
-        return hystrixConfigurationProperties;
-    }
-
 }
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index d8e1e8a..459a95a 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -41,11 +41,13 @@ import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.rest.RestConfigurationDefinition;
 import org.apache.camel.spi.CamelBeanPostProcessor;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.EventNotifier;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.LifecycleStrategySupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.service.ServiceHelper;
@@ -795,10 +797,11 @@ public abstract class MainSupport extends ServiceSupport {
         // lookup and configure SPI beans
         DefaultConfigurationConfigurer.afterPropertiesSet(camelContext);
 
-        // now configure context with additional properties
+        // now configure context/hystrix/rest with additional properties
         Properties prop = camelContext.getPropertiesComponent().loadProperties();
         Map<String, Object> properties = new LinkedHashMap<>();
         Map<String, Object> hystrixProperties = new LinkedHashMap<>();
+        Map<String, Object> restProperties = new LinkedHashMap<>();
         for (String key : prop.stringPropertyNames()) {
             if (key.startsWith("camel.context.")) {
                 // grab the value
@@ -810,6 +813,11 @@ public abstract class MainSupport extends ServiceSupport {
                 String value = prop.getProperty(key);
                 String option = key.substring(14);
                 hystrixProperties.put(option, value);
+            } else if (key.startsWith("camel.rest.")) {
+                // grab the value
+                String value = prop.getProperty(key);
+                String option = key.substring(11);
+                restProperties.put(option, value);
             }
         }
         if (!properties.isEmpty()) {
@@ -826,6 +834,16 @@ public abstract class MainSupport extends ServiceSupport {
             }
             setCamelProperties(camelContext, hystrix, hystrixProperties, true);
         }
+        if (!restProperties.isEmpty()) {
+            LOG.info("Auto configuring Rest DSL from loaded properties: {}", restProperties.size());
+            ModelCamelContext model = camelContext.adapt(ModelCamelContext.class);
+            RestConfiguration rest = model.getRestConfiguration();
+            if (rest == null) {
+                rest = new RestConfiguration();
+                model.setRestConfiguration(rest);
+            }
+            setCamelProperties(camelContext, rest, restProperties, true);
+        }
     }
 
     protected void autoConfigurationPropertiesComponent(CamelContext camelContext) throws Exception {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
new file mode 100644
index 0000000..6e1237a
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/RestConfigurationProperties.java
@@ -0,0 +1,596 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.main;
+
+import org.apache.camel.support.PatternHelper;
+
+/**
+ * Global configuration for Rest DSL.
+ */
+public class RestConfigurationProperties {
+
+    private final MainConfigurationProperties parent;
+
+    private String component;
+    private String apiComponent;
+    private String producerComponent;
+    private String scheme;
+    private String host;
+    private String apiHost;
+    private Boolean useXForwardHeaders;
+    private String port;
+    private String producerApiDoc;
+    private String contextPath;
+    private String apiContextPath;
+    private String apiContextRouteId;
+    private String apiContextIdPattern;
+    private Boolean apiContextListing;
+    private Boolean apiVendorExtension;
+    private String hostNameResolver;
+    private String bindingMode;
+    private Boolean skipBindingOnErrorCode;
+    private Boolean clientRequestValidation;
+    private Boolean enableCORS;
+    private String jsonDataFormat;
+    private String xmlDataFormat;
+
+    // TODO: Do these later
+//    private List<RestPropertyDefinition> componentProperties = new ArrayList<>();
+//    private List<RestPropertyDefinition> endpointProperties = new ArrayList<>();
+//    private List<RestPropertyDefinition> consumerProperties = new ArrayList<>();
+//    private List<RestPropertyDefinition> dataFormatProperties = new ArrayList<>();
+//    private List<RestPropertyDefinition> apiProperties = new ArrayList<>();
+//    private List<RestPropertyDefinition> corsHeaders = new ArrayList<>();
+
+    public RestConfigurationProperties(MainConfigurationProperties parent) {
+        this.parent = parent;
+    }
+
+    public MainConfigurationProperties end() {
+        return parent;
+    }
+
+    // getter and setters
+    // --------------------------------------------------------------
+
+    public String getComponent() {
+        return component;
+    }
+
+    /**
+     * The Camel Rest component to use for the REST transport (consumer), such as restlet, spark-rest.
+     * If no component has been explicit configured, then Camel will lookup if there is a Camel component
+     * that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry.
+     * If either one is found, then that is being used.
+     */
+    public void setComponent(String component) {
+        this.component = component;
+    }
+
+    public String getApiComponent() {
+        return apiComponent;
+    }
+
+    /**
+     * The name of the Camel component to use as the REST API (such as swagger)
+     */
+    public void setApiComponent(String apiComponent) {
+        this.apiComponent = apiComponent;
+    }
+
+    public String getProducerComponent() {
+        return producerComponent;
+    }
+
+    /**
+     * Sets the name of the Camel component to use as the REST producer
+     */
+    public void setProducerComponent(String producerComponent) {
+        this.producerComponent = producerComponent;
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+
+    /**
+     * The scheme to use for exposing the REST service. Usually http or https is supported.
+     * <p/>
+     * The default value is http
+     */
+    public void setScheme(String scheme) {
+        this.scheme = scheme;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * The hostname to use for exposing the REST service.
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getApiHost() {
+        return apiHost;
+    }
+
+    /**
+     * To use an specific hostname for the API documentation (eg swagger)
+     * <p/>
+     * This can be used to override the generated host with this configured hostname
+     */
+    public void setApiHost(String apiHost) {
+        this.apiHost = apiHost;
+    }
+
+    public Boolean getUseXForwardHeaders() {
+        return useXForwardHeaders;
+    }
+
+    /**
+     * Whether to use X-Forward headers for Host and related setting.
+     * <p/>
+     * The default value is true.
+     */
+    public void setUseXForwardHeaders(Boolean useXForwardHeaders) {
+        this.useXForwardHeaders = useXForwardHeaders;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    /**
+     * The port number to use for exposing the REST service.
+     * Notice if you use servlet component then the port number configured here does not apply,
+     * as the port number in use is the actual port number the servlet component is using.
+     * eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf
+     * that uses port 8181 by default etc. Though in those situations setting the port number here,
+     * allows tooling and JMX to know the port number, so its recommended to set the port number
+     * to the number that the servlet engine uses.
+     */
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getProducerApiDoc() {
+        return producerApiDoc;
+    }
+
+    /**
+     * Sets the location of the api document (swagger api) the REST producer will use
+     * to validate the REST uri and query parameters are valid accordingly to the api document.
+     * This requires adding camel-swagger-java to the classpath, and any miss configuration
+     * will let Camel fail on startup and report the error(s).
+     * <p/>
+     * The location of the api document is loaded from classpath by default, but you can use
+     * <tt>file:</tt> or <tt>http:</tt> to refer to resources to load from file or http url.
+     */
+    public void setProducerApiDoc(String producerApiDoc) {
+        this.producerApiDoc = producerApiDoc;
+    }
+
+    public String getContextPath() {
+        return contextPath;
+    }
+
+    /**
+     * Sets a leading context-path the REST services will be using.
+     * <p/>
+     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
+     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
+     * that includes a HTTP server.
+     */
+    public void setContextPath(String contextPath) {
+        this.contextPath = contextPath;
+    }
+
+    public String getApiContextPath() {
+        return apiContextPath;
+    }
+
+    /**
+     * Sets a leading API context-path the REST API services will be using.
+     * <p/>
+     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
+     * is deployed using a context-path.
+     */
+    public void setApiContextPath(String apiContextPath) {
+        this.apiContextPath = apiContextPath;
+    }
+
+    public String getApiContextRouteId() {
+        return apiContextRouteId;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     */
+    public void setApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+    }
+
+    public String getApiContextIdPattern() {
+        return apiContextIdPattern;
+    }
+
+    /**
+     * Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.
+     * <p/>
+     * The pattern <tt>#name#</tt> refers to the CamelContext name, to match on the current CamelContext only.
+     * For any other value, the pattern uses the rules from {@link PatternHelper#matchPattern(String, String)}
+     */
+    public void setApiContextIdPattern(String apiContextIdPattern) {
+        this.apiContextIdPattern = apiContextIdPattern;
+    }
+
+    public Boolean getApiContextListing() {
+        return apiContextListing;
+    }
+
+    /**
+     * Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover
+     * these contexts, if <tt>false</tt> then only the current CamelContext is in use.
+     */
+    public void setApiContextListing(Boolean apiContextListing) {
+        this.apiContextListing = apiContextListing;
+    }
+
+    public Boolean getApiVendorExtension() {
+        return apiVendorExtension;
+    }
+
+    /**
+     * Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information
+     * as vendor extension (eg keys starting with x-) such as route ids, class names etc.
+     * Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs.
+     */
+    public void setApiVendorExtension(Boolean apiVendorExtension) {
+        this.apiVendorExtension = apiVendorExtension;
+    }
+
+    public String getHostNameResolver() {
+        return hostNameResolver;
+    }
+
+    /**
+     * If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using.
+     * The possible values are: allLocalIp, localIp, localHostName
+     */
+    public void setHostNameResolver(String hostNameResolver) {
+        this.hostNameResolver = hostNameResolver;
+    }
+
+    public String getBindingMode() {
+        return bindingMode;
+    }
+
+    /**
+     * Sets the binding mode to use.
+     * <p/>
+     * The possible values are: auto, off, json, xml, json_xml
+     * The default value is off
+     */
+    public void setBindingMode(String bindingMode) {
+        this.bindingMode = bindingMode;
+    }
+
+    public Boolean getSkipBindingOnErrorCode() {
+        return skipBindingOnErrorCode;
+    }
+
+    /**
+     * Whether to skip binding on output if there is a custom HTTP error code header.
+     * This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
+     */
+    public void setSkipBindingOnErrorCode(Boolean skipBindingOnErrorCode) {
+        this.skipBindingOnErrorCode = skipBindingOnErrorCode;
+    }
+
+    public Boolean getClientRequestValidation() {
+        return clientRequestValidation;
+    }
+
+    /**
+     * Whether to enable validation of the client request to check whether the Content-Type and Accept headers from
+     * the client is supported by the Rest-DSL configuration of its consumes/produces settings.
+     * <p/>
+     * This can be turned on, to enable this check. In case of validation error, then HTTP Status codes 415 or 406 is returned.
+     * <p/>
+     * The default value is false.
+     */
+    public void setClientRequestValidation(Boolean clientRequestValidation) {
+        this.clientRequestValidation = clientRequestValidation;
+    }
+
+    public Boolean getEnableCORS() {
+        return enableCORS;
+    }
+
+    /**
+     * Whether to enable CORS headers in the HTTP response.
+     * <p/>
+     * The default value is false.
+     */
+    public void setEnableCORS(Boolean enableCORS) {
+        this.enableCORS = enableCORS;
+    }
+
+    public String getJsonDataFormat() {
+        return jsonDataFormat;
+    }
+
+    /**
+     * Name of specific json data format to use.
+     * By default json-jackson will be used.
+     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
+     */
+    public void setJsonDataFormat(String jsonDataFormat) {
+        this.jsonDataFormat = jsonDataFormat;
+    }
+
+    public String getXmlDataFormat() {
+        return xmlDataFormat;
+    }
+
+    /**
+     * Name of specific XML data format to use.
+     * By default jaxb will be used.
+     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
+     */
+    public void setXmlDataFormat(String xmlDataFormat) {
+        this.xmlDataFormat = xmlDataFormat;
+    }
+
+
+    // fluent builders
+    // --------------------------------------------------------------
+
+    /**
+     * The Camel Rest component to use for the REST transport (consumer), such as restlet, spark-rest.
+     * If no component has been explicit configured, then Camel will lookup if there is a Camel component
+     * that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry.
+     * If either one is found, then that is being used.
+     */
+    public RestConfigurationProperties withComponent(String component) {
+        this.component = component;
+        return this;
+    }
+
+    /**
+     * The name of the Camel component to use as the REST API (such as swagger)
+     */
+    public RestConfigurationProperties withApiComponent(String apiComponent) {
+        this.apiComponent = apiComponent;
+        return this;
+    }
+
+    /**
+     * Sets the name of the Camel component to use as the REST producer
+     */
+    public RestConfigurationProperties withProducerComponent(String producerComponent) {
+        this.producerComponent = producerComponent;
+        return this;
+    }
+
+    /**
+     * The scheme to use for exposing the REST service. Usually http or https is supported.
+     * <p/>
+     * The default value is http
+     */
+    public RestConfigurationProperties withScheme(String scheme) {
+        this.scheme = scheme;
+        return this;
+    }
+
+    /**
+     * The hostname to use for exposing the REST service.
+     */
+    public RestConfigurationProperties withHost(String host) {
+        this.host = host;
+        return this;
+    }
+
+    /**
+     * To use an specific hostname for the API documentation (eg swagger)
+     * <p/>
+     * This can be used to override the generated host with this configured hostname
+     */
+    public RestConfigurationProperties withApiHost(String apiHost) {
+        this.apiHost = apiHost;
+        return this;
+    }
+
+    /**
+     * Whether to use X-Forward headers for Host and related setting.
+     * <p/>
+     * The default value is true.
+     */
+    public RestConfigurationProperties withUseXForwardHeaders(Boolean useXForwardHeaders) {
+        this.useXForwardHeaders = useXForwardHeaders;
+        return this;
+    }
+
+    /**
+     * The port number to use for exposing the REST service.
+     * Notice if you use servlet component then the port number configured here does not apply,
+     * as the port number in use is the actual port number the servlet component is using.
+     * eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf
+     * that uses port 8181 by default etc. Though in those situations setting the port number here,
+     * allows tooling and JMX to know the port number, so its recommended to set the port number
+     * to the number that the servlet engine uses.
+     */
+    public RestConfigurationProperties withPort(String port) {
+        this.port = port;
+        return this;
+    }
+
+    /**
+     * Sets the location of the api document (swagger api) the REST producer will use
+     * to validate the REST uri and query parameters are valid accordingly to the api document.
+     * This requires adding camel-swagger-java to the classpath, and any miss configuration
+     * will let Camel fail on startup and report the error(s).
+     * <p/>
+     * The location of the api document is loaded from classpath by default, but you can use
+     * <tt>file:</tt> or <tt>http:</tt> to refer to resources to load from file or http url.
+     */
+    public RestConfigurationProperties withProducerApiDoc(String producerApiDoc) {
+        this.producerApiDoc = producerApiDoc;
+        return this;
+    }
+
+    /**
+     * Sets a leading context-path the REST services will be using.
+     * <p/>
+     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
+     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
+     * that includes a HTTP server.
+     */
+    public RestConfigurationProperties withContextPath(String contextPath) {
+        this.contextPath = contextPath;
+        return this;
+    }
+
+    /**
+     * Sets a leading API context-path the REST API services will be using.
+     * <p/>
+     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
+     * is deployed using a context-path.
+     */
+    public RestConfigurationProperties withApiContextPath(String apiContextPath) {
+        this.apiContextPath = apiContextPath;
+        return this;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     */
+    public RestConfigurationProperties withApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+        return this;
+    }
+
+    /**
+     * Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.
+     * <p/>
+     * The pattern <tt>#name#</tt> refers to the CamelContext name, to match on the current CamelContext only.
+     * For any other value, the pattern uses the rules from {@link PatternHelper#matchPattern(String, String)}
+     */
+    public RestConfigurationProperties withApiContextIdPattern(String apiContextIdPattern) {
+        this.apiContextIdPattern = apiContextIdPattern;
+        return this;
+    }
+
+    /**
+     * Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover
+     * these contexts, if <tt>false</tt> then only the current CamelContext is in use.
+     */
+    public RestConfigurationProperties withApiContextListing(Boolean apiContextListing) {
+        this.apiContextListing = apiContextListing;
+        return this;
+    }
+
+    /**
+     * Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information
+     * as vendor extension (eg keys starting with x-) such as route ids, class names etc.
+     * Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs.
+     */
+    public RestConfigurationProperties withApiVendorExtension(Boolean apiVendorExtension) {
+        this.apiVendorExtension = apiVendorExtension;
+        return this;
+    }
+
+    /**
+     * If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using.
+     * The possible values are: allLocalIp, localIp, localHostName
+     */
+    public RestConfigurationProperties withHostNameResolver(String hostNameResolver) {
+        this.hostNameResolver = hostNameResolver;
+        return this;
+    }
+
+    /**
+     * Sets the binding mode to use.
+     * <p/>
+     * The possible values are: auto, off, json, xml, json_xml
+     * The default value is off
+     */
+    public RestConfigurationProperties withBindingMode(String bindingMode) {
+        this.bindingMode = bindingMode;
+        return this;
+    }
+
+    /**
+     * Whether to skip binding on output if there is a custom HTTP error code header.
+     * This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
+     */
+    public RestConfigurationProperties withSkipBindingOnErrorCode(Boolean skipBindingOnErrorCode) {
+        this.skipBindingOnErrorCode = skipBindingOnErrorCode;
+        return this;
+    }
+
+    /**
+     * Whether to enable validation of the client request to check whether the Content-Type and Accept headers from
+     * the client is supported by the Rest-DSL configuration of its consumes/produces settings.
+     * <p/>
+     * This can be turned on, to enable this check. In case of validation error, then HTTP Status codes 415 or 406 is returned.
+     * <p/>
+     * The default value is false.
+     */
+    public RestConfigurationProperties withClientRequestValidation(Boolean clientRequestValidation) {
+        this.clientRequestValidation = clientRequestValidation;
+        return this;
+    }
+
+    /**
+     * Whether to enable CORS headers in the HTTP response.
+     * <p/>
+     * The default value is false.
+     */
+    public RestConfigurationProperties withEnableCORS(Boolean enableCORS) {
+        this.enableCORS = enableCORS;
+        return this;
+    }
+
+    /**
+     * Name of specific json data format to use.
+     * By default json-jackson will be used.
+     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
+     */
+    public RestConfigurationProperties withJsonDataFormat(String jsonDataFormat) {
+        this.jsonDataFormat = jsonDataFormat;
+        return this;
+    }
+
+    /**
+     * Name of specific XML data format to use.
+     * By default jaxb will be used.
+     * Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
+     */
+    public RestConfigurationProperties withXmlDataFormat(String xmlDataFormat) {
+        this.xmlDataFormat = xmlDataFormat;
+        return this;
+    }
+
+}