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 2014/06/25 10:47:31 UTC

git commit: Fix for CAMEL-7530 Expose the component options for Camel CXFRS

Repository: camel
Updated Branches:
  refs/heads/master dc5a2c14a -> 0f25b1679


Fix for CAMEL-7530 Expose the component options for Camel CXFRS


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

Branch: refs/heads/master
Commit: 0f25b1679891abeffad4be2b0398a9b80b4e42fd
Parents: dc5a2c1
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Wed Jun 25 10:23:06 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Wed Jun 25 10:23:39 2014 +0200

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  |  2 +
 .../component/cxf/jaxrs/CxfRsEndpoint.java      | 15 +++++-
 ...ponentConfigurationAndDocumentationTest.java | 55 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0f25b167/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 840e997..7437990 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -1055,6 +1055,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
         // the ftp components are in a special package
         if ("ftp".equals(componentName) || "ftps".equals(componentName) || "sftp".equals(componentName)) {
             return "file/remote";
+        } else if ("cxfrs".equals(componentName)) {
+            return "cxf/jaxrs";
         }
         return componentName.replaceAll("-", "");
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/0f25b167/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index 9e9bec1..7bc6b41 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -34,6 +34,8 @@ import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -50,8 +52,8 @@ import org.apache.cxf.message.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@UriEndpoint(scheme = "cxfrs", consumerClass = CxfRsConsumer.class)
 public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware, Service {
-    
     public enum BindingStyle {
         /**
          * <i>Only available for consumers.</i>
@@ -80,17 +82,26 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
     private List<Class<?>> resourceClasses;
     private HeaderFilterStrategy headerFilterStrategy;
     private CxfRsBinding binding;
+    @UriParam
     private boolean httpClientAPI = true;
+    @UriParam
     private String address;
+    @UriParam
     private boolean throwExceptionOnFailure = true;
+    @UriParam
     private int maxClientCacheSize = 10;
+    @UriParam
     private boolean loggingFeatureEnabled;
+    @UriParam
     private int loggingSizeLimit;
+    @UriParam
     private boolean skipFaultLogging;
+    @UriParam
     private BindingStyle bindingStyle = BindingStyle.Default;
     // The continuation timeout value for CXF continuation to use
+    @UriParam
     private long continuationTimeout = 30000;
-   
+    @UriParam
     private boolean isSetDefaultBus;
     
     private List<Feature> features = new ModCountCopyOnWriteArrayList<Feature>();

http://git-wip-us.apache.org/repos/asf/camel/blob/0f25b167/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponentConfigurationAndDocumentationTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..336ad55
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.cxf.jaxrs;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CxfRsComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        CxfRsComponent comp = context.getComponent("cxfrs", CxfRsComponent.class);
+        EndpointConfiguration conf = comp.createConfiguration("cxfrs:bean:cxfEndpoint?resourceClasses=org.apache.camel.rs.Example&maxClientCacheSize=32");
+
+        assertEquals("org.apache.camel.rs.Example", conf.getParameter("resourceClasses"));
+        assertEquals("32", conf.getParameter("maxClientCacheSize"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"address\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"maxClientCacheSize\": { \"type\": \"int\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("cxfrs");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+}