[GitHub] lburgazzoli closed pull request #170: runtime(groovy) : improve registry dsl

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] lburgazzoli closed pull request #170: runtime(groovy) : improve registry dsl

GitBox
lburgazzoli closed pull request #170: runtime(groovy) : improve registry dsl
URL: https://github.com/apache/camel-k/pull/170
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/runtime/examples/camel-caffeine.groovy b/runtime/examples/camel-caffeine.groovy
index 84da8fc3..1a70c252 100644
--- a/runtime/examples/camel-caffeine.groovy
+++ b/runtime/examples/camel-caffeine.groovy
@@ -1,16 +1,14 @@
 //
 // To run this integrations use:
 //
-//     kamel run -d camel:groovy runtime/examples/camel-caffeine.groovy
+//     kamel run --runtime groovy runtime/examples/camel-caffeine.groovy
 //
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
 
-Cache cache = Caffeine.newBuilder().recordStats().build();
+import com.github.benmanes.caffeine.cache.Caffeine
 
 context {
     registry {
-        bind 'caffeineCache', cache
+        caffeineCache = Caffeine.newBuilder().recordStats().build()
     }
 }
 
diff --git a/runtime/examples/routes.groovy b/runtime/examples/routes.groovy
index 091713f6..aef7ad35 100644
--- a/runtime/examples/routes.groovy
+++ b/runtime/examples/routes.groovy
@@ -27,7 +27,7 @@ context {
     // configure registry
     //
     registry {
-        bind 'myProcessor', processor {
+        myProcessor = processor {
             it.in.headers['RandomValue'] = ThreadLocalRandom.current().nextInt()
         }
     }
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy b/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
index 340c56b5..0b7b23d8 100644
--- a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
+++ b/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
@@ -28,4 +28,8 @@ class RegistryConfiguration {
     def bind(String name, value) {
         registry.bind(name, value)
     }
+
+    def propertyMissing(String name, value) {
+        registry.bind(name, value)
+    }
 }
diff --git a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy b/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
index 785b2e49..1b6a1e67 100644
--- a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
+++ b/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.k.groovy.dsl
 
+import org.apache.camel.Processor
 import org.apache.camel.component.log.LogComponent
 import org.apache.camel.component.seda.SedaComponent
 import org.apache.camel.k.jvm.Runtime
@@ -67,6 +68,7 @@ class IntegrationTest extends Specification {
         then:
         runtime.camelContext.registry.lookup('myEntry1') == 'myRegistryEntry1'
         runtime.camelContext.registry.lookup('myEntry2') == 'myRegistryEntry2'
+        runtime.camelContext.registry.lookup('myEntry3') instanceof Processor
     }
 
     def "load integration with component configuration"()  {
diff --git a/runtime/groovy/src/test/resources/routes-with-bindings.groovy b/runtime/groovy/src/test/resources/routes-with-bindings.groovy
index cf589e1d..6595b23b 100644
--- a/runtime/groovy/src/test/resources/routes-with-bindings.groovy
+++ b/runtime/groovy/src/test/resources/routes-with-bindings.groovy
@@ -1,8 +1,10 @@
-
 context {
     registry {
-        bind 'myEntry1', 'myRegistryEntry1'
-        bind 'myEntry2', 'myRegistryEntry2'
+        myEntry1 = 'myRegistryEntry1'
+        myEntry2 = 'myRegistryEntry2'
+        myEntry3 = processor {
+            it.in.headers['test'] = 'value'
+        }
     }
 }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services