Repository: camel
Updated Branches:
  refs/heads/master 7761061fa -> 25cfae1f3


CAMEL-7999: Component json schema should favor the built time generated that is 
richer.


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

Branch: refs/heads/master
Commit: dac574d0b7fec2ffd2712dea4c8da773a66c7bf2
Parents: 7761061
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Nov 12 10:39:35 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Nov 12 12:07:25 2014 +0100

----------------------------------------------------------------------
 .../camel/impl/ComponentConfigurationSupport.java       | 12 ++++++++++++
 ...TimerComponentConfigurationAndDocumentationTest.java |  1 +
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dac574d0/camel-core/src/main/java/org/apache/camel/impl/ComponentConfigurationSupport.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/ComponentConfigurationSupport.java
 
b/camel-core/src/main/java/org/apache/camel/impl/ComponentConfigurationSupport.java
index 40f190c..8e34e42 100644
--- 
a/camel-core/src/main/java/org/apache/camel/impl/ComponentConfigurationSupport.java
+++ 
b/camel-core/src/main/java/org/apache/camel/impl/ComponentConfigurationSupport.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.impl;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -165,6 +166,17 @@ public abstract class ComponentConfigurationSupport 
implements ComponentConfigur
     }
 
     public String createParameterJsonSchema() {
+        // favor loading the json schema from the built-time generated file
+        String defaultName = 
component.getCamelContext().resolveComponentDefaultName(component.getClass().getName());
+        if (defaultName != null) {
+            try {
+                return 
component.getCamelContext().getComponentParameterJsonSchema(defaultName);
+            } catch (IOException e) {
+                // ignore as we fallback to create the json at runtime
+            }
+        }
+
+        // fallback to resolving at runtime
         SortedMap<String, ParameterConfiguration> map = 
getParameterConfigurationMap();
         StringBuilder buffer = new StringBuilder("{\n  \"properties\": {");
         boolean first = true;

http://git-wip-us.apache.org/repos/asf/camel/blob/dac574d0/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java
index b6cdcaa..0769411 100644
--- 
a/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java
@@ -41,6 +41,7 @@ public class TimerComponentConfigurationAndDocumentationTest 
extends ContextTest
         String json = compConf.createParameterJsonSchema();
         assertNotNull(json);
 
+        assertTrue(json.contains("\"timerName\": { \"type\": \"string\", 
\"javaType\": \"java.lang.String\", \"description\": \"The name of the timer\" 
}"));
         assertTrue(json.contains("\"delay\": { \"type\": \"integer\""));
     }
 

Reply via email to