Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime(groovy) : improve registry dsl #170

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions runtime/examples/camel-caffeine.groovy
Original file line number Diff line number Diff line change
@@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/examples/routes.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ context {
// configure registry
//
registry {
bind 'myProcessor', processor {
myProcessor = processor {
it.in.headers['RandomValue'] = ThreadLocalRandom.current().nextInt()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ class RegistryConfiguration {
def bind(String name, value) {
registry.bind(name, value)
}

def propertyMissing(String name, value) {
registry.bind(name, value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"() {
Expand Down
8 changes: 5 additions & 3 deletions runtime/groovy/src/test/resources/routes-with-bindings.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

context {
registry {
bind 'myEntry1', 'myRegistryEntry1'
bind 'myEntry2', 'myRegistryEntry2'
myEntry1 = 'myRegistryEntry1'
myEntry2 = 'myRegistryEntry2'
myEntry3 = processor {
it.in.headers['test'] = 'value'
}
}
}

Expand Down