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 ad8bb2e09e3ff52c2549628e4ca01ffc748b06e4 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Wed Jul 3 18:26:04 2019 +0200 groovy: initial support for idea auto completion --- .../k/groovy/dsl/ComponentsConfiguration.groovy | 4 ++-- .../camel/k/groovy/dsl/ContextConfiguration.groovy | 4 ++-- .../k/groovy/dsl/IntegrationConfiguration.groovy | 12 +++++----- .../camel/k/groovy/dsl/RestConfiguration.groovy | 8 ++++--- .../integration.gdsl} | 26 ++++------------------ 5 files changed, 19 insertions(+), 35 deletions(-) diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy index 7f147be..6287100 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy @@ -26,7 +26,7 @@ class ComponentsConfiguration { this.context = context } - def component(String name, Closure<?> callable) { + def component(String name, @DelegatesTo(ComponentConfiguration) Closure<?> callable) { def component = context.getComponent(name, true, false) callable.resolveStrategy = Closure.DELEGATE_FIRST @@ -34,7 +34,7 @@ class ComponentsConfiguration { callable.call() } - def component(String name, Class<? extends Component> type, Closure <?> callable) { + def component(String name, Class<? extends Component> type, @DelegatesTo(ComponentConfiguration) Closure <?> callable) { def component = context.getComponent(name, true, false) // if the component is not found, let's create a new one. This is diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy index c5f332b..3b1c373 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy @@ -25,13 +25,13 @@ class ContextConfiguration { this.context = context } - def registry(Closure<?> callable) { + def registry(@DelegatesTo(RegistryConfiguration) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = new RegistryConfiguration(this.context.registry) callable.call() } - def components(Closure<?> callable) { + def components(@DelegatesTo(ComponentsConfiguration) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = new ComponentsConfiguration(context) callable.call() diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy index 6af42ab..b47f509 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy @@ -22,7 +22,7 @@ import org.apache.camel.Predicate import org.apache.camel.Processor import org.apache.camel.builder.RouteBuilder import org.apache.camel.k.jvm.dsl.Components -import org.apache.camel.model.RouteDefinition +import org.apache.camel.model.ProcessorDefinition import org.apache.camel.spi.Registry class IntegrationConfiguration { @@ -38,23 +38,23 @@ class IntegrationConfiguration { this.builder = builder } - def context(Closure<?> callable) { + def context(@DelegatesTo(ContextConfiguration) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = new ContextConfiguration(context) callable.call() } - def rest(Closure<?> callable) { + def rest(@DelegatesTo(RestConfiguration) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = new RestConfiguration(builder) callable.call() } - RouteDefinition from(String endpoint) { + ProcessorDefinition from(String endpoint) { return builder.from(endpoint) } - def processor(Closure<?> callable) { + def processor(@DelegatesTo(Exchange) Closure<?> callable) { return new Processor() { @Override void process(Exchange exchange) throws Exception { @@ -64,7 +64,7 @@ class IntegrationConfiguration { } } - def predicate(Closure<?> callable) { + def predicate(@DelegatesTo(Exchange) Closure<?> callable) { return new Predicate() { @Override boolean matches(Exchange exchange) throws Exception { diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy index 1a461d9..a082f68 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy @@ -17,6 +17,8 @@ package org.apache.camel.k.groovy.dsl import org.apache.camel.builder.RouteBuilder +import org.apache.camel.model.rest.RestConfigurationDefinition +import org.apache.camel.model.rest.RestDefinition class RestConfiguration { private final RouteBuilder builder @@ -25,19 +27,19 @@ class RestConfiguration { this.builder = builder } - def configuration(Closure<?> callable) { + def configuration(@DelegatesTo(RestConfigurationDefinition) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = builder.restConfiguration() callable.call() } - def configuration(String component, Closure<?> callable) { + def configuration(String component, @DelegatesTo(RestConfigurationDefinition) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = builder.restConfiguration(component) callable.call() } - def path(String path, Closure<?> callable) { + def path(String path, @DelegatesTo(RestDefinition) Closure<?> callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST callable.delegate = builder.rest(path) callable.call() diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy b/camel-k-runtime-groovy/src/main/resources/integration.gdsl similarity index 55% copy from camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy copy to camel-k-runtime-groovy/src/main/resources/integration.gdsl index c5f332b..75ddf1f 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/resources/integration.gdsl @@ -14,26 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.groovy.dsl +def ctx = context(scope: scriptScope()) -import org.apache.camel.CamelContext - -class ContextConfiguration { - private final CamelContext context - - ContextConfiguration(CamelContext context) { - this.context = context - } - - def registry(Closure<?> callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new RegistryConfiguration(this.context.registry) - callable.call() - } - - def components(Closure<?> callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new ComponentsConfiguration(context) - callable.call() - } -} +contributor(ctx) { + delegatesTo(findClass('org.apache.camel.k.groovy.dsl.IntegrationConfiguration')) +} \ No newline at end of file