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 2016/01/31 11:11:07 UTC

[4/4] camel git commit: CAMEL-9483: camel-blueprint should detect which rest configured components and data format are in use, and wait for those to be installed so they are available. Like we do for scanning the routes what they are using.

CAMEL-9483: camel-blueprint should detect which rest configured components and data format are in use, and wait for those to be installed so they are available. Like we do for scanning the routes what they are using.


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

Branch: refs/heads/camel-2.16.x
Commit: b1555bae4a878135a8681d9bbe895f1f97c96870
Parents: a4da244
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 31 11:08:51 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 31 11:10:56 2016 +0100

----------------------------------------------------------------------
 .../handler/CamelNamespaceHandler.java          | 29 +++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b1555bae/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
index 332193a..00ce974 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
@@ -32,7 +32,6 @@ import javax.xml.bind.Binder;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 
-import org.apache.camel.model.rest.RestConfigurationDefinition;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -83,6 +82,7 @@ import org.apache.camel.model.ToDefinition;
 import org.apache.camel.model.UnmarshalDefinition;
 import org.apache.camel.model.WireTapDefinition;
 import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.model.rest.RestBindingMode;
 import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.model.rest.VerbDefinition;
 import org.apache.camel.spi.CamelContextNameStrategy;
@@ -108,12 +108,10 @@ import org.osgi.service.blueprint.reflect.RefMetadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 import static org.osgi.service.blueprint.reflect.ComponentMetadata.ACTIVATION_LAZY;
 import static org.osgi.service.blueprint.reflect.ServiceReferenceMetadata.AVAILABILITY_MANDATORY;
 import static org.osgi.service.blueprint.reflect.ServiceReferenceMetadata.AVAILABILITY_OPTIONAL;
 
-
 /**
  * Camel {@link NamespaceHandler} to parse the Camel related namespaces.
  */
@@ -993,8 +991,8 @@ public class CamelNamespaceHandler implements NamespaceHandler {
                 }
             }
 
-            // rest configuration may refer to a component to use
             if (ccfb.getRestConfiguration() != null) {
+                // rest configuration may refer to a component to use
                 String component = ccfb.getRestConfiguration().getComponent();
                 if (component != null) {
                     components.add(component);
@@ -1003,6 +1001,29 @@ public class CamelNamespaceHandler implements NamespaceHandler {
                 if (component != null) {
                     components.add(component);
                 }
+
+                // check what data formats are used in binding mode
+                RestBindingMode mode = ccfb.getRestConfiguration().getBindingMode();
+                String json = ccfb.getRestConfiguration().getJsonDataFormat();
+                if (json == null && mode != null) {
+                    if (RestBindingMode.json.equals(mode) || RestBindingMode.json_xml.equals(mode)) {
+                        // jackson is the default json data format
+                        json = "json-jackson";
+                    }
+                }
+                if (json != null) {
+                    dataformats.add(json);
+                }
+                String xml = ccfb.getRestConfiguration().getXmlDataFormat();
+                if (xml == null && mode != null) {
+                    if (RestBindingMode.xml.equals(mode) || RestBindingMode.json_xml.equals(mode)) {
+                        // jaxb is the default xml data format
+                        dataformats.add("jaxb");
+                    }
+                }
+                if (xml != null) {
+                    dataformats.add(xml);
+                }
             }
 
             // We can only add service references to resolvers, but we can't make the factory depends on those