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/11/07 13:35:48 UTC
[05/21] camel git commit: Camel apt improved html doc generation. And
working on generating json schema as well.
Camel apt improved html doc generation. And working on generating json schema as well.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/125a4e95
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/125a4e95
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/125a4e95
Branch: refs/heads/master
Commit: 125a4e9505cf9a9f69fd2499123f178aa9cb3ba7
Parents: 2695c39
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Nov 6 11:38:12 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Nov 7 13:25:18 2014 +0100
----------------------------------------------------------------------
.../camel/component/direct/DirectEndpoint.java | 26 ++++++++++++++++++++
.../management/mbean/ManagedCamelContext.java | 16 +++++++-----
...ponentConfigurationAndDocumentationTest.java | 11 +++++++++
.../camel/tools/apt/util/JsonSchemaHelper.java | 7 ++++--
4 files changed, 52 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/125a4e95/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java
index a242427..855f275 100644
--- a/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java
@@ -94,18 +94,44 @@ public class DirectEndpoint extends DefaultEndpoint {
return consumers.get(key);
}
+ /**
+ * If sending a message to a direct endpoint which has no active consumer,
+ * then we can tell the producer to block and wait for the consumer to become active.
+ * <p/>
+ * Is by default <tt>false</tt>.
+ */
public boolean isBlock() {
return block;
}
+ /**
+ * If sending a message to a direct endpoint which has no active consumer,
+ * then we can tell the producer to block and wait for the consumer to become active.
+ * <p/>
+ * Is by default <tt>false</tt>.
+ *
+ * @param block whether to block
+ */
public void setBlock(boolean block) {
this.block = block;
}
+ /**
+ * The timeout value to use if block is enabled.
+ * <p/>
+ * Is by default <tt>30000</tt>.
+ */
public long getTimeout() {
return timeout;
}
+ /**
+ * The timeout value to use if block is enabled.
+ * <p/>
+ * Is by default <tt>30000</tt>.
+ *
+ * @param timeout the timeout value
+ */
public void setTimeout(long timeout) {
this.timeout = timeout;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/125a4e95/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
index 2ccad19..deb215b 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
@@ -490,13 +490,17 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti
}
public String componentParameterJsonSchema(String componentName) throws Exception {
- Component component = context.getComponent(componentName);
- if (component != null) {
- ComponentConfiguration configuration = component.createComponentConfiguration();
- return configuration.createParameterJsonSchema();
- } else {
- return null;
+ // favor using pre generated schema if component has that
+ String json = context.getComponentParameterJsonSchema(componentName);
+ if (json == null) {
+ // okay this requires having the component on the classpath and being instantiated
+ Component component = context.getComponent(componentName);
+ if (component != null) {
+ ComponentConfiguration configuration = component.createComponentConfiguration();
+ json = configuration.createParameterJsonSchema();
+ }
}
+ return json;
}
public void reset(boolean includeRoutes) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/125a4e95/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java
index cf8f89a..44a1c0c 100644
--- a/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java
@@ -52,4 +52,15 @@ public class DirectComponentConfigurationAndDocumentationTest extends ContextTes
assertNotNull("Should have found some auto-generated HTML", html);
}
+ @Test
+ public void testComponentJsonSchema() throws Exception {
+ CamelContext context = new DefaultCamelContext();
+ String json = context.getComponentParameterJsonSchema("direct");
+ assertNotNull("Should have found some auto-generated JSON", json);
+ log.info(json);
+
+ // should include javadoc
+ assertTrue("Should include javadoc", json.contains("\"timeout\": { \"type\": \"integer\", \"description\": \"The timeout value to use if block is enabled. Is by default 30000.\" }"));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/125a4e95/tooling/apt/src/main/java/org/apache/camel/tools/apt/util/JsonSchemaHelper.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/util/JsonSchemaHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/util/JsonSchemaHelper.java
index 217b002..0549d22 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/util/JsonSchemaHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/util/JsonSchemaHelper.java
@@ -33,7 +33,7 @@ public final class JsonSchemaHelper {
StringBuilder sb = new StringBuilder();
sb.append(doubleQuote(name));
- sb.append(": { \"type\":");
+ sb.append(": { \"type\": ");
if ("enum".equals(typeName)) {
sb.append(doubleQuote("string"));
@@ -178,7 +178,10 @@ public final class JsonSchemaHelper {
first = false;
}
- return sb.toString();
+ // remove double whitespaces, and trim
+ String s = sb.toString();
+ s = s.replaceAll("\\s+", " ");
+ return s.trim();
}
}