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 26368ddf140eff8807ec9b8e6b2e89a865bd0805
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Aug 23 10:23:43 2019 +0200

    CAMEL-13870: Fast property configuration of Camel endpoints.
---
 .../org/apache/camel/component/undertow/UndertowConsumer.java |  9 ++++++++-
 .../org/apache/camel/component/undertow/UndertowEndpoint.java | 11 +++++------
 .../camel-undertow/src/test/resources/HandlersSpringTest.xml  |  8 ++------
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
index 0cf1dae..a8cc099 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
@@ -46,7 +46,9 @@ import org.apache.camel.Processor;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.component.undertow.UndertowConstants.EventType;
 import org.apache.camel.component.undertow.handlers.CamelWebSocketHandler;
+import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultConsumer;
+import org.apache.camel.support.EndpointHelper;
 import org.apache.camel.util.CollectionStringBuffer;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -273,7 +275,12 @@ public class UndertowConsumer extends DefaultConsumer 
implements HttpHandler {
     
     private HttpHandler wrapHandler(HttpHandler handler, UndertowEndpoint 
endpoint) {
         HttpHandler nextHandler = handler;
-        for (CamelUndertowHttpHandler h : endpoint.getHandlers()) {
+        String[] handlders = endpoint.getHandlers().split(",");
+        for (String obj : handlders) {
+            if (EndpointHelper.isReferenceParameter(obj)) {
+                obj = obj.substring(1);
+            }
+            CamelUndertowHttpHandler h = 
CamelContextHelper.mandatoryLookup(endpoint.getCamelContext(), obj, 
CamelUndertowHttpHandler.class);
             h.setNext(nextHandler);
             nextHandler = h;
         }
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index 1cb7e85..56a1ebb 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -105,12 +105,12 @@ public class UndertowEndpoint extends DefaultEndpoint 
implements AsyncEndpoint,
     private Integer sendTimeout = 30000;
     @UriParam(label = "consumer,websocket", defaultValue = "false")
     private boolean fireWebSocketChannelEvents;
-    @UriParam(label = "consumer,advanced", javaType = "java.lang.String",
+    @UriParam(label = "consumer,advanced",
         description = "Specifies a comma-delimited set of Undertow HttpHandler 
instances to lookup in your Registry."
         + " These handlers are added to the Undertow handler chain (for 
example, to add security)."
         + " Important: You can not use different handlers with different 
Undertow endpoints using the same port number."
         + " The handlers is associated to the port number. If you need 
different handlers, then use different port numbers.")
-    private List<CamelUndertowHttpHandler> handlers;
+    private String handlers;
 
     public UndertowEndpoint(String uri, UndertowComponent component) {
         super(uri, component);
@@ -503,8 +503,8 @@ public class UndertowEndpoint extends DefaultEndpoint 
implements AsyncEndpoint,
     public void setAccessLogReceiver(AccessLogReceiver accessLogReceiver) {
         this.accessLogReceiver = accessLogReceiver;
     }
-    
-    public List<CamelUndertowHttpHandler> getHandlers() {
+
+    public String getHandlers() {
         return handlers;
     }
 
@@ -514,9 +514,8 @@ public class UndertowEndpoint extends DefaultEndpoint 
implements AsyncEndpoint,
      * Important: You can not use different handlers with different Undertow 
endpoints using the same port number.
      * The handlers is associated to the port number. If you need different 
handlers, then use different port numbers.
      */
-    public void setHandlers(List<CamelUndertowHttpHandler> handlers) {
+    public void setHandlers(String handlers) {
         this.handlers = handlers;
     }
 
-
 }
diff --git 
a/components/camel-undertow/src/test/resources/HandlersSpringTest.xml 
b/components/camel-undertow/src/test/resources/HandlersSpringTest.xml
index 34c7ff6..d44434a 100644
--- a/components/camel-undertow/src/test/resources/HandlersSpringTest.xml
+++ b/components/camel-undertow/src/test/resources/HandlersSpringTest.xml
@@ -19,12 +19,10 @@
 -->
 <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:camel="http://camel.apache.org/schema/spring";
-       xmlns:util="http://www.springframework.org/schema/util";
        xmlns="http://www.springframework.org/schema/beans";
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
-       http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd
     ">
 
     <camel:sslContextParameters id="sslContextParameters">
@@ -47,12 +45,10 @@
         </property>
     </bean>
 
-    <util:list id="handlers" value-type="io.undertow.server.HttpHandler">
-        <bean 
class="org.apache.camel.component.undertow.UndertowBasicAuthHandler"/>
-    </util:list>
+    <bean id="myHandler" 
class="org.apache.camel.component.undertow.UndertowBasicAuthHandler"/>
 
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>
-        <endpoint id="input" 
uri="undertow:http://localhost:#{dynaPort}/spring?handlers=#handlers"/>
+        <endpoint id="input" 
uri="undertow:http://localhost:#{dynaPort}/spring?handlers=#myHandler"/>
 
         <route>
             <from uri="ref:input"/>

Reply via email to