You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/14 14:44:10 UTC

[camel-k-runtime] branch master updated (a0b31d2 -> a376ded)

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git.


    from a0b31d2  Merge pull request #153 from lburgazzoli/github-151
     new de4b638  chore: fix yaml based examples
     new a376ded  chore: quarkus fixes for camel-knative

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/knative/KnativeComponent.java  |  22 ++-
 .../camel/component/knative/KnativeEndpoint.java   |   9 +-
 .../src/main/resources/env.json                    |   9 +-
 .../src/main/resources/routes.yaml                 |  23 +--
 .../data/env.json                                  |  12 +-
 .../data/routes.yaml                               |  29 ++--
 .../data/routes.yaml                               |  46 +++---
 .../src/main/resources/routes.yaml                 | 179 +++++++++++----------
 8 files changed, 178 insertions(+), 151 deletions(-)


[camel-k-runtime] 01/02: chore: fix yaml based examples

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit de4b638dc89d51735636e032a37b91d6f7ff83e4
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Oct 14 16:43:20 2019 +0200

    chore: fix yaml based examples
---
 .../src/main/resources/env.json                    |   9 +-
 .../src/main/resources/routes.yaml                 |  23 +--
 .../data/env.json                                  |  12 +-
 .../data/routes.yaml                               |  29 ++--
 .../data/routes.yaml                               |  46 +++---
 .../src/main/resources/routes.yaml                 | 179 +++++++++++----------
 6 files changed, 155 insertions(+), 143 deletions(-)

diff --git a/examples/camel-k-runtime-example-knative/src/main/resources/env.json b/examples/camel-k-runtime-example-knative/src/main/resources/env.json
index 2220159..24dbf20 100644
--- a/examples/camel-k-runtime-example-knative/src/main/resources/env.json
+++ b/examples/camel-k-runtime-example-knative/src/main/resources/env.json
@@ -1,11 +1,12 @@
 {
-  "services": [
-     {
+  "services": [{
       "type": "endpoint",
-      "protocol": "http",
       "name": "from",
       "host": "0.0.0.0",
-      "port": 9090
+      "port": 9090,
+      "metadata": {
+        "camel.endpoint.kind": "source"
+      }
     }
   ]
 }
\ No newline at end of file
diff --git a/examples/camel-k-runtime-example-knative/src/main/resources/routes.yaml b/examples/camel-k-runtime-example-knative/src/main/resources/routes.yaml
index 43a2622..72b90e4 100644
--- a/examples/camel-k-runtime-example-knative/src/main/resources/routes.yaml
+++ b/examples/camel-k-runtime-example-knative/src/main/resources/routes.yaml
@@ -15,14 +15,15 @@
 # limitations under the License.
 #
 
-- id: "knative"
-  group: "routes"
-  from:
-    uri: "knative:endpoint/from"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:knative"
-      - set-body:
-          constant: "Hello from camel-k (native)"
\ No newline at end of file
+- route:
+    id: "knative"
+    group: "routes"
+    from:
+      uri: "knative:endpoint/from"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:knative"
+        - set-body:
+            constant: "Hello from camel-k (native)"
\ No newline at end of file
diff --git a/examples/camel-k-runtime-example-quarkus-knative/data/env.json b/examples/camel-k-runtime-example-quarkus-knative/data/env.json
index 5b44241..3a38ef7 100644
--- a/examples/camel-k-runtime-example-quarkus-knative/data/env.json
+++ b/examples/camel-k-runtime-example-quarkus-knative/data/env.json
@@ -2,16 +2,20 @@
     "services": [
       {
         "type": "endpoint",
-        "protocol": "http",
         "name": "sink",
         "host": "0.0.0.0",
-        "port": 9091
+        "port": 9091,
+        "metadata": {
+          "camel.endpoint.kind": "sink"
+        }
       }, {
         "type": "endpoint",
-        "protocol": "http",
         "name": "source",
         "host": "0.0.0.0",
-        "port": 9090
+        "port": 9090,
+        "metadata": {
+          "camel.endpoint.kind": "source"
+        }
       }
     ]
 }
\ No newline at end of file
diff --git a/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml b/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml
index ce1e634..e0559a5 100644
--- a/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml
+++ b/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml
@@ -15,18 +15,19 @@
 # limitations under the License.
 #
 
-- id: "knative"
-  group: "routes"
-  from:
-    uri: "knative://endpoint/source"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - choice:
-          when:
-            - simple: "${body} >= 100"
+- route:
+    id: "knative"
+    group: "routes"
+    from:
+      uri: "knative://endpoint/source"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - choice:
+            when:
+              - simple: "${body} >= 100"
+                steps:
+                  - to: "log:when"
+            otherwise:
               steps:
-                - to: "log:when"
-          otherwise:
-            steps:
-              - to: "log:otherwise"
\ No newline at end of file
+                - to: "log:otherwise"
\ No newline at end of file
diff --git a/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml b/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml
index d45b65a..b5015ee 100644
--- a/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml
+++ b/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml
@@ -15,25 +15,27 @@
 # limitations under the License.
 #
 
-- id: "flow-1"
-  group: "routes"
-  from:
-    uri: "netty-http:localhost:8080"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:info"
-- id: "flow-2"
-  group: "routes"
-  from:
-    uri: "timer:tick"
-    parameters:
-      period: "5s"
-    steps:
-      - set-body:
-          simple: "${exchangeProperty.CamelTimerName} -> ${exchangeProperty.CamelTimerCounter}"
-      - to:
-          uri: "log:tick"
-      - log:
-          message: "{{message}}"
\ No newline at end of file
+- route:
+    id: "flow-1"
+    group: "routes"
+    from:
+      uri: "netty-http:localhost:8080"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:info"
+- route:
+    id: "flow-2"
+    group: "routes"
+    from:
+      uri: "timer:tick"
+      parameters:
+        period: "5s"
+      steps:
+        - set-body:
+            simple: "${exchangeProperty.CamelTimerName} -> ${exchangeProperty.CamelTimerCounter}"
+        - to:
+            uri: "log:tick"
+        - log:
+            message: "{{message}}"
\ No newline at end of file
diff --git a/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml b/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml
index 6fd82ab..ec7bb5b 100644
--- a/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml
+++ b/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml
@@ -15,91 +15,94 @@
 # limitations under the License.
 #
 
-- id: "rest"
-  group: "routes"
-  rest:
-    verb: "post"
-    uri: "/api/route"
-    accepts: "text/plain"
-    binding-mode: "off"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:in"
-      - choice:
-          when:
-            - simple: "${body.contains(\",\")}"
-              steps:
-                - split:
-                    tokenize: ","
-                    steps:
-                      - set-body:
-                          simple: "${body.toUpperCase()}"
-                      - to:
-                          uri: "log:contains-1"
-            - simple: "${body.contains(\";\")}"
-              steps:
-                - split:
-                    tokenize: ";"
-                    steps:
-                      - set-body:
-                          simple: "${body.toLowerCase()}"
-                      - to:
-                          uri: "log:contains2"
-      - marshal:
-          json: {}
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:out"
-- id: "flow"
-  group: "routes"
-  rest:
-    verb: "post"
-    uri: "/api/flow"
-    accepts: "text/plain"
-    binding-mode: "off"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:in"
-      - filter:
-          simple: "${body.contains(\",\")}"
-      - split:
-          tokenize: ";"
-      - set-body:
-          simple: "${body.toLowerCase()}"
-      - to:
-          uri: "log:out"
-- id: "rest+flow"
-  group: "routes"
-  rest:
-    verb: "post"
-    uri: "/api/floute"
-    accepts: "text/plain"
-    binding-mode: "off"
-    steps:
-      - convert-body:
-          type: "java.lang.String"
-      - to:
-          uri: "log:in"
-      - choice:
-          when:
-            - simple: "${body.contains(\",\")}"
-              steps:
-                - split:
-                    tokenize: ","
-                - set-body:
-                    simple: "${body.toUpperCase()}"
-                - to:
-                    uri: "log:contains-1"
-            - simple: "${body.contains(\";\")}"
-              steps:
-                - split:
-                    tokenize: ";"
-                - set-body:
-                    simple: "${body.toLowerCase()}"
-                - to:
-                    uri: "log:contains2"
\ No newline at end of file
+- route:
+    id: "rest"
+    group: "routes"
+    rest:
+      verb: "post"
+      uri: "/api/route"
+      accepts: "text/plain"
+      binding-mode: "off"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:in"
+        - choice:
+            when:
+              - simple: "${body.contains(\",\")}"
+                steps:
+                  - split:
+                      tokenize: ","
+                      steps:
+                        - set-body:
+                            simple: "${body.toUpperCase()}"
+                        - to:
+                            uri: "log:contains-1"
+              - simple: "${body.contains(\";\")}"
+                steps:
+                  - split:
+                      tokenize: ";"
+                      steps:
+                        - set-body:
+                            simple: "${body.toLowerCase()}"
+                        - to:
+                            uri: "log:contains2"
+        - marshal:
+            json: {}
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:out"
+- route:
+    id: "flow"
+    group: "routes"
+    rest:
+      verb: "post"
+      uri: "/api/flow"
+      accepts: "text/plain"
+      binding-mode: "off"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:in"
+        - filter:
+            simple: "${body.contains(\",\")}"
+        - split:
+            tokenize: ";"
+        - set-body:
+            simple: "${body.toLowerCase()}"
+        - to:
+            uri: "log:out"
+- route:
+    id: "rest+flow"
+    group: "routes"
+    rest:
+      verb: "post"
+      uri: "/api/floute"
+      accepts: "text/plain"
+      binding-mode: "off"
+      steps:
+        - convert-body:
+            type: "java.lang.String"
+        - to:
+            uri: "log:in"
+        - choice:
+            when:
+              - simple: "${body.contains(\",\")}"
+                steps:
+                  - split:
+                      tokenize: ","
+                  - set-body:
+                      simple: "${body.toUpperCase()}"
+                  - to:
+                      uri: "log:contains-1"
+              - simple: "${body.contains(\";\")}"
+                steps:
+                  - split:
+                      tokenize: ";"
+                  - set-body:
+                      simple: "${body.toLowerCase()}"
+                  - to:
+                      uri: "log:contains2"
\ No newline at end of file


[camel-k-runtime] 02/02: chore: quarkus fixes for camel-knative

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit a376ded50db67a1b93593c14073ad089440772db
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Oct 14 16:43:55 2019 +0200

    chore: quarkus fixes for camel-knative
---
 .../camel/component/knative/KnativeComponent.java  | 22 ++++++++++++++++++++--
 .../camel/component/knative/KnativeEndpoint.java   |  9 +++------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
index 90064c4..5529485 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
@@ -34,9 +34,13 @@ import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Component("knative")
 public class KnativeComponent extends DefaultComponent {
+    private static final Logger LOGGER = LoggerFactory.getLogger(KnativeComponent.class);
+
     public static final String CONFIGURATION_ENV_VARIABLE = "CAMEL_KNATIVE_CONFIGURATION";
 
     private KnativeConfiguration configuration;
@@ -157,6 +161,8 @@ public class KnativeComponent extends DefaultComponent {
 
     @Override
     protected void doInit() throws Exception {
+        super.doInit();
+
         if (transport == null) {
             this.transport = getCamelContext().getRegistry().lookupByNameAndType(protocol.name(), KnativeTransport.class);
 
@@ -166,14 +172,24 @@ public class KnativeComponent extends DefaultComponent {
                     .getFactoryFinder(Knative.KNATIVE_TRANSPORT_RESOURCE_PATH)
                     .newInstance(protocol.name(), KnativeTransport.class)
                     .orElseThrow(() -> new RuntimeException("Error creating knative transport for protocol: " + protocol.name()));
+            }
+
+            if (this.transport instanceof CamelContextAware) {
+                CamelContextAware camelContextAware = (CamelContextAware)this.transport;
 
-                CamelContextAware.trySetCamelContext(transport, getCamelContext());
+                if (camelContextAware.getCamelContext() == null) {
+                    camelContextAware.setCamelContext(getCamelContext());
+                }
             }
         }
+
+        LOGGER.info("found knative transport: {} for protocol: {}", transport, protocol.name());
     }
 
     @Override
     protected void doStart() throws Exception {
+        super.doStart();
+
         if (this.transport != null && managedTransport) {
             ServiceHelper.startService(this.transport);
         }
@@ -181,6 +197,8 @@ public class KnativeComponent extends DefaultComponent {
 
     @Override
     protected void doStop() throws Exception {
+        super.doStop();
+
         if (this.transport != null && managedTransport) {
             ServiceHelper.stopService(this.transport);
         }
@@ -216,7 +234,7 @@ public class KnativeComponent extends DefaultComponent {
             conf.setServiceName(name);
         }
 
-        return new KnativeEndpoint(uri, this, Knative.Type.valueOf(type), name, this.transport, conf);
+        return new KnativeEndpoint(uri, this, Knative.Type.valueOf(type), name, conf);
     }
 
     // ************************
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
index a71b954..09ae6f7 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
@@ -28,7 +28,6 @@ import org.apache.camel.component.knative.ce.CloudEventProcessor;
 import org.apache.camel.component.knative.ce.CloudEventProcessors;
 import org.apache.camel.component.knative.spi.Knative;
 import org.apache.camel.component.knative.spi.KnativeEnvironment;
-import org.apache.camel.component.knative.spi.KnativeTransport;
 import org.apache.camel.processor.Pipeline;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
@@ -52,15 +51,13 @@ public class KnativeEndpoint extends DefaultEndpoint {
     @UriParam
     private KnativeConfiguration configuration;
 
-    private final KnativeTransport transport;
     private final CloudEventProcessor cloudEvent;
 
-    public KnativeEndpoint(String uri, KnativeComponent component, Knative.Type type, String name, KnativeTransport transport, KnativeConfiguration configuration) {
+    public KnativeEndpoint(String uri, KnativeComponent component, Knative.Type type, String name, KnativeConfiguration configuration) {
         super(uri, component);
 
         this.type = type;
         this.name = name;
-        this.transport = transport;
         this.configuration = configuration;
         this.cloudEvent = CloudEventProcessors.fromSpecVersion(configuration.getCloudEventsSpecVersion());
     }
@@ -75,7 +72,7 @@ public class KnativeEndpoint extends DefaultEndpoint {
         final KnativeEnvironment.KnativeServiceDefinition service = lookupServiceDefinition(Knative.EndpointKind.sink);
         final Processor ceProcessor = cloudEvent.producer(this, service);
         final Processor ceConverter = new KnativeConversionProcessor(configuration.isJsonSerializationEnabled());
-        final Producer producer = transport.createProducer(this, service);
+        final Producer producer = getComponent().getTransport().createProducer(this, service);
 
         PropertyBindingSupport.build()
             .withCamelContext(getCamelContext())
@@ -92,7 +89,7 @@ public class KnativeEndpoint extends DefaultEndpoint {
         final KnativeEnvironment.KnativeServiceDefinition service = lookupServiceDefinition(Knative.EndpointKind.source);
         final Processor ceProcessor = cloudEvent.consumer(this, service);
         final Processor pipeline = Pipeline.newInstance(getCamelContext(), ceProcessor, processor);
-        final Consumer consumer = transport.createConsumer(this, service, pipeline);
+        final Consumer consumer = getComponent().getTransport().createConsumer(this, service, pipeline);
 
         PropertyBindingSupport.build()
             .withCamelContext(getCamelContext())