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 2017/03/03 09:08:45 UTC
[1/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Repository: camel
Updated Branches:
refs/heads/master 8a7789899 -> 239f093a1
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/dsld/CamelGroovyMethods.dsld
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/dsld/CamelGroovyMethods.dsld b/components/camel-groovy-dsl/src/main/resources/dsld/CamelGroovyMethods.dsld
new file mode 100644
index 0000000..3bb225a
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/dsld/CamelGroovyMethods.dsld
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+ currentType(subType('org.apache.camel.model.ProcessorDefinition')).accept {
+ method name : 'process', type : 'org.apache.camel.model.ProcessorDefinition', params: [processorLogic : 'groovy.lang.Closure']
+ method name : 'enrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', aggregationLogic : 'groovy.lang.Closure']
+ method name : 'pollEnrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', aggregationLogic : 'groovy.lang.Closure']
+ method name : 'pollEnrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', timeout : 'long', aggregationLogic : 'groovy.lang.Closure']
+ method name : 'script', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'transform', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'setProperty', type : 'org.apache.camel.model.ProcessorDefinition', params: [name : 'java.lang.String', expression : 'groovy.lang.Closure']
+ method name : 'setHeader', type : 'org.apache.camel.model.ProcessorDefinition', params: [name : 'java.lang.String', expression : 'groovy.lang.Closure']
+ method name : 'setBody', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'setFaultBody', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'sort', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'idempotentConsumer', type : 'org.apache.camel.model.IdempotentConsumerDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'idempotentConsumer', type : 'org.apache.camel.model.IdempotentConsumerDefinition', params: [rep : 'org.apache.camel.spi.IdempotentRepository', expression : 'groovy.lang.Closure']
+ method name : 'recipientList', type : 'org.apache.camel.model.RecipientListDefinition', params: [recipients : 'groovy.lang.Closure']
+ method name : 'recipientList', type : 'org.apache.camel.model.RecipientListDefinition', params: [delimiter : 'java.lang.String', recipients : 'groovy.lang.Closure']
+ method name : 'routingSlip', type : 'org.apache.camel.model.RoutingSlipDefinition', params: [recipients : 'groovy.lang.Closure']
+ method name : 'routingSlip', type : 'org.apache.camel.model.RoutingSlipDefinition', params: [delimiter : 'java.lang.String', recipients : 'groovy.lang.Closure']
+ method name : 'dynamicRouter', type : 'org.apache.camel.model.DynamicRouterDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'split', type : 'org.apache.camel.model.SplitDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'resequence', type : 'org.apache.camel.model.ResequenceDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'aggregate', type : 'org.apache.camel.model.AggregateDefinition', params: [correlationExpression : 'groovy.lang.Closure']
+ method name : 'delay', type : 'org.apache.camel.model.DelayDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'throttle', type : 'org.apache.camel.model.ThrottleDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'loop', type : 'org.apache.camel.model.LoopDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'filter', type : 'org.apache.camel.model.FilterDefinition', params: [predicate : 'groovy.lang.Closure']
+ method name : 'validate', type : 'org.apache.camel.model.ProcessorDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.groovy.extend.CamelGroovyMethods')).accept {
+ method name : 'newExchange', type : 'org.apache.camel.model.WireTapDefinition', params: [self : 'org.apache.camel.model.WireTapDefinition', processorLogic : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.OnExceptionDefinition')).accept {
+ method name : 'onRedelivery', type : 'org.apache.camel.model.OnExceptionDefinition', params: [processorLogic : 'groovy.lang.Closure']
+ method name : 'onWhen', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
+ method name : 'handled', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
+ method name : 'continued', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
+ method name : 'retryWhile', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.MulticastDefinition')).accept {
+ method name : 'aggregationStrategy', type : 'org.apache.camel.model.MulticastDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
+ method name : 'onPrepare', type : 'org.apache.camel.model.MulticastDefinition', params: [processorLogic : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.RecipientListDefinition')).accept {
+ method name : 'aggregationStrategy', type : 'org.apache.camel.model.RecipientListDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
+ method name : 'onPrepare', type : 'org.apache.camel.model.RecipientListDefinition', params: [processorLogic : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.SplitDefinition')).accept {
+ method name : 'aggregationStrategy', type : 'org.apache.camel.model.SplitDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
+ method name : 'onPrepare', type : 'org.apache.camel.model.SplitDefinition', params: [processorLogic : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.AggregateDefinition')).accept {
+ method name : 'aggregationStrategy', type : 'org.apache.camel.model.AggregateDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
+ method name : 'completionSize', type : 'org.apache.camel.model.AggregateDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'completionTimeout', type : 'org.apache.camel.model.AggregateDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'completionPredicate', type : 'org.apache.camel.model.AggregateDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.WireTapDefinition')).accept {
+ method name : 'onPrepare', type : 'org.apache.camel.model.WireTapDefinition', params: [processorLogic : 'groovy.lang.Closure']
+ method name : 'newExchangeBody', type : 'org.apache.camel.model.WireTapDefinition', params: [expression : 'groovy.lang.Closure']
+ method name : 'newExchangeHeader', type : 'org.apache.camel.model.WireTapDefinition', params: [header : 'java.lang.String', expression : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.ChoiceDefinition')).accept {
+ method name : 'when', type : 'org.apache.camel.model.ChoiceDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.TryDefinition')).accept {
+ method name : 'onWhen', type : 'org.apache.camel.model.TryDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.OnCompletionDefinition')).accept {
+ method name : 'onWhen', type : 'org.apache.camel.model.OnCompletionDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.CatchDefinition')).accept {
+ method name : 'onWhen', type : 'org.apache.camel.model.CatchDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.InterceptDefinition')).accept {
+ method name : 'when', type : 'org.apache.camel.model.InterceptDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.model.InterceptSendToEndpointDefinition')).accept {
+ method name : 'when', type : 'org.apache.camel.model.InterceptSendToEndpointDefinition', params: [predicate : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.builder.RouteBuilder')).accept {
+ method name : 'aggregator', type : 'org.apache.camel.processor.aggregate.AggregationStrategy', params: [aggregationLogic : 'groovy.lang.Closure']
+ method name : 'expression', type : 'org.apache.camel.Expression', params: [expression : 'groovy.lang.Closure']
+ method name : 'predicate', type : 'org.apache.camel.Predicate', params: [predicate : 'groovy.lang.Closure']
+ method name : 'processor', type : 'org.apache.camel.Processor', params: [processor : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.builder.ExpressionClause')).accept {
+ method name : 'expression', type : 'T', params: [expression : 'groovy.lang.Closure']
+}
+ currentType(subType('org.apache.camel.builder.DataFormatClause')).accept {
+ method name : 'gnode', type : 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware : 'boolean']
+ method name : 'gnode', type : 'org.apache.camel.model.ProcessorDefinition'
+ method name : 'gpath', type : 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware : 'boolean']
+ method name : 'gpath', type : 'org.apache.camel.model.ProcessorDefinition'
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/gdsl/CamelGroovyMethods.gdsl
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/gdsl/CamelGroovyMethods.gdsl b/components/camel-groovy-dsl/src/main/resources/gdsl/CamelGroovyMethods.gdsl
new file mode 100644
index 0000000..eac8545
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/gdsl/CamelGroovyMethods.gdsl
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+contributor([context(ctype: 'org.apache.camel.model.ProcessorDefinition')]) {
+ method name: 'process', type: 'org.apache.camel.model.ProcessorDefinition', params: [processorLogic: 'groovy.lang.Closure']
+ method name: 'enrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', aggregationLogic: 'groovy.lang.Closure']
+ method name: 'pollEnrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', aggregationLogic: 'groovy.lang.Closure']
+ method name: 'pollEnrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', timeout: 'long', aggregationLogic: 'groovy.lang.Closure']
+ method name: 'script', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'transform', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'setProperty', type: 'org.apache.camel.model.ProcessorDefinition', params: [name: 'java.lang.String', expression: 'groovy.lang.Closure']
+ method name: 'setHeader', type: 'org.apache.camel.model.ProcessorDefinition', params: [name: 'java.lang.String', expression: 'groovy.lang.Closure']
+ method name: 'setBody', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'setFaultBody', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'sort', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'idempotentConsumer', type: 'org.apache.camel.model.IdempotentConsumerDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'idempotentConsumer', type: 'org.apache.camel.model.IdempotentConsumerDefinition', params: [rep: 'org.apache.camel.spi.IdempotentRepository', expression: 'groovy.lang.Closure']
+ method name: 'recipientList', type: 'org.apache.camel.model.RecipientListDefinition', params: [recipients: 'groovy.lang.Closure']
+ method name: 'recipientList', type: 'org.apache.camel.model.RecipientListDefinition', params: [delimiter: 'java.lang.String', recipients: 'groovy.lang.Closure']
+ method name: 'routingSlip', type: 'org.apache.camel.model.RoutingSlipDefinition', params: [recipients: 'groovy.lang.Closure']
+ method name: 'routingSlip', type: 'org.apache.camel.model.RoutingSlipDefinition', params: [delimiter: 'java.lang.String', recipients: 'groovy.lang.Closure']
+ method name: 'dynamicRouter', type: 'org.apache.camel.model.DynamicRouterDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'split', type: 'org.apache.camel.model.SplitDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'resequence', type: 'org.apache.camel.model.ResequenceDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'aggregate', type: 'org.apache.camel.model.AggregateDefinition', params: [correlationExpression: 'groovy.lang.Closure']
+ method name: 'delay', type: 'org.apache.camel.model.DelayDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'throttle', type: 'org.apache.camel.model.ThrottleDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'loop', type: 'org.apache.camel.model.LoopDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'filter', type: 'org.apache.camel.model.FilterDefinition', params: [predicate: 'groovy.lang.Closure']
+ method name: 'validate', type: 'org.apache.camel.model.ProcessorDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.groovy.extend.CamelGroovyMethods')]) {
+ method name: 'newExchange', type: 'org.apache.camel.model.WireTapDefinition', params: [self: 'org.apache.camel.model.WireTapDefinition', processorLogic: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.OnExceptionDefinition')]) {
+ method name: 'onRedelivery', type: 'org.apache.camel.model.OnExceptionDefinition', params: [processorLogic: 'groovy.lang.Closure']
+ method name: 'onWhen', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
+ method name: 'handled', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
+ method name: 'continued', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
+ method name: 'retryWhile', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.MulticastDefinition')]) {
+ method name: 'aggregationStrategy', type: 'org.apache.camel.model.MulticastDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
+ method name: 'onPrepare', type: 'org.apache.camel.model.MulticastDefinition', params: [processorLogic: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.RecipientListDefinition')]) {
+ method name: 'aggregationStrategy', type: 'org.apache.camel.model.RecipientListDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
+ method name: 'onPrepare', type: 'org.apache.camel.model.RecipientListDefinition', params: [processorLogic: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.SplitDefinition')]) {
+ method name: 'aggregationStrategy', type: 'org.apache.camel.model.SplitDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
+ method name: 'onPrepare', type: 'org.apache.camel.model.SplitDefinition', params: [processorLogic: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.AggregateDefinition')]) {
+ method name: 'aggregationStrategy', type: 'org.apache.camel.model.AggregateDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
+ method name: 'completionSize', type: 'org.apache.camel.model.AggregateDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'completionTimeout', type: 'org.apache.camel.model.AggregateDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'completionPredicate', type: 'org.apache.camel.model.AggregateDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.WireTapDefinition')]) {
+ method name: 'onPrepare', type: 'org.apache.camel.model.WireTapDefinition', params: [processorLogic: 'groovy.lang.Closure']
+ method name: 'newExchangeBody', type: 'org.apache.camel.model.WireTapDefinition', params: [expression: 'groovy.lang.Closure']
+ method name: 'newExchangeHeader', type: 'org.apache.camel.model.WireTapDefinition', params: [header: 'java.lang.String', expression: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.ChoiceDefinition')]) {
+ method name: 'when', type: 'org.apache.camel.model.ChoiceDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.TryDefinition')]) {
+ method name: 'onWhen', type: 'org.apache.camel.model.TryDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.OnCompletionDefinition')]) {
+ method name: 'onWhen', type: 'org.apache.camel.model.OnCompletionDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.CatchDefinition')]) {
+ method name: 'onWhen', type: 'org.apache.camel.model.CatchDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.InterceptDefinition')]) {
+ method name: 'when', type: 'org.apache.camel.model.InterceptDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.model.InterceptSendToEndpointDefinition')]) {
+ method name: 'when', type: 'org.apache.camel.model.InterceptSendToEndpointDefinition', params: [predicate: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.builder.RouteBuilder')]) {
+ method name: 'aggregator', type: 'org.apache.camel.processor.aggregate.AggregationStrategy', params: [aggregationLogic: 'groovy.lang.Closure']
+ method name: 'expression', type: 'org.apache.camel.Expression', params: [expression: 'groovy.lang.Closure']
+ method name: 'predicate', type: 'org.apache.camel.Predicate', params: [predicate: 'groovy.lang.Closure']
+ method name: 'processor', type: 'org.apache.camel.Processor', params: [processor: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.builder.ExpressionClause')]) {
+ method name: 'expression', type: 'T', params: [expression: 'groovy.lang.Closure']
+}
+contributor([context(ctype: 'org.apache.camel.builder.DataFormatClause')]) {
+ method name: 'gnode', type: 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware: 'boolean']
+ method name: 'gnode', type: 'org.apache.camel.model.ProcessorDefinition'
+ method name: 'gpath', type: 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware: 'boolean']
+ method name: 'gpath', type: 'org.apache.camel.model.ProcessorDefinition'
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy b/components/camel-groovy-dsl/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
new file mode 100644
index 0000000..9f135f8
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
@@ -0,0 +1,48 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.groovy
+
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+
+/**
+ */
+class ConfigureCamel implements Runnable {
+
+ static void main(String[] args) {
+ new ConfigureCamel().run();
+ }
+
+ void run() {
+ ExpandoMetaClass.enableGlobally();
+
+ ProcessorDefinition.metaClass.filter = { filter ->
+ if (filter instanceof Closure) {
+ filter = CamelGroovyMethods.toExpression(filter)
+ }
+ delegate.filter(filter);
+ }
+
+ ChoiceDefinition.metaClass.when = { filter ->
+ if (filter instanceof Closure) {
+ filter = CamelGroovyMethods.toExpression(filter)
+ }
+ delegate.when(filter);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
new file mode 100644
index 0000000..2766892
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
@@ -0,0 +1,244 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend
+
+import org.apache.camel.EndpointInject
+import org.apache.camel.Exchange
+import org.apache.camel.builder.RouteBuilder
+import org.apache.camel.component.mock.MockEndpoint
+import org.apache.camel.test.junit4.CamelTestSupport
+import org.junit.Test
+
+/**
+ * Test a few DSL extensions.
+ */
+class CamelGroovyMethodsTest extends CamelTestSupport {
+
+ private static final String HELLO = 'Hello'
+ private static final String WORLD = 'World'
+
+ @EndpointInject(uri = 'mock:test1')
+ private MockEndpoint resultEndpoint;
+ @EndpointInject(uri = 'mock:test2')
+ private MockEndpoint otherEndpoint;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+
+ def aggregation = { Exchange original, Exchange resource ->
+ original.in.body += resource.in.body
+ original
+ }
+
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+
+ from('direct:test1')
+ .enrich('direct:enrich') { Exchange original, Exchange resource ->
+ original.in.body += resource.in.body
+ original
+ }
+ .to('mock:test1')
+
+ from('direct:enrich')
+ .transform(constant(WORLD))
+
+ from('direct:test2')
+ .pollEnrich('seda:enrich', aggregation)
+ .to('mock:test1')
+
+ from('direct:test3')
+ .process { Exchange e ->
+ e.in.with {
+ body = HELLO
+ headers[HELLO] = WORLD
+ }
+ }
+ .to('mock:test1')
+
+ from('direct:test4')
+ .setHeader(HELLO) { Exchange e ->
+ e.in.body.reverse()
+ }
+ .to('mock:test1')
+
+ from('direct:test5')
+ .setProperty(HELLO) { Exchange e ->
+ e.in.body.reverse()
+ }
+ .to('mock:test1')
+
+ from('direct:test6')
+ .transform { Exchange e ->
+ e.in.body.reverse()
+ }
+ .to('mock:test1')
+
+ from('direct:test7')
+ .setBody { Exchange e ->
+ e.in.body.reverse()
+ }
+ .to('mock:test1')
+
+ from('direct:test8')
+ .unmarshal().gpath()
+ // XmlSlurper proceeds to first node
+ .transform { it.in.body.World.text() }
+ .to('mock:test1')
+
+ from('direct:test9')
+ .unmarshal().gnode()
+ // XmlParser proceeds to first node
+ .transform { it.in.body.World.text() }
+ .to('mock:test1')
+
+ from('direct:test10')
+ .marshal().gnode()
+ .convertBodyTo(String)
+ .to('mock:test1')
+
+ from('direct:test11')
+ .choice()
+ .when { it.in.body == HELLO }.to('mock:test1')
+ .otherwise().to('mock:test2')
+
+ from('direct:test12')
+ .setHeader(HELLO).expression { Exchange e ->
+ e.in.body.reverse()
+ }
+ .to('mock:test1')
+
+ from('direct:toD')
+ .toD('mock:${header.foo}')
+
+ }
+
+ }
+ }
+
+ @Test
+ void testClosureEnricherAggregation() {
+ resultEndpoint.expectedBodiesReceived(HELLO + WORLD)
+ template.sendBody('direct:test1', HELLO)
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosurePollingEnricherAggregation() {
+ resultEndpoint.expectedBodiesReceived(HELLO + WORLD)
+ template.sendBody('seda:enrich', WORLD)
+ template.sendBody('direct:test2', HELLO)
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureProcessor() {
+ resultEndpoint.expectedBodiesReceived(HELLO)
+ resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
+ template.sendBody('direct:test3', '')
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureSetHeader() {
+ resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
+ template.sendBody('direct:test4', WORLD.reverse())
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureSetHeaderWithExpressionClause() {
+ resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
+ template.sendBody('direct:test4', WORLD.reverse())
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureSetProperty() {
+ resultEndpoint.expectedPropertyReceived(HELLO, WORLD)
+ template.sendBody('direct:test5', WORLD.reverse())
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureTransformer() {
+ resultEndpoint.expectedBodiesReceived(HELLO)
+ template.sendBody('direct:test6', HELLO.reverse())
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureSetBody() {
+ resultEndpoint.expectedBodiesReceived(HELLO)
+ template.sendBody('direct:test7', HELLO.reverse())
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureChoice1() {
+ resultEndpoint.expectedBodiesReceived(HELLO)
+ otherEndpoint.expectedMessageCount(0)
+ template.sendBody('direct:test11', HELLO)
+ resultEndpoint.assertIsSatisfied()
+ otherEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testClosureChoice2() {
+ resultEndpoint.expectedMessageCount(0)
+ otherEndpoint.expectedBodiesReceived(WORLD)
+ template.sendBody('direct:test11', WORLD)
+ resultEndpoint.assertIsSatisfied()
+ otherEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testXmlSlurper() {
+ String text = "How are you?"
+ resultEndpoint.expectedBodiesReceived(text)
+ template.sendBody('direct:test8', "<Hello><World>${text}</World></Hello>")
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testXmlParser() {
+ String text = "How are you?"
+ resultEndpoint.expectedBodiesReceived(text)
+ template.sendBody('direct:test9', "<Hello><World>${text}</World></Hello>")
+ resultEndpoint.assertIsSatisfied()
+ }
+
+ @Test
+ void testXmlPrinter() {
+ String text = "<Hello><World>How are you?</World></Hello>"
+ Node parsed = new XmlParser().parseText(text)
+ resultEndpoint.expectedMessageCount(1)
+ template.sendBody('direct:test10', parsed)
+ // The created XML differs in terms of white spaces and line feeds.
+ assertEquals(text.replaceAll('\\s+', ''), resultEndpoint.exchanges[0].in.body.replaceAll('\\s+', ''))
+ }
+
+ @Test
+ void testToD() {
+ resultEndpoint.expectedMessageCount(1)
+ template.sendBodyAndHeader('direct:toD', WORLD, "foo", "test1")
+ resultEndpoint.assertIsSatisfied()
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
new file mode 100644
index 0000000..71a9b73
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend
+
+import static org.junit.Assert.*
+import static org.apache.camel.groovy.extend.CamelGroovyMethods.toAggregationStrategy
+
+import org.apache.camel.CamelContext
+import org.apache.camel.Exchange
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.impl.DefaultExchange
+import org.junit.Before
+import org.junit.Test
+
+
+class ClosureAggregationStrategyTest {
+
+ private Exchange exchange1
+ private Exchange exchange2
+ private static final String HELLO = "Hello"
+ private static final String WORLD = "World"
+
+ @Before
+ public void setUp() throws Exception {
+ CamelContext context = new DefaultCamelContext()
+ exchange1 = new DefaultExchange(context);
+ exchange2 = new DefaultExchange(context);
+ }
+
+ @Test
+ public void testAggregationStrategy() {
+ exchange1.in.body = HELLO
+ exchange2.in.body = WORLD
+ ClosureAggregationStrategy cas = toAggregationStrategy { Exchange oldExchange, Exchange newExchange ->
+ newExchange.in.body = newExchange.in.body + ' ' + oldExchange.in.body
+ newExchange
+ }
+ assertEquals(HELLO + ' ' + WORLD, cas.aggregate(exchange2, exchange1).in.body)
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
new file mode 100644
index 0000000..ecd50a2
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend
+
+import static org.junit.Assert.*
+import static org.apache.camel.groovy.extend.CamelGroovyMethods.toExpression
+
+import org.apache.camel.Exchange
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.impl.DefaultExchange
+import org.junit.Before
+import org.junit.Test
+
+
+class ClosureExpressionTest {
+
+ private Exchange exchange
+ private static final String HELLO = "Hello"
+
+ @Before
+ public void setUp() throws Exception {
+ exchange = new DefaultExchange(new DefaultCamelContext());
+ exchange.in.body = HELLO
+ }
+
+ @Test
+ public void testAsExpression() {
+ ClosureExpression expression = toExpression { Exchange exchange ->
+ exchange.in.body
+ }
+ assertEquals(HELLO, expression.evaluate(exchange))
+ }
+
+ @Test
+ public void testAsPredicate() {
+ ClosureExpression expressionTrue = toExpression { Exchange exchange ->
+ exchange.in.body == HELLO
+ }
+ assertTrue(expressionTrue.evaluate(exchange))
+ ClosureExpression expressionFalse = toExpression { Exchange exchange ->
+ exchange.in.body != HELLO
+ }
+ assertFalse(expressionFalse.evaluate(exchange))
+ }
+
+ @Test
+ public void testClosureException() {
+ String unknownProperty = 'Gablorg'
+ ClosureExpression expression = toExpression { Exchange exchange ->
+ exchange."${unknownProperty}"
+ }
+ try {
+ expression.evaluate(exchange)
+ } catch (MissingPropertyException e) {
+ assertTrue(e.message.contains(unknownProperty))
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
new file mode 100644
index 0000000..3733551
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend
+
+import static org.junit.Assert.*
+import static org.apache.camel.groovy.extend.CamelGroovyMethods.toProcessor
+
+import org.apache.camel.Exchange
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.impl.DefaultExchange
+import org.junit.Before
+import org.junit.Test
+
+
+class ClosureProcessorTest {
+
+ private Exchange exchange
+ private static final String HELLO = "Hello"
+
+ @Before
+ public void setUp() throws Exception {
+ exchange = new DefaultExchange(new DefaultCamelContext());
+ }
+
+ @Test
+ public void testProcessor() {
+ exchange.in.body = HELLO
+ ClosureProcessor processor = toProcessor { Exchange exchange ->
+ exchange.in.body = exchange.in.body.reverse()
+ }
+ processor.process(exchange)
+ assertEquals(HELLO.reverse(), exchange.in.body )
+ }
+
+ @Test(expected=NullPointerException)
+ public void testProcessorException() {
+ exchange.in.body = null
+ ClosureProcessor processor = toProcessor { Exchange exchange ->
+ exchange.in.body = exchange.in.body.reverse()
+ }
+ processor.process(exchange)
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/resources/log4j2.properties b/components/camel-groovy-dsl/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..16b9193
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/resources/log4j2.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-groovy-dsl-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+logger.springframework.name = org.springframework
+logger.springframework.level = WARN
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/test/resources/mygroovy.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/test/resources/mygroovy.groovy b/components/camel-groovy-dsl/src/test/resources/mygroovy.groovy
new file mode 100644
index 0000000..371a3da
--- /dev/null
+++ b/components/camel-groovy-dsl/src/test/resources/mygroovy.groovy
@@ -0,0 +1,2 @@
+// this is code comments
+return "The result is " + body * 2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index d67c729..a40f233 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -46,6 +46,7 @@
<module>camel-spring-dm</module>
<module>camel-bam</module>
<module>camel-groovy</module>
+ <module>camel-groovy-dsl</module>
<module>camel-scala</module>
<module>camel-http-common</module>
<module>camel-http</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootStarterMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootStarterMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootStarterMojo.java
index 9e70080..2b6fef8 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootStarterMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootStarterMojo.java
@@ -81,13 +81,12 @@ import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNod
*/
public class SpringBootStarterMojo extends AbstractMojo {
-
private static final String[] IGNORE_MODULES = {
/* OSGi -> */ "camel-blueprint", "camel-core-osgi", "camel-eventadmin", "camel-paxlogging",
/* Java EE -> */ "camel-cdi", "camel-ejb",
/* deprecated (and not working perfectly) -> */ "camel-swagger", "camel-mina", "camel-ibatis", "camel-quartz",
/* currently incompatible */ "camel-jclouds", "camel-spark-rest",
- /* others (not managed) -> */ "camel-zipkin"};
+ /* others (not managed) -> */ "camel-groovy-dsl", "camel-zipkin"};
private static final boolean IGNORE_TEST_MODULES = true;
[4/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Posted by da...@apache.org.
CAMEL-10930: Move groovy dsl into camel-groovy-dsl
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91ff7db2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91ff7db2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91ff7db2
Branch: refs/heads/master
Commit: 91ff7db20e007e47440c1c045144f06143df1b27
Parents: 2a198c2
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 3 10:00:57 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Mar 3 10:00:57 2017 +0100
----------------------------------------------------------------------
components/camel-groovy/pom.xml | 114 +-----
.../camel-groovy/src/main/docs/groovy-dsl.adoc | 402 -------------------
.../groovy/converter/GPathResultConverter.java | 52 ---
.../camel/groovy/converter/TypeConverter.java | 83 ----
.../dataformat/AbstractXmlDataFormat.java | 104 -----
.../groovy/dataformat/XmlParserDataFormat.java | 65 ---
.../groovy/dataformat/XmlSlurperDataFormat.java | 55 ---
.../camel/groovy/extend/CamelGroovyMethods.java | 383 ------------------
.../extend/ClosureAggregationStrategy.java | 37 --
.../camel/groovy/extend/ClosureExpression.java | 46 ---
.../camel/groovy/extend/ClosureProcessor.java | 40 --
.../camel/groovy/extend/ClosureSupport.java | 39 --
.../language/groovy/CamelGroovyMethods.java | 63 ---
.../language/groovy/GroovyRouteBuilder.java | 35 --
.../META-INF/services/groovy/groovyMethods | 18 -
.../org.codehaus.groovy.runtime.ExtensionModule | 20 -
.../services/org/apache/camel/TypeConverter | 18 -
.../main/resources/dsld/CamelGroovyMethods.dsld | 110 -----
.../main/resources/gdsl/CamelGroovyMethods.gdsl | 110 -----
.../camel/language/groovy/ConfigureCamel.groovy | 48 ---
.../converter/GPathResultConverterTest.groovy | 70 ----
.../groovy/extend/CamelGroovyMethodsTest.groovy | 244 -----------
.../ClosureAggregationStrategyTest.groovy | 55 ---
.../groovy/extend/ClosureExpressionTest.groovy | 72 ----
.../groovy/extend/ClosureProcessorTest.groovy | 57 ---
.../language/groovy/GroovyExpressionTest.java | 2 +-
.../camel/language/groovy/GroovyTest.java | 72 ----
.../language/groovy/example/GroovyRoutes.groovy | 30 --
28 files changed, 2 insertions(+), 2442 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-groovy/pom.xml b/components/camel-groovy/pom.xml
index 1ffdfb2..8096742 100644
--- a/components/camel-groovy/pom.xml
+++ b/components/camel-groovy/pom.xml
@@ -87,116 +87,4 @@
</dependency>
</dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <!-- Eclipse m2e Lifecycle Management -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>${lifecycle-mapping-version}</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <versionRange>${maven-compiler-plugin-version}</versionRange>
- <goals>
- <goal>compile</goal>
- <goal>testCompile</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerId>groovy-eclipse-compiler</compilerId>
- <!-- set verbose to be true if you want lots of uninteresting messages -->
- <!-- <verbose>true</verbose> -->
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-eclipse-compiler</artifactId>
- <version>2.9.2-01</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-eclipse-batch</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-eclipse-batch</artifactId>
- <version>2.4.3-01</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <configuration>
- <additionalProjectnatures>
- <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
- </additionalProjectnatures>
- <classpathContainers>
- <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
- <classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
- </classpathContainers>
- </configuration>
- </plugin>
- </plugins>
- <!-- Need to explicitly specify test resources, otherwise maven eclipse plugin
- does not include src/test/groovy as source folder -->
- <testResources>
- <testResource>
- <directory>src/test/groovy</directory>
- </testResource>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
- </build>
-
- <profiles>
- <profile>
- <id>jdk9-build</id>
- <activation>
- <jdk>9</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <!--Skip compile on Java 9 https://issues.apache.org/jira/browse/CAMEL-10905 -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/docs/groovy-dsl.adoc
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/docs/groovy-dsl.adoc b/components/camel-groovy/src/main/docs/groovy-dsl.adoc
deleted file mode 100644
index 8f3c126..0000000
--- a/components/camel-groovy/src/main/docs/groovy-dsl.adoc
+++ /dev/null
@@ -1,402 +0,0 @@
-[[GroovyDSL-AbouttheGroovyDSL]]
-About the Groovy DSL
-^^^^^^^^^^^^^^^^^^^^
-
-The Groovy DSL implementation is built on top of the existing Java-based
-link:dsl.html[DSL], but it additionally allows to use Groovy language
-features in your routes, particularly
-http://www.groovy-lang.org/closures.html[Closures] acting as
-link:processor.html[Processor], link:expression.html[Expression],
-link:predicate.html[Predicate], or link:aggregator.html[Aggregation
-Strategy]. +
- With the Groovy DSL you write your RouteBuilder classes entirely in
-Groovy, while the link:scripting-languages.html[scripting component]
-allows to embed small scripts into Java routes. The Groovy DSL requires
-Groovy 2.0 or newer and is available as of *Camel 2.11*.
-
-[[GroovyDSL-Introduction]]
-Introduction
-^^^^^^^^^^^^
-
-Because Groovy is syntactically very similar to Java, you can write your
-Groovy routes just like Java routes. The same Java DSL classes are being
-used, with the exception that some of the DSL classes get extended with
-a bunch of new methods at runtime. This is achieved by turning
-camel-groovy into a Groovy
-http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module[Extension
-Module] that defines extension methods on existing classes.
-
-The majority of the extension methods allow
-http://www.groovy-lang.org/closures.html[Closures] to be used as
-parameters e.g. for expressions, predicates, processors. The following
-example reverses a string in the message body and then prints the value
-to System.out:
-
-*MyRouteBuilder.groovy*
-
-[source,java]
------------------------------------------
-...
- from('direct:test')
- .transform { it.in.body.reverse() }
- .process { println it.in.body }
-...
------------------------------------------
-
-The corresponding route in Java would look something like this:
-
-*MyRouteBuilder.java*
-
-[source,java]
------------------------------------------------------------------------------------------
-...
- from("direct:test")
- .transform(new Expression() {
- @Override
- public Object evaluate(Exchange e) {
- return new StringBuffer(e.getIn().getBody().toString()).reverse().toString();
- }
- })
- .process(new Processor() {
- @Override
- public void process(Exchange e) {
- System.out.println(e.getIn().getBody());
- }
- });
-...
------------------------------------------------------------------------------------------
-
-[[GroovyDSL-DevelopingwiththeGroovyDSL]]
-Developing with the Groovy DSL
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-To be able to use the Groovy DSL in your camel routes you need to add
-the a dependency on *camel-groovy* which implements the Groovy DSL.
-
-If you use Maven you can just add the following to your pom.xml,
-substituting the version number for the latest & greatest release (see
-the download page for the latest versions).
-
-[source,xml]
----------------------------------------
-<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-groovy</artifactId>
- <version>2.11.0</version>
-</dependency>
----------------------------------------
-
-Additionally you need to make sure that the Groovy classes will be
-compiled. You can either use gmaven for this or, particularly with mixed
-projects containing Java and Groovy code, you might want to use the
-http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven[Groovy
-Eclipse compiler]:
-
-[source,xml]
---------------------------------------------------------
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerId>groovy-eclipse-compiler</compilerId>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-eclipse-compiler</artifactId>
- <version>2.7.0-01</version>
- </dependency>
- </dependencies>
- </plugin>
---------------------------------------------------------
-
-As Eclipse user, you might want to configure the Maven Eclipse plugin in
-a way so that your project is set up correctly for using
-http://groovy.codehaus.org/Eclipse+Plugin[Eclipse Plugin for Groovy]
-when `mvn eclipse:eclipse` is executed:
-
-[source,xml]
-----------------------------------------------------------------------------------------
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <configuration>
- <additionalProjectnatures>
- <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
- </additionalProjectnatures>
- <classpathContainers>
- <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
- <classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
- </classpathContainers>
- </configuration>
- </plugin>
-----------------------------------------------------------------------------------------
-
-[[GroovyDSL-UsingClosuresinyourroutes]]
-Using Closures in your routes
-+++++++++++++++++++++++++++++
-
-Groovy closures can be used to write concise implementations of Camel
-processors, expressions, predicates, and aggregation strategies. It is
-recommended to keep more complicated implementations of these objects in
-their own classes, e.g. to be able to test them more easily and not to
-clutter up your routes with business logic.
-
-[[GroovyDSL-ProcessorClosures]]
-Processor Closures
-
-All Java DSL parameters of type `org.apache.camel.Processor` can be
-replaced by a closure that accepts an object of type
-`org.apache.camel.Exchange` as only parameter. The return value of the
-closure is disregarded. All closures may also refer to variables not
-listed in their parameter list. Example:
-
-[source,java]
-------------------------------------------------------------------------------
-...
- private String someValue
-...
- from('direct:test')
- .process { Exchange exchange -> println (exchange.in.body + someValue) }
- .process { println (it.in.body + someValue) } // equivalent
-...
-------------------------------------------------------------------------------
-
-[[GroovyDSL-ExpressionClosures]]
-Expression Closures
-
-All Java DSL parameters of type `org.apache.camel.Expression` can be
-replaced by a closure that accepts an object of type
-`org.apache.camel.Exchange` as only parameter. The return value of the
-closure is the result of the expression. Example:
-
-[source,java]
------------------------------------------------------
-...
- private String someValue
-...
- from('direct:test')
- .transform { it.in.body.reverse() + someValue }
- .setHeader("myHeader") { someValue.reverse() }
-...
------------------------------------------------------
-
-[[GroovyDSL-PredicateClosures]]
-Predicate Closures
-
-All Java DSL parameters of type `org.apache.camel.Predicate` can be
-replaced by a closure that accepts an object of type
-`org.apache.camel.Exchange` as only parameter. The return value of the
-closure is translated into a boolean value representing the result of
-the predicate. Example:
-
-[source,java]
-------------------------------------------------------
-...
- private String someValue
-
- // This time, the closure is stored in a variable
- def pred = { Exchange e -> e.in.body != someValue }
-...
- from('direct:test')
- .filter(pred)
-...
-------------------------------------------------------
-
-[[GroovyDSL-AggregationStrategyClosures]]
-Aggregation Strategy Closures
-
-Java DSL parameters of type
-`org.apache.camel.processor.aggregate.AggregationStrategy` can be
-replaced by a closure that accepts two objects of type
-`org.apache.camel.Exchange` representing the two Exchanges to be
-aggregated. The return value of the closure must be the aggregated
-Exchange. Example:
-
-[source,java]
--------------------------------------------------------------------------
-...
- private String separator
-...
- from('direct:test1')
- .enrich('direct:enrich') { Exchange original, Exchange resource ->
- original.in.body += resource.in.body + separator
- original // don't forget to return resulting exchange
- }
-...
--------------------------------------------------------------------------
-
-[[GroovyDSL-Genericclosurebridges]]
-Generic closure bridges
-
-In addition to the above-mentioned DSL extensions, you can use closures
-even if no DSL method signature with closure parameters is available.
-Assuming there's no `filter(Closure)` method, you could instead write:
-
-[source,java]
----------------------------------------------------------
-...
- private String someValue
-
- // This time, the closure is stored in a variable
- def pred = { Exchange e -> e.in.body != someValue }
-...
- from('direct:test')
- // predicate(Closure) -> org.apache.camel.Predicate
- .filter(predicate(pred))
-...
----------------------------------------------------------
-
-Similarly, `expression(Closure)` returns a Camel expression,
-`processor(Closure)` returns a Processor, and `aggregator(Closure)`
-returns an AggregationStrategy.
-
-[[GroovyDSL-UsingGroovyXMLprocessing]]
-Using Groovy XML processing
-+++++++++++++++++++++++++++
-
-Groovy provides special http://groovy-lang.org/processing-xml.html[XML
-processing support] through its `XmlParser`, `XmlNodePrinter` and
-`XmlSlurper` classes. camel-groovy provides two
-link:data-format.html[data formats] to use these classes directly in
-your routes.
-
-*Unmarshal XML with XmlParser*
-
-[source,java]
------------------------------------------------------
-...
- from('direct:test1')
- .unmarshal().gnode()
- // message body is now of type groovy.util.Node
-...
------------------------------------------------------
-
-By default, XML processing is _namespace-aware_. You can change this by
-providing a boolean `false` parameter.
-
-*Unmarshal XML with XmlSlurper*
-
-[source,java]
----------------------------------------------------------------------------
-...
- from('direct:test1')
- .unmarshal().gpath(false) // explicitly namespace-unaware
- // message body is now of type groovy.util.slurpersupport.GPathResult
-...
----------------------------------------------------------------------------
-
-Currently, marshalling is only supported for `groovy.util.Node` objects.
-
-*Marshal XML with XmlNodePrinter*
-
-[source,java]
-------------------------------------------------------
-...
- from('direct:test1')
- // message body must be of type groovy.util.Node
- .marshal().gnode()
-...
-------------------------------------------------------
-
-[[GroovyDSL-UsingGroovyGStrings]]
-Using Groovy GStrings
-+++++++++++++++++++++
-
-Groovy
-http://docs.groovy-lang.org/latest/html/documentation/index.html#all-strings[GStrings]
-are declared inside double-quotes and can contain arbitrary Groovy
-expressions like accessing properties or calling methods, e.g.
-
-[source,java]
------------------------------------------
-def x = "It is currently ${ new Date() }"
------------------------------------------
-
-Because GStrings aren't Strings, camel-groovy adds the necessary
-link:type-converter.html[TypeConverter] to automatically turn them into
-the required type.
-
-[[GroovyDSL-CustomDSLextensions]]
-Custom DSL extensions
-+++++++++++++++++++++
-
-You can easily define your custom extensions - be it as a Java DSL
-extension for your Groovy routes or for any other class unrelated to
-Camel. All you have to do is to write your extension methods and provide
-a extension module descriptor - the details are described in the
-http://www.groovy-lang.org/metaprogramming.html#_extension_modules[Groovy
-documentation]. And as long as you don't require other extension
-methods, you can even use plain Java code to achieve this! +
- As an example, let's write two DSL extensions to make commonly used DSL
-methods more concise:
-
-*MyExtension.java*
-
-[source,java]
--------------------------------------------------------------------------------------------------------------------------------
-import org.apache.camel.Endpoint;
-import org.apache.camel.Predicate;
-
-public final class MyExtension {
- private MyExtension() {
- // Utility Class
- }
-
- // Set the id of a route to its consumer URI
- public static RouteDefinition fromId(RouteDefinition delegate, String uri) {
- return delegate.from(uri).routeId(uri);
- }
-
- public static RouteDefinition fromId(RouteDefinition delegate, Endpoint endpoint) {
- return delegate.from(endpoint).routeId(endpoint.getEndpointUri());
- }
-
- // Make common choice pattern more concise
-
- public static ProcessorDefinition<?> fork(ProcessorDefinition<?> delegate, String uri1, String uri2, Predicate predicate) {
- return delegate.choice().when(predicate).to(uri1).otherwise().to(uri2);
- }
-
-}
--------------------------------------------------------------------------------------------------------------------------------
-
-Add a corresponding extension module descriptor to `META-INF/services`:
-
-*META-INF/services/org.codehaus.groovy.runtime.ExtensionModule*
-
-[source,java]
-----------------------------
-moduleName=my-extension
-moduleVersion=2.11
-extensionClasses=MyExtension
-staticExtensionClasses=
-----------------------------
-
-And now your Groovy route can look like this:
-
-*MyRoute.groovy*
-
-[source,java]
-------------------------------------------------------------
-...
- fromId('direct:test1')
- .fork('direct:null','direct:not-null',body().isNull())
-...
-------------------------------------------------------------
-
-Using the plain Java DSL, the route would look something like this:
-
-*MyRoute.java*
-
-[source,java]
------------------------------------
-...
- from("direct:test1")
- .routeId("direct:test1")
- .choice()
- .when(body().isNull())
- .to("direct:null")
- .otherwise()
- .to("direct:not-null");
-...
------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
deleted file mode 100644
index 6c7384e..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.converter;
-
-import java.io.IOException;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import groovy.util.XmlSlurper;
-import groovy.util.slurpersupport.GPathResult;
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.StringSource;
-import org.apache.camel.converter.jaxp.XmlConverter;
-
-@Converter
-public class GPathResultConverter {
-
- private final XmlConverter xmlConverter = new XmlConverter();
-
- @Converter
- public GPathResult fromString(String input) throws ParserConfigurationException, SAXException, IOException {
- return new XmlSlurper().parseText(input);
- }
-
- @Converter
- public GPathResult fromStringSource(StringSource input) throws IOException, SAXException, ParserConfigurationException {
- return fromString(input.getText());
- }
-
- @Converter
- public GPathResult fromNode(Node input, Exchange exchange) throws IOException, SAXException, ParserConfigurationException, TransformerException {
- return fromString(xmlConverter.toString(input, exchange));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
deleted file mode 100644
index d0bb945..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.converter;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-
-import groovy.lang.GString;
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.converter.IOConverter;
-import org.apache.camel.converter.ObjectConverter;
-
-/**
- * TypeConverter for Groovy GStrings.
- */
-@Converter
-public final class TypeConverter {
-
- private TypeConverter() {
-
- }
-
- @Converter
- public static InputStream toInputStream(GString value, Exchange exchange) throws IOException {
- return IOConverter.toInputStream(value.toString(), exchange);
- }
-
- @Converter
- public static byte[] toByteArray(GString value, Exchange exchange) throws IOException {
- return IOConverter.toByteArray(value.toString(), exchange);
- }
-
- @Converter
- public static StringReader toReader(GString value) {
- return IOConverter.toReader(value.toString());
- }
-
- @Converter
- public static char toChar(GString value) {
- return ObjectConverter.toChar(value.toString());
- }
-
- @Converter
- public static Integer toInteger(GString value) {
- return ObjectConverter.toInteger(value.toString());
- }
-
- @Converter
- public static Long toLong(GString value) {
- return ObjectConverter.toLong(value.toString());
- }
-
- @Converter
- public static Float toFloat(GString value) {
- return ObjectConverter.toFloat(value.toString());
- }
-
- @Converter
- public static Double toDouble(GString value) {
- return ObjectConverter.toDouble(value.toString());
- }
-
- @Converter
- public static Boolean toBoolean(GString value) {
- return ObjectConverter.toBoolean(value.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
deleted file mode 100644
index 9202059..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.dataformat;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import groovy.xml.FactorySupport;
-
-import org.apache.camel.spi.DataFormat;
-import org.apache.camel.support.ServiceSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Common attributes and methods for XmlParser and XmlSlurper usage.
- */
-public abstract class AbstractXmlDataFormat extends ServiceSupport implements DataFormat {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractXmlDataFormat.class);
- private static final ErrorHandler DEFAULT_HANDLER = new DefaultErrorHandler();
-
- private boolean namespaceAware = true;
- private boolean keepWhitespace;
- private ErrorHandler errorHandler = DEFAULT_HANDLER;
-
- public AbstractXmlDataFormat(boolean namespaceAware) {
- this.namespaceAware = namespaceAware;
- }
-
- protected SAXParser newSaxParser() throws Exception {
- SAXParserFactory factory = FactorySupport.createSaxParserFactory();
- factory.setNamespaceAware(namespaceAware);
- factory.setValidating(false);
- return factory.newSAXParser();
- }
-
- public ErrorHandler getErrorHandler() {
- return errorHandler;
- }
-
- public boolean isNamespaceAware() {
- return namespaceAware;
- }
-
- public void setNamespaceAware(boolean namespaceAware) {
- this.namespaceAware = namespaceAware;
- }
-
- public boolean isKeepWhitespace() {
- return keepWhitespace;
- }
-
- public void setKeepWhitespace(boolean keepWhitespace) {
- this.keepWhitespace = keepWhitespace;
- }
-
- private static class DefaultErrorHandler implements ErrorHandler {
-
- @Override
- public void warning(SAXParseException exception) throws SAXException {
- LOG.warn("Warning occured during parsing", exception);
- }
-
- @Override
- public void error(SAXParseException exception) throws SAXException {
- throw new SAXException(exception);
- }
-
- @Override
- public void fatalError(SAXParseException exception) throws SAXException {
- throw new SAXException(exception);
- }
-
- }
-
- @Override
- protected void doStart() throws Exception {
- // noop
- }
-
- @Override
- protected void doStop() throws Exception {
- // noop
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
deleted file mode 100644
index 44bf294..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.dataformat;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-import groovy.util.Node;
-import groovy.util.XmlNodePrinter;
-import groovy.util.XmlParser;
-import org.apache.camel.Exchange;
-
-/**
- * DataFormat for using groovy.util.XmlParser as parser and renderer for XML
- * data
- */
-public class XmlParserDataFormat extends AbstractXmlDataFormat {
-
- public XmlParserDataFormat() {
- this(true);
- }
-
- public XmlParserDataFormat(boolean namespaceAware) {
- super(namespaceAware);
- }
-
- @Override
- public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
- newPrinter(stream).print((Node) graph);
- }
-
- @Override
- public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
- return newParser().parse(stream);
- }
-
- private XmlParser newParser() throws Exception {
- XmlParser xmlParser = new XmlParser(newSaxParser());
- xmlParser.setErrorHandler(getErrorHandler());
- xmlParser.setTrimWhitespace(!isKeepWhitespace());
- return xmlParser;
- }
-
- private XmlNodePrinter newPrinter(OutputStream stream) {
- XmlNodePrinter xmlNodePrinter = new XmlNodePrinter(new PrintWriter(stream));
- xmlNodePrinter.setNamespaceAware(isNamespaceAware());
- return xmlNodePrinter;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
deleted file mode 100644
index 6b8bb68..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.dataformat;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import groovy.util.XmlSlurper;
-import org.apache.camel.Exchange;
-
-/**
- * DataFormat for using groovy.util.XmlSlurper as parser for XML data
- */
-public class XmlSlurperDataFormat extends AbstractXmlDataFormat {
-
- public XmlSlurperDataFormat() {
- this(true);
- }
-
- public XmlSlurperDataFormat(boolean namespaceAware) {
- super(namespaceAware);
- }
-
- @Override
- public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
- throw new UnsupportedOperationException("XmlSlurper does not support marshalling");
- }
-
- @Override
- public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
- return newSlurper().parse(stream);
- }
-
- private XmlSlurper newSlurper() throws Exception {
- XmlSlurper slurper = new XmlSlurper(newSaxParser());
- slurper.setErrorHandler(getErrorHandler());
- slurper.setKeepWhitespace(isKeepWhitespace());
- return slurper;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
deleted file mode 100644
index 79e84ee..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend;
-
-import java.lang.reflect.Method;
-
-import groovy.lang.Closure;
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.Predicate;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.DataFormatClause;
-import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.groovy.dataformat.XmlParserDataFormat;
-import org.apache.camel.groovy.dataformat.XmlSlurperDataFormat;
-import org.apache.camel.model.AggregateDefinition;
-import org.apache.camel.model.CatchDefinition;
-import org.apache.camel.model.ChoiceDefinition;
-import org.apache.camel.model.DataFormatDefinition;
-import org.apache.camel.model.DelayDefinition;
-import org.apache.camel.model.DynamicRouterDefinition;
-import org.apache.camel.model.FilterDefinition;
-import org.apache.camel.model.IdempotentConsumerDefinition;
-import org.apache.camel.model.InterceptDefinition;
-import org.apache.camel.model.InterceptSendToEndpointDefinition;
-import org.apache.camel.model.LoopDefinition;
-import org.apache.camel.model.MulticastDefinition;
-import org.apache.camel.model.OnCompletionDefinition;
-import org.apache.camel.model.OnExceptionDefinition;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.RecipientListDefinition;
-import org.apache.camel.model.ResequenceDefinition;
-import org.apache.camel.model.RoutingSlipDefinition;
-import org.apache.camel.model.SplitDefinition;
-import org.apache.camel.model.ThrottleDefinition;
-import org.apache.camel.model.TryDefinition;
-import org.apache.camel.model.WireTapDefinition;
-import org.apache.camel.processor.aggregate.AggregationStrategy;
-import org.apache.camel.spi.IdempotentRepository;
-import org.apache.camel.support.ExpressionSupport;
-
-/**
- * Extension class containing static methods that mainly allow to use Closures
- * instead of Predicates, Expressions, Processors, or AggregationStrategies
- */
-public final class CamelGroovyMethods {
-
- private CamelGroovyMethods() {
- // Utility Class
- }
-
- // Extension Methods that use Closures to encapsulate logic
-
- public static ProcessorDefinition<?> process(ProcessorDefinition<?> self,
- Closure<?> processorLogic) {
- return self.process(toProcessor(processorLogic));
- }
-
- public WireTapDefinition<?> newExchange(WireTapDefinition<?> self,
- Closure<?> processorLogic) {
- return self.newExchange(toProcessor(processorLogic));
- }
-
- public static OnExceptionDefinition onRedelivery(OnExceptionDefinition self,
- Closure<Exchange> processorLogic) {
- return self.onRedelivery(toProcessor(processorLogic));
- }
-
- public static ProcessorDefinition<?> enrich(ProcessorDefinition<?> self, String resourceUri,
- Closure<Exchange> aggregationLogic) {
- return self.enrich(resourceUri, toAggregationStrategy(aggregationLogic));
- }
-
- public static ProcessorDefinition<?> pollEnrich(ProcessorDefinition<?> self,
- String resourceUri, Closure<Exchange> aggregationLogic) {
- return self.pollEnrich(resourceUri, toAggregationStrategy(aggregationLogic));
- }
-
- public static ProcessorDefinition<?> pollEnrich(ProcessorDefinition<?> self,
- String resourceUri, long timeout, Closure<Exchange> aggregationLogic) {
- return self.pollEnrich(resourceUri, timeout, toAggregationStrategy(aggregationLogic));
- }
-
- public static MulticastDefinition aggregationStrategy(MulticastDefinition self,
- Closure<Exchange> aggregationLogic) {
- return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
- }
-
- public static RecipientListDefinition<?> aggregationStrategy(RecipientListDefinition<?> self,
- Closure<Exchange> aggregationLogic) {
- return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
- }
-
- public static SplitDefinition aggregationStrategy(SplitDefinition self,
- Closure<Exchange> aggregationLogic) {
- return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
- }
-
- public static AggregateDefinition aggregationStrategy(AggregateDefinition self,
- Closure<Exchange> aggregationLogic) {
- return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
- }
-
- public static MulticastDefinition onPrepare(MulticastDefinition self,
- Closure<Exchange> processorLogic) {
- return self.onPrepare(toProcessor(processorLogic));
- }
-
- public static RecipientListDefinition<?> onPrepare(RecipientListDefinition<?> self,
- Closure<Exchange> processorLogic) {
- return self.onPrepare(toProcessor(processorLogic));
- }
-
- public static SplitDefinition onPrepare(SplitDefinition self, Closure<Exchange> processorLogic) {
- return self.onPrepare(toProcessor(processorLogic));
- }
-
- public static WireTapDefinition<?> onPrepare(WireTapDefinition<?> self,
- Closure<Exchange> processorLogic) {
- return self.onPrepare(toProcessor(processorLogic));
- }
-
- // Extension Methods that use Closures as expressions
-
- public static ProcessorDefinition<?> script(ProcessorDefinition<?> self,
- Closure<?> expression) {
- return self.script(toExpression(expression));
- }
-
- public static ProcessorDefinition<?> transform(ProcessorDefinition<?> self,
- Closure<?> expression) {
- return self.transform(toExpression(expression));
- }
-
- public static ProcessorDefinition<?> setProperty(ProcessorDefinition<?> self, String name,
- Closure<?> expression) {
- return self.setProperty(name, toExpression(expression));
- }
-
- public static ProcessorDefinition<?> setHeader(ProcessorDefinition<?> self, String name,
- Closure<?> expression) {
- return self.setHeader(name, toExpression(expression));
- }
-
- public static ProcessorDefinition<?> setBody(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.setBody(toExpression(expression));
- }
-
- public static ProcessorDefinition<?> setFaultBody(ProcessorDefinition<?> self,
- Closure<?> expression) {
- return self.setFaultBody(toExpression(expression));
- }
-
- public static ProcessorDefinition<?> sort(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.sort(toExpression(expression));
- }
-
- public static IdempotentConsumerDefinition idempotentConsumer(ProcessorDefinition<?> self,
- Closure<?> expression) {
- return self.idempotentConsumer(toExpression(expression));
- }
-
- public static IdempotentConsumerDefinition idempotentConsumer(ProcessorDefinition<?> self,
- IdempotentRepository<?> rep, Closure<?> expression) {
- return self.idempotentConsumer(toExpression(expression), rep);
- }
-
- public static RecipientListDefinition<?> recipientList(ProcessorDefinition<?> self,
- Closure<?> recipients) {
- return self.recipientList(toExpression(recipients));
- }
-
- public static RecipientListDefinition<?> recipientList(ProcessorDefinition<?> self,
- String delimiter, Closure<?> recipients) {
- return self.recipientList(toExpression(recipients), delimiter);
- }
-
- public static RoutingSlipDefinition<?> routingSlip(ProcessorDefinition<?> self,
- Closure<?> recipients) {
- return self.routingSlip(toExpression(recipients));
- }
-
- public static RoutingSlipDefinition<?> routingSlip(ProcessorDefinition<?> self,
- String delimiter, Closure<?> recipients) {
- return self.routingSlip(toExpression(recipients), delimiter);
- }
-
- public static DynamicRouterDefinition<?> dynamicRouter(ProcessorDefinition<?> self,
- Closure<?> expression) {
- return self.dynamicRouter(toExpression(expression));
- }
-
- public static SplitDefinition split(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.split(toExpression(expression));
- }
-
- public static ResequenceDefinition resequence(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.resequence(toExpression(expression));
- }
-
- public static AggregateDefinition aggregate(ProcessorDefinition<?> self,
- Closure<?> correlationExpression) {
- return self.aggregate(toExpression(correlationExpression));
- }
-
- public static AggregateDefinition completionSize(AggregateDefinition self, Closure<?> expression) {
- return self.completionSize(toExpression(expression));
- }
-
- public static AggregateDefinition completionTimeout(AggregateDefinition self,
- Closure<?> expression) {
- return self.completionTimeout(toExpression(expression));
- }
-
- public static DelayDefinition delay(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.delay(toExpression(expression));
- }
-
- public static ThrottleDefinition throttle(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.throttle(toExpression(expression));
- }
-
- public static LoopDefinition loop(ProcessorDefinition<?> self, Closure<?> expression) {
- return self.loop(toExpression(expression));
- }
-
- public static WireTapDefinition<?> newExchangeBody(WireTapDefinition<?> self,
- Closure<?> expression) {
- return self.newExchangeBody(toExpression(expression));
- }
-
- public static WireTapDefinition<?> newExchangeHeader(WireTapDefinition<?> self, String header,
- Closure<?> expression) {
- return self.newExchangeHeader(header, toExpression(expression));
- }
-
- // Extension Methods that use Closures as predicates
-
- public static FilterDefinition filter(ProcessorDefinition<?> self, Closure<?> predicate) {
- return self.filter(toExpression(predicate));
- }
-
- public static ProcessorDefinition<?> validate(ProcessorDefinition<?> self, Closure<?> predicate) {
- return self.validate((Predicate) toExpression(predicate));
- }
-
- public static ChoiceDefinition when(ChoiceDefinition self, Closure<?> predicate) {
- return self.when(toExpression(predicate));
- }
-
- public static TryDefinition onWhen(TryDefinition self, Closure<?> predicate) {
- return self.onWhen(toExpression(predicate));
- }
-
- public static OnExceptionDefinition onWhen(OnExceptionDefinition self, Closure<?> predicate) {
- return self.onWhen(toExpression(predicate));
- }
-
- public static OnExceptionDefinition handled(OnExceptionDefinition self, Closure<?> predicate) {
- return self.handled((Predicate) toExpression(predicate));
- }
-
- public static OnExceptionDefinition continued(OnExceptionDefinition self, Closure<?> predicate) {
- return self.continued((Predicate) toExpression(predicate));
- }
-
- public static OnExceptionDefinition retryWhile(OnExceptionDefinition self, Closure<?> predicate) {
- return self.retryWhile(toExpression(predicate));
- }
-
- public static OnCompletionDefinition onWhen(OnCompletionDefinition self, Closure<?> predicate) {
- return self.onWhen(toExpression(predicate));
- }
-
- public static CatchDefinition onWhen(CatchDefinition self, Closure<?> predicate) {
- return self.onWhen(toExpression(predicate));
- }
-
- public static AggregateDefinition completionPredicate(AggregateDefinition self,
- Closure<?> predicate) {
- return self.completionPredicate(toExpression(predicate));
- }
-
- public static InterceptDefinition when(InterceptDefinition self, Closure<?> predicate) {
- return self.when(toExpression(predicate));
- }
-
- public static InterceptSendToEndpointDefinition when(InterceptSendToEndpointDefinition self,
- Closure<?> predicate) {
- return self.when(toExpression(predicate));
- }
-
- // Bridging generic attribution of expressions, predicates etc.
-
- public static AggregationStrategy aggregator(RouteBuilder self,
- Closure<Exchange> aggregationLogic) {
- return toAggregationStrategy(aggregationLogic);
- }
-
- public static Expression expression(RouteBuilder self, Closure<?> expression) {
- return toExpression(expression);
- }
-
- public static Predicate predicate(RouteBuilder self, Closure<?> predicate) {
- return toExpression(predicate);
- }
-
- public static Processor processor(RouteBuilder self, Closure<Exchange> processor) {
- return toProcessor(processor);
- }
-
- public static <T> T expression(ExpressionClause<T> self, Closure<?> expression) {
- return self.expression(toExpression(expression));
- }
-
- // Private Helpers
-
- static ExpressionSupport toExpression(final Closure<?> closure) {
- return new ClosureExpression(closure);
- }
-
- static Processor toProcessor(final Closure<?> closure) {
- return new ClosureProcessor(closure);
- }
-
- static AggregationStrategy toAggregationStrategy(final Closure<Exchange> closure) {
- return new ClosureAggregationStrategy(closure);
- }
-
- // Groovy-specific data formats
-
- public static ProcessorDefinition<?> gnode(DataFormatClause<?> self, boolean namespaceAware) {
- return dataFormat(self, parser(namespaceAware));
- }
-
- public static ProcessorDefinition<?> gnode(DataFormatClause<?> self) {
- return gnode(self, true);
- }
-
- public static ProcessorDefinition<?> gpath(DataFormatClause<?> self, boolean namespaceAware) {
- return dataFormat(self, slurper(namespaceAware));
- }
-
- public static ProcessorDefinition<?> gpath(DataFormatClause<?> self) {
- return gpath(self, true);
- }
-
- private static DataFormatDefinition slurper(boolean namespaceAware) {
- return new DataFormatDefinition(new XmlSlurperDataFormat(namespaceAware));
- }
-
- private static DataFormatDefinition parser(boolean namespaceAware) {
- return new DataFormatDefinition(new XmlParserDataFormat(namespaceAware));
- }
-
- // DataFormatClause.dataFormat(DataFormatDefinition) is private...
- private static ProcessorDefinition<?> dataFormat(DataFormatClause<?> self,
- DataFormatDefinition format) {
- try {
- Method m = self.getClass().getDeclaredMethod("dataFormat", DataFormatDefinition.class);
- m.setAccessible(true);
- return (ProcessorDefinition<?>) m.invoke(self, format);
- } catch (Exception e) {
- throw new IllegalArgumentException("Unknown DataFormat operation", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
deleted file mode 100644
index c290db8..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend;
-
-import groovy.lang.Closure;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.processor.aggregate.AggregationStrategy;
-
-class ClosureAggregationStrategy implements AggregationStrategy {
-
- private final Closure<Exchange> closure;
-
- ClosureAggregationStrategy(Closure<Exchange> closure) {
- this.closure = closure;
- }
-
- @Override
- public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
- return ClosureSupport.call(closure, oldExchange, newExchange);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
deleted file mode 100644
index 1309b7c..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend;
-
-import groovy.lang.Closure;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.support.ExpressionSupport;
-
-/**
- * Bridges a closure to ExpressionSupport
- */
-class ClosureExpression extends ExpressionSupport {
-
- private final Closure<?> closure;
-
- ClosureExpression(Closure<?> closure) {
- this.closure = closure;
- }
-
- @Override
- public <T> T evaluate(Exchange exchange, Class<T> type) {
- Object result = ClosureSupport.call(closure, exchange);
- return exchange.getContext().getTypeConverter().convertTo(type, result);
- }
-
- @Override
- protected String assertionFailureMessage(Exchange exchange) {
- return closure.toString();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
deleted file mode 100644
index 415543f..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend;
-
-import groovy.lang.Closure;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-
-/**
- * Bridges a Closure to a Processor
- */
-class ClosureProcessor implements Processor {
-
- private final Closure<?> closure;
-
- ClosureProcessor(Closure<?> closure) {
- this.closure = closure;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- ClosureSupport.call(closure, exchange);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java b/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
deleted file mode 100644
index be60ed2..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend;
-
-import groovy.lang.Closure;
-
-import org.codehaus.groovy.runtime.InvokerInvocationException;
-
-final class ClosureSupport {
-
- private ClosureSupport() {
- }
-
- static <T> T call(Closure<T> closure, Object... args) {
- try {
- return closure.call(args);
- } catch (InvokerInvocationException e) {
- if (e.getCause() instanceof RuntimeException) {
- throw (RuntimeException) e.getCause();
- } else {
- throw e;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/CamelGroovyMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/CamelGroovyMethods.java b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/CamelGroovyMethods.java
deleted file mode 100644
index bad1c28..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/CamelGroovyMethods.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.groovy;
-
-import groovy.lang.Closure;
-import org.apache.camel.Exchange;
-import org.apache.camel.model.ChoiceDefinition;
-import org.apache.camel.model.FilterDefinition;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.support.ExpressionSupport;
-
-/**
- * @version
- * @deprecated see {@link org.apache.camel.groovy.extend.CamelGroovyMethods} which is
- * used automatically
- */
-@Deprecated
-public final class CamelGroovyMethods {
- private CamelGroovyMethods() {
- // Utility Class
- }
-
- public static FilterDefinition filter(ProcessorDefinition<?> self, Closure<?> filter) {
- return self.filter(toExpression(filter));
- }
-
- public static ChoiceDefinition when(ChoiceDefinition self, Closure<?> filter) {
- return self.when(toExpression(filter));
- }
-
- public static ExpressionSupport toExpression(final Closure<?> filter) {
- return new ExpressionSupport() {
- protected String assertionFailureMessage(Exchange exchange) {
- return filter.toString();
- }
-
- public <T> T evaluate(Exchange exchange, Class<T> type) {
- Object result = filter.call(exchange);
- return exchange.getContext().getTypeConverter().convertTo(type, result);
- }
-
- @Override
- public String toString() {
- return "Groovy[" + filter + "]";
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
deleted file mode 100644
index a6f018c..0000000
--- a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.groovy;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * @deprecated the standard {@link RouteBuilder} can be used to write
- * Groovy routes.
- */
-@Deprecated
-public abstract class GroovyRouteBuilder extends RouteBuilder {
- public GroovyRouteBuilder() {
- }
-
- public GroovyRouteBuilder(CamelContext context) {
- super(context);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/META-INF/services/groovy/groovyMethods
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/META-INF/services/groovy/groovyMethods b/components/camel-groovy/src/main/resources/META-INF/services/groovy/groovyMethods
deleted file mode 100644
index 7043aed..0000000
--- a/components/camel-groovy/src/main/resources/META-INF/services/groovy/groovyMethods
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.camel.language.groovy.CamelGroovyMethods
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/components/camel-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
deleted file mode 100644
index 10db1bc..0000000
--- a/components/camel-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-moduleName=camel-groovy
-moduleVersion=2.15
-extensionClasses=org.apache.camel.groovy.extend.CamelGroovyMethods
-staticExtensionClasses=
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
deleted file mode 100644
index 8a0e315..0000000
--- a/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-org.apache.camel.groovy.converter.TypeConverter
-org.apache.camel.groovy.converter.GPathResultConverter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/dsld/CamelGroovyMethods.dsld
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/dsld/CamelGroovyMethods.dsld b/components/camel-groovy/src/main/resources/dsld/CamelGroovyMethods.dsld
deleted file mode 100644
index 3bb225a..0000000
--- a/components/camel-groovy/src/main/resources/dsld/CamelGroovyMethods.dsld
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*******************************************************************************/
- currentType(subType('org.apache.camel.model.ProcessorDefinition')).accept {
- method name : 'process', type : 'org.apache.camel.model.ProcessorDefinition', params: [processorLogic : 'groovy.lang.Closure']
- method name : 'enrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', aggregationLogic : 'groovy.lang.Closure']
- method name : 'pollEnrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', aggregationLogic : 'groovy.lang.Closure']
- method name : 'pollEnrich', type : 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri : 'java.lang.String', timeout : 'long', aggregationLogic : 'groovy.lang.Closure']
- method name : 'script', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'transform', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'setProperty', type : 'org.apache.camel.model.ProcessorDefinition', params: [name : 'java.lang.String', expression : 'groovy.lang.Closure']
- method name : 'setHeader', type : 'org.apache.camel.model.ProcessorDefinition', params: [name : 'java.lang.String', expression : 'groovy.lang.Closure']
- method name : 'setBody', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'setFaultBody', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'sort', type : 'org.apache.camel.model.ProcessorDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'idempotentConsumer', type : 'org.apache.camel.model.IdempotentConsumerDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'idempotentConsumer', type : 'org.apache.camel.model.IdempotentConsumerDefinition', params: [rep : 'org.apache.camel.spi.IdempotentRepository', expression : 'groovy.lang.Closure']
- method name : 'recipientList', type : 'org.apache.camel.model.RecipientListDefinition', params: [recipients : 'groovy.lang.Closure']
- method name : 'recipientList', type : 'org.apache.camel.model.RecipientListDefinition', params: [delimiter : 'java.lang.String', recipients : 'groovy.lang.Closure']
- method name : 'routingSlip', type : 'org.apache.camel.model.RoutingSlipDefinition', params: [recipients : 'groovy.lang.Closure']
- method name : 'routingSlip', type : 'org.apache.camel.model.RoutingSlipDefinition', params: [delimiter : 'java.lang.String', recipients : 'groovy.lang.Closure']
- method name : 'dynamicRouter', type : 'org.apache.camel.model.DynamicRouterDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'split', type : 'org.apache.camel.model.SplitDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'resequence', type : 'org.apache.camel.model.ResequenceDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'aggregate', type : 'org.apache.camel.model.AggregateDefinition', params: [correlationExpression : 'groovy.lang.Closure']
- method name : 'delay', type : 'org.apache.camel.model.DelayDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'throttle', type : 'org.apache.camel.model.ThrottleDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'loop', type : 'org.apache.camel.model.LoopDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'filter', type : 'org.apache.camel.model.FilterDefinition', params: [predicate : 'groovy.lang.Closure']
- method name : 'validate', type : 'org.apache.camel.model.ProcessorDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.groovy.extend.CamelGroovyMethods')).accept {
- method name : 'newExchange', type : 'org.apache.camel.model.WireTapDefinition', params: [self : 'org.apache.camel.model.WireTapDefinition', processorLogic : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.OnExceptionDefinition')).accept {
- method name : 'onRedelivery', type : 'org.apache.camel.model.OnExceptionDefinition', params: [processorLogic : 'groovy.lang.Closure']
- method name : 'onWhen', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
- method name : 'handled', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
- method name : 'continued', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
- method name : 'retryWhile', type : 'org.apache.camel.model.OnExceptionDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.MulticastDefinition')).accept {
- method name : 'aggregationStrategy', type : 'org.apache.camel.model.MulticastDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
- method name : 'onPrepare', type : 'org.apache.camel.model.MulticastDefinition', params: [processorLogic : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.RecipientListDefinition')).accept {
- method name : 'aggregationStrategy', type : 'org.apache.camel.model.RecipientListDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
- method name : 'onPrepare', type : 'org.apache.camel.model.RecipientListDefinition', params: [processorLogic : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.SplitDefinition')).accept {
- method name : 'aggregationStrategy', type : 'org.apache.camel.model.SplitDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
- method name : 'onPrepare', type : 'org.apache.camel.model.SplitDefinition', params: [processorLogic : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.AggregateDefinition')).accept {
- method name : 'aggregationStrategy', type : 'org.apache.camel.model.AggregateDefinition', params: [aggregationLogic : 'groovy.lang.Closure']
- method name : 'completionSize', type : 'org.apache.camel.model.AggregateDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'completionTimeout', type : 'org.apache.camel.model.AggregateDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'completionPredicate', type : 'org.apache.camel.model.AggregateDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.WireTapDefinition')).accept {
- method name : 'onPrepare', type : 'org.apache.camel.model.WireTapDefinition', params: [processorLogic : 'groovy.lang.Closure']
- method name : 'newExchangeBody', type : 'org.apache.camel.model.WireTapDefinition', params: [expression : 'groovy.lang.Closure']
- method name : 'newExchangeHeader', type : 'org.apache.camel.model.WireTapDefinition', params: [header : 'java.lang.String', expression : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.ChoiceDefinition')).accept {
- method name : 'when', type : 'org.apache.camel.model.ChoiceDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.TryDefinition')).accept {
- method name : 'onWhen', type : 'org.apache.camel.model.TryDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.OnCompletionDefinition')).accept {
- method name : 'onWhen', type : 'org.apache.camel.model.OnCompletionDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.CatchDefinition')).accept {
- method name : 'onWhen', type : 'org.apache.camel.model.CatchDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.InterceptDefinition')).accept {
- method name : 'when', type : 'org.apache.camel.model.InterceptDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.model.InterceptSendToEndpointDefinition')).accept {
- method name : 'when', type : 'org.apache.camel.model.InterceptSendToEndpointDefinition', params: [predicate : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.builder.RouteBuilder')).accept {
- method name : 'aggregator', type : 'org.apache.camel.processor.aggregate.AggregationStrategy', params: [aggregationLogic : 'groovy.lang.Closure']
- method name : 'expression', type : 'org.apache.camel.Expression', params: [expression : 'groovy.lang.Closure']
- method name : 'predicate', type : 'org.apache.camel.Predicate', params: [predicate : 'groovy.lang.Closure']
- method name : 'processor', type : 'org.apache.camel.Processor', params: [processor : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.builder.ExpressionClause')).accept {
- method name : 'expression', type : 'T', params: [expression : 'groovy.lang.Closure']
-}
- currentType(subType('org.apache.camel.builder.DataFormatClause')).accept {
- method name : 'gnode', type : 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware : 'boolean']
- method name : 'gnode', type : 'org.apache.camel.model.ProcessorDefinition'
- method name : 'gpath', type : 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware : 'boolean']
- method name : 'gpath', type : 'org.apache.camel.model.ProcessorDefinition'
-}
[6/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Posted by da...@apache.org.
CAMEL-10930: Move groovy dsl into camel-groovy-dsl
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/239f093a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/239f093a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/239f093a
Branch: refs/heads/master
Commit: 239f093a109bfef44ed964fdc17d26771e5b8cd2
Parents: 65d41c1
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 3 10:08:33 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Mar 3 10:08:33 2017 +0100
----------------------------------------------------------------------
components/camel-groovy-dsl/pom.xml | 4 ++++
components/readme.adoc | 4 +++-
docs/user-manual/en/SUMMARY.md | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/239f093a/components/camel-groovy-dsl/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/pom.xml b/components/camel-groovy-dsl/pom.xml
index e7e460d..4acd84a 100644
--- a/components/camel-groovy-dsl/pom.xml
+++ b/components/camel-groovy-dsl/pom.xml
@@ -30,6 +30,10 @@
<description>Camel Groovy DSL support</description>
<properties>
+ <!-- use by camel-catalog -->
+ <firstVersion>2.19.0</firstVersion>
+ <label>dsl</label>
+
<camel.osgi.import.pkg>
org.codehaus.groovy.runtime.callsite,
org.apache.camel.*;${camel.osgi.import.camel.version},
http://git-wip-us.apache.org/repos/asf/camel/blob/239f093a/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index 1d442f7..c21167c 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -840,7 +840,7 @@ Miscellaneous Components
^^^^^^^^^^^^^^^^^^^^^^^^
// others: START
-Number of Miscellaneous Components: 35
+Number of Miscellaneous Components: 36
[width="100%",cols="4,1,5",options="header"]
|=======================================================================
@@ -856,6 +856,8 @@ Number of Miscellaneous Components: 35
| link:camel-eclipse/src/main/docs/eclipse.adoc[Eclipse] (camel-eclipse) | 2.3 | *deprecated* Camel classpath scanning support for running in Eclipse Desktop Applications
+| link:camel-groovy-dsl/src/main/docs/groovy-dsl.adoc[Groovy Dsl] (camel-groovy-dsl) | 2.19 | *deprecated* Camel Groovy DSL support
+
| link:camel-guice/src/main/docs/guice.adoc[Guice] (camel-guice) | 1.5 | Using Camel with Guice
| link:camel-hawtdb/src/main/docs/hawtdb.adoc[Hawtdb] (camel-hawtdb) | 2.3 | *deprecated* Using HawtDB as persistent EIP store
http://git-wip-us.apache.org/repos/asf/camel/blob/239f093a/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 87a6600..f225177 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -331,6 +331,7 @@
* [CDI](cdi.adoc)
* [CXF Transport](cxf-transport.adoc)
* [Eclipse](eclipse.adoc)
+ * [Groovy Dsl](groovy-dsl.adoc)
* [Guice](guice.adoc)
* [Hawtdb](hawtdb.adoc)
* [Hystrix](hystrix.adoc)
[5/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Posted by da...@apache.org.
CAMEL-10930: Move groovy dsl into camel-groovy-dsl
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/65d41c16
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/65d41c16
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/65d41c16
Branch: refs/heads/master
Commit: 65d41c16ccf828c65d0233c99393b0bfcc583dc4
Parents: 91ff7db
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 3 10:03:48 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Mar 3 10:03:48 2017 +0100
----------------------------------------------------------------------
apache-camel/pom.xml | 4 ++++
apache-camel/src/main/descriptors/common-bin.xml | 1 +
.../src/main/resources/archetype-resources/pom.xml | 4 ++--
examples/camel-example-groovy/pom.xml | 2 +-
parent/pom.xml | 5 +++++
5 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/65d41c16/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index df1488c..a2300d3 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -347,6 +347,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-groovy-dsl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-guava-eventbus</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/65d41c16/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index e7f1b2b..c5187fd 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -97,6 +97,7 @@
<include>org.apache.camel:camel-google-pubsub</include>
<include>org.apache.camel:camel-gora</include>
<include>org.apache.camel:camel-groovy</include>
+ <include>org.apache.camel:camel-groovy-dsl</include>
<include>org.apache.camel:camel-guava-eventbus</include>
<include>org.apache.camel:camel-guice</include>
<include>org.apache.camel:camel-gson</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/65d41c16/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml b/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml
index 2327fe9..d1994c0 100644
--- a/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml
@@ -25,7 +25,7 @@
<packaging>jar</packaging>
<version>${version}</version>
- <name>A Groovy Camel Route</name>
+ <name>A Groovy DSL Camel Route</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-groovy</artifactId>
+ <artifactId>camel-groovy-dsl</artifactId>
</dependency>
<!-- used for jetty -->
http://git-wip-us.apache.org/repos/asf/camel/blob/65d41c16/examples/camel-example-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-groovy/pom.xml b/examples/camel-example-groovy/pom.xml
index 839996a..88139c2 100644
--- a/examples/camel-example-groovy/pom.xml
+++ b/examples/camel-example-groovy/pom.xml
@@ -42,7 +42,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-groovy</artifactId>
+ <artifactId>camel-groovy-dsl</artifactId>
</dependency>
<!-- used for jetty -->
http://git-wip-us.apache.org/repos/asf/camel/blob/65d41c16/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 869193b..4a1883e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1142,6 +1142,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-groovy-dsl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-guava-eventbus</artifactId>
<version>${project.version}</version>
</dependency>
[2/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Posted by da...@apache.org.
CAMEL-10930: Move groovy dsl into camel-groovy-dsl
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2a198c2f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2a198c2f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2a198c2f
Branch: refs/heads/master
Commit: 2a198c2f5db7f92df7c96774c907b69dd0114b65
Parents: 8a77898
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 3 09:56:14 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Mar 3 09:56:14 2017 +0100
----------------------------------------------------------------------
components/camel-groovy-dsl/pom.xml | 202 ++++++++++
.../src/main/docs/groovy-dsl.adoc | 402 +++++++++++++++++++
.../groovy/converter/GPathResultConverter.java | 51 +++
.../camel/groovy/converter/TypeConverter.java | 83 ++++
.../dataformat/AbstractXmlDataFormat.java | 102 +++++
.../groovy/dataformat/XmlParserDataFormat.java | 65 +++
.../groovy/dataformat/XmlSlurperDataFormat.java | 55 +++
.../camel/groovy/extend/CamelGroovyMethods.java | 383 ++++++++++++++++++
.../extend/ClosureAggregationStrategy.java | 37 ++
.../camel/groovy/extend/ClosureExpression.java | 46 +++
.../camel/groovy/extend/ClosureProcessor.java | 40 ++
.../camel/groovy/extend/ClosureSupport.java | 39 ++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../META-INF/services/camel/TypeConverter | 18 +
.../META-INF/services/groovy/groovyMethods | 18 +
.../org.codehaus.groovy.runtime.ExtensionModule | 20 +
.../main/resources/dsld/CamelGroovyMethods.dsld | 110 +++++
.../main/resources/gdsl/CamelGroovyMethods.gdsl | 110 +++++
.../camel/language/groovy/ConfigureCamel.groovy | 48 +++
.../groovy/extend/CamelGroovyMethodsTest.groovy | 244 +++++++++++
.../ClosureAggregationStrategyTest.groovy | 55 +++
.../groovy/extend/ClosureExpressionTest.groovy | 72 ++++
.../groovy/extend/ClosureProcessorTest.groovy | 57 +++
.../src/test/resources/log4j2.properties | 30 ++
.../src/test/resources/mygroovy.groovy | 2 +
components/pom.xml | 1 +
.../maven/packaging/SpringBootStarterMojo.java | 3 +-
28 files changed, 2505 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/pom.xml b/components/camel-groovy-dsl/pom.xml
new file mode 100644
index 0000000..e7e460d
--- /dev/null
+++ b/components/camel-groovy-dsl/pom.xml
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-groovy-dsl</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Groovy DSL (deprecated)</name>
+ <description>Camel Groovy DSL support</description>
+
+ <properties>
+ <camel.osgi.import.pkg>
+ org.codehaus.groovy.runtime.callsite,
+ org.apache.camel.*;${camel.osgi.import.camel.version},
+ ${camel.osgi.import.defaults},
+ *
+ </camel.osgi.import.pkg>
+ <camel.osgi.export.pkg>
+ org.apache.camel.groovy.converter.*,
+ org.apache.camel.groovy.dataformat.*,
+ org.apache.camel.groovy.extend.*
+ </camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- Eclipse m2e Lifecycle Management -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>${lifecycle-mapping-version}</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <versionRange>${maven-compiler-plugin-version}</versionRange>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ <!-- set verbose to be true if you want lots of uninteresting messages -->
+ <!-- <verbose>true</verbose> -->
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.9.2-01</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-batch</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-batch</artifactId>
+ <version>2.4.3-01</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
+ </additionalProjectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+ <classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+ </plugins>
+ <!-- Need to explicitly specify test resources, otherwise maven eclipse plugin
+ does not include src/test/groovy as source folder -->
+ <testResources>
+ <testResource>
+ <directory>src/test/groovy</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>jdk9-build</id>
+ <activation>
+ <jdk>9</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <!--Skip compile on Java 9 https://issues.apache.org/jira/browse/CAMEL-10905 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/docs/groovy-dsl.adoc
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/docs/groovy-dsl.adoc b/components/camel-groovy-dsl/src/main/docs/groovy-dsl.adoc
new file mode 100644
index 0000000..8f3c126
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/docs/groovy-dsl.adoc
@@ -0,0 +1,402 @@
+[[GroovyDSL-AbouttheGroovyDSL]]
+About the Groovy DSL
+^^^^^^^^^^^^^^^^^^^^
+
+The Groovy DSL implementation is built on top of the existing Java-based
+link:dsl.html[DSL], but it additionally allows to use Groovy language
+features in your routes, particularly
+http://www.groovy-lang.org/closures.html[Closures] acting as
+link:processor.html[Processor], link:expression.html[Expression],
+link:predicate.html[Predicate], or link:aggregator.html[Aggregation
+Strategy]. +
+ With the Groovy DSL you write your RouteBuilder classes entirely in
+Groovy, while the link:scripting-languages.html[scripting component]
+allows to embed small scripts into Java routes. The Groovy DSL requires
+Groovy 2.0 or newer and is available as of *Camel 2.11*.
+
+[[GroovyDSL-Introduction]]
+Introduction
+^^^^^^^^^^^^
+
+Because Groovy is syntactically very similar to Java, you can write your
+Groovy routes just like Java routes. The same Java DSL classes are being
+used, with the exception that some of the DSL classes get extended with
+a bunch of new methods at runtime. This is achieved by turning
+camel-groovy into a Groovy
+http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module[Extension
+Module] that defines extension methods on existing classes.
+
+The majority of the extension methods allow
+http://www.groovy-lang.org/closures.html[Closures] to be used as
+parameters e.g. for expressions, predicates, processors. The following
+example reverses a string in the message body and then prints the value
+to System.out:
+
+*MyRouteBuilder.groovy*
+
+[source,java]
+-----------------------------------------
+...
+ from('direct:test')
+ .transform { it.in.body.reverse() }
+ .process { println it.in.body }
+...
+-----------------------------------------
+
+The corresponding route in Java would look something like this:
+
+*MyRouteBuilder.java*
+
+[source,java]
+-----------------------------------------------------------------------------------------
+...
+ from("direct:test")
+ .transform(new Expression() {
+ @Override
+ public Object evaluate(Exchange e) {
+ return new StringBuffer(e.getIn().getBody().toString()).reverse().toString();
+ }
+ })
+ .process(new Processor() {
+ @Override
+ public void process(Exchange e) {
+ System.out.println(e.getIn().getBody());
+ }
+ });
+...
+-----------------------------------------------------------------------------------------
+
+[[GroovyDSL-DevelopingwiththeGroovyDSL]]
+Developing with the Groovy DSL
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To be able to use the Groovy DSL in your camel routes you need to add
+the a dependency on *camel-groovy* which implements the Groovy DSL.
+
+If you use Maven you can just add the following to your pom.xml,
+substituting the version number for the latest & greatest release (see
+the download page for the latest versions).
+
+[source,xml]
+---------------------------------------
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-groovy</artifactId>
+ <version>2.11.0</version>
+</dependency>
+---------------------------------------
+
+Additionally you need to make sure that the Groovy classes will be
+compiled. You can either use gmaven for this or, particularly with mixed
+projects containing Java and Groovy code, you might want to use the
+http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven[Groovy
+Eclipse compiler]:
+
+[source,xml]
+--------------------------------------------------------
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.7.0-01</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+--------------------------------------------------------
+
+As Eclipse user, you might want to configure the Maven Eclipse plugin in
+a way so that your project is set up correctly for using
+http://groovy.codehaus.org/Eclipse+Plugin[Eclipse Plugin for Groovy]
+when `mvn eclipse:eclipse` is executed:
+
+[source,xml]
+----------------------------------------------------------------------------------------
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
+ </additionalProjectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+ <classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+----------------------------------------------------------------------------------------
+
+[[GroovyDSL-UsingClosuresinyourroutes]]
+Using Closures in your routes
++++++++++++++++++++++++++++++
+
+Groovy closures can be used to write concise implementations of Camel
+processors, expressions, predicates, and aggregation strategies. It is
+recommended to keep more complicated implementations of these objects in
+their own classes, e.g. to be able to test them more easily and not to
+clutter up your routes with business logic.
+
+[[GroovyDSL-ProcessorClosures]]
+Processor Closures
+
+All Java DSL parameters of type `org.apache.camel.Processor` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is disregarded. All closures may also refer to variables not
+listed in their parameter list. Example:
+
+[source,java]
+------------------------------------------------------------------------------
+...
+ private String someValue
+...
+ from('direct:test')
+ .process { Exchange exchange -> println (exchange.in.body + someValue) }
+ .process { println (it.in.body + someValue) } // equivalent
+...
+------------------------------------------------------------------------------
+
+[[GroovyDSL-ExpressionClosures]]
+Expression Closures
+
+All Java DSL parameters of type `org.apache.camel.Expression` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is the result of the expression. Example:
+
+[source,java]
+-----------------------------------------------------
+...
+ private String someValue
+...
+ from('direct:test')
+ .transform { it.in.body.reverse() + someValue }
+ .setHeader("myHeader") { someValue.reverse() }
+...
+-----------------------------------------------------
+
+[[GroovyDSL-PredicateClosures]]
+Predicate Closures
+
+All Java DSL parameters of type `org.apache.camel.Predicate` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is translated into a boolean value representing the result of
+the predicate. Example:
+
+[source,java]
+------------------------------------------------------
+...
+ private String someValue
+
+ // This time, the closure is stored in a variable
+ def pred = { Exchange e -> e.in.body != someValue }
+...
+ from('direct:test')
+ .filter(pred)
+...
+------------------------------------------------------
+
+[[GroovyDSL-AggregationStrategyClosures]]
+Aggregation Strategy Closures
+
+Java DSL parameters of type
+`org.apache.camel.processor.aggregate.AggregationStrategy` can be
+replaced by a closure that accepts two objects of type
+`org.apache.camel.Exchange` representing the two Exchanges to be
+aggregated. The return value of the closure must be the aggregated
+Exchange. Example:
+
+[source,java]
+-------------------------------------------------------------------------
+...
+ private String separator
+...
+ from('direct:test1')
+ .enrich('direct:enrich') { Exchange original, Exchange resource ->
+ original.in.body += resource.in.body + separator
+ original // don't forget to return resulting exchange
+ }
+...
+-------------------------------------------------------------------------
+
+[[GroovyDSL-Genericclosurebridges]]
+Generic closure bridges
+
+In addition to the above-mentioned DSL extensions, you can use closures
+even if no DSL method signature with closure parameters is available.
+Assuming there's no `filter(Closure)` method, you could instead write:
+
+[source,java]
+---------------------------------------------------------
+...
+ private String someValue
+
+ // This time, the closure is stored in a variable
+ def pred = { Exchange e -> e.in.body != someValue }
+...
+ from('direct:test')
+ // predicate(Closure) -> org.apache.camel.Predicate
+ .filter(predicate(pred))
+...
+---------------------------------------------------------
+
+Similarly, `expression(Closure)` returns a Camel expression,
+`processor(Closure)` returns a Processor, and `aggregator(Closure)`
+returns an AggregationStrategy.
+
+[[GroovyDSL-UsingGroovyXMLprocessing]]
+Using Groovy XML processing
++++++++++++++++++++++++++++
+
+Groovy provides special http://groovy-lang.org/processing-xml.html[XML
+processing support] through its `XmlParser`, `XmlNodePrinter` and
+`XmlSlurper` classes. camel-groovy provides two
+link:data-format.html[data formats] to use these classes directly in
+your routes.
+
+*Unmarshal XML with XmlParser*
+
+[source,java]
+-----------------------------------------------------
+...
+ from('direct:test1')
+ .unmarshal().gnode()
+ // message body is now of type groovy.util.Node
+...
+-----------------------------------------------------
+
+By default, XML processing is _namespace-aware_. You can change this by
+providing a boolean `false` parameter.
+
+*Unmarshal XML with XmlSlurper*
+
+[source,java]
+---------------------------------------------------------------------------
+...
+ from('direct:test1')
+ .unmarshal().gpath(false) // explicitly namespace-unaware
+ // message body is now of type groovy.util.slurpersupport.GPathResult
+...
+---------------------------------------------------------------------------
+
+Currently, marshalling is only supported for `groovy.util.Node` objects.
+
+*Marshal XML with XmlNodePrinter*
+
+[source,java]
+------------------------------------------------------
+...
+ from('direct:test1')
+ // message body must be of type groovy.util.Node
+ .marshal().gnode()
+...
+------------------------------------------------------
+
+[[GroovyDSL-UsingGroovyGStrings]]
+Using Groovy GStrings
++++++++++++++++++++++
+
+Groovy
+http://docs.groovy-lang.org/latest/html/documentation/index.html#all-strings[GStrings]
+are declared inside double-quotes and can contain arbitrary Groovy
+expressions like accessing properties or calling methods, e.g.
+
+[source,java]
+-----------------------------------------
+def x = "It is currently ${ new Date() }"
+-----------------------------------------
+
+Because GStrings aren't Strings, camel-groovy adds the necessary
+link:type-converter.html[TypeConverter] to automatically turn them into
+the required type.
+
+[[GroovyDSL-CustomDSLextensions]]
+Custom DSL extensions
++++++++++++++++++++++
+
+You can easily define your custom extensions - be it as a Java DSL
+extension for your Groovy routes or for any other class unrelated to
+Camel. All you have to do is to write your extension methods and provide
+a extension module descriptor - the details are described in the
+http://www.groovy-lang.org/metaprogramming.html#_extension_modules[Groovy
+documentation]. And as long as you don't require other extension
+methods, you can even use plain Java code to achieve this! +
+ As an example, let's write two DSL extensions to make commonly used DSL
+methods more concise:
+
+*MyExtension.java*
+
+[source,java]
+-------------------------------------------------------------------------------------------------------------------------------
+import org.apache.camel.Endpoint;
+import org.apache.camel.Predicate;
+
+public final class MyExtension {
+ private MyExtension() {
+ // Utility Class
+ }
+
+ // Set the id of a route to its consumer URI
+ public static RouteDefinition fromId(RouteDefinition delegate, String uri) {
+ return delegate.from(uri).routeId(uri);
+ }
+
+ public static RouteDefinition fromId(RouteDefinition delegate, Endpoint endpoint) {
+ return delegate.from(endpoint).routeId(endpoint.getEndpointUri());
+ }
+
+ // Make common choice pattern more concise
+
+ public static ProcessorDefinition<?> fork(ProcessorDefinition<?> delegate, String uri1, String uri2, Predicate predicate) {
+ return delegate.choice().when(predicate).to(uri1).otherwise().to(uri2);
+ }
+
+}
+-------------------------------------------------------------------------------------------------------------------------------
+
+Add a corresponding extension module descriptor to `META-INF/services`:
+
+*META-INF/services/org.codehaus.groovy.runtime.ExtensionModule*
+
+[source,java]
+----------------------------
+moduleName=my-extension
+moduleVersion=2.11
+extensionClasses=MyExtension
+staticExtensionClasses=
+----------------------------
+
+And now your Groovy route can look like this:
+
+*MyRoute.groovy*
+
+[source,java]
+------------------------------------------------------------
+...
+ fromId('direct:test1')
+ .fork('direct:null','direct:not-null',body().isNull())
+...
+------------------------------------------------------------
+
+Using the plain Java DSL, the route would look something like this:
+
+*MyRoute.java*
+
+[source,java]
+-----------------------------------
+...
+ from("direct:test1")
+ .routeId("direct:test1")
+ .choice()
+ .when(body().isNull())
+ .to("direct:null")
+ .otherwise()
+ .to("direct:not-null");
+...
+-----------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
new file mode 100644
index 0000000..fdf4971
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.converter;
+
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import groovy.util.XmlSlurper;
+import groovy.util.slurpersupport.GPathResult;
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.StringSource;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+@Converter
+public class GPathResultConverter {
+
+ private final XmlConverter xmlConverter = new XmlConverter();
+
+ @Converter
+ public GPathResult fromString(String input) throws ParserConfigurationException, SAXException, IOException {
+ return new XmlSlurper().parseText(input);
+ }
+
+ @Converter
+ public GPathResult fromStringSource(StringSource input) throws IOException, SAXException, ParserConfigurationException {
+ return fromString(input.getText());
+ }
+
+ @Converter
+ public GPathResult fromNode(Node input, Exchange exchange) throws IOException, SAXException, ParserConfigurationException, TransformerException {
+ return fromString(xmlConverter.toString(input, exchange));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
new file mode 100644
index 0000000..d0bb945
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/converter/TypeConverter.java
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.converter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+
+import groovy.lang.GString;
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.converter.ObjectConverter;
+
+/**
+ * TypeConverter for Groovy GStrings.
+ */
+@Converter
+public final class TypeConverter {
+
+ private TypeConverter() {
+
+ }
+
+ @Converter
+ public static InputStream toInputStream(GString value, Exchange exchange) throws IOException {
+ return IOConverter.toInputStream(value.toString(), exchange);
+ }
+
+ @Converter
+ public static byte[] toByteArray(GString value, Exchange exchange) throws IOException {
+ return IOConverter.toByteArray(value.toString(), exchange);
+ }
+
+ @Converter
+ public static StringReader toReader(GString value) {
+ return IOConverter.toReader(value.toString());
+ }
+
+ @Converter
+ public static char toChar(GString value) {
+ return ObjectConverter.toChar(value.toString());
+ }
+
+ @Converter
+ public static Integer toInteger(GString value) {
+ return ObjectConverter.toInteger(value.toString());
+ }
+
+ @Converter
+ public static Long toLong(GString value) {
+ return ObjectConverter.toLong(value.toString());
+ }
+
+ @Converter
+ public static Float toFloat(GString value) {
+ return ObjectConverter.toFloat(value.toString());
+ }
+
+ @Converter
+ public static Double toDouble(GString value) {
+ return ObjectConverter.toDouble(value.toString());
+ }
+
+ @Converter
+ public static Boolean toBoolean(GString value) {
+ return ObjectConverter.toBoolean(value.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
new file mode 100644
index 0000000..b2b921e
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/AbstractXmlDataFormat.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.dataformat;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import groovy.xml.FactorySupport;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.support.ServiceSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Common attributes and methods for XmlParser and XmlSlurper usage.
+ */
+public abstract class AbstractXmlDataFormat extends ServiceSupport implements DataFormat {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractXmlDataFormat.class);
+ private static final ErrorHandler DEFAULT_HANDLER = new DefaultErrorHandler();
+
+ private boolean namespaceAware = true;
+ private boolean keepWhitespace;
+ private ErrorHandler errorHandler = DEFAULT_HANDLER;
+
+ public AbstractXmlDataFormat(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ protected SAXParser newSaxParser() throws Exception {
+ SAXParserFactory factory = FactorySupport.createSaxParserFactory();
+ factory.setNamespaceAware(namespaceAware);
+ factory.setValidating(false);
+ return factory.newSAXParser();
+ }
+
+ public ErrorHandler getErrorHandler() {
+ return errorHandler;
+ }
+
+ public boolean isNamespaceAware() {
+ return namespaceAware;
+ }
+
+ public void setNamespaceAware(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ public boolean isKeepWhitespace() {
+ return keepWhitespace;
+ }
+
+ public void setKeepWhitespace(boolean keepWhitespace) {
+ this.keepWhitespace = keepWhitespace;
+ }
+
+ private static class DefaultErrorHandler implements ErrorHandler {
+
+ @Override
+ public void warning(SAXParseException exception) throws SAXException {
+ LOG.warn("Warning occured during parsing", exception);
+ }
+
+ @Override
+ public void error(SAXParseException exception) throws SAXException {
+ throw new SAXException(exception);
+ }
+
+ @Override
+ public void fatalError(SAXParseException exception) throws SAXException {
+ throw new SAXException(exception);
+ }
+
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ // noop
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
new file mode 100644
index 0000000..44bf294
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlParserDataFormat.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.dataformat;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import groovy.util.Node;
+import groovy.util.XmlNodePrinter;
+import groovy.util.XmlParser;
+import org.apache.camel.Exchange;
+
+/**
+ * DataFormat for using groovy.util.XmlParser as parser and renderer for XML
+ * data
+ */
+public class XmlParserDataFormat extends AbstractXmlDataFormat {
+
+ public XmlParserDataFormat() {
+ this(true);
+ }
+
+ public XmlParserDataFormat(boolean namespaceAware) {
+ super(namespaceAware);
+ }
+
+ @Override
+ public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
+ newPrinter(stream).print((Node) graph);
+ }
+
+ @Override
+ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+ return newParser().parse(stream);
+ }
+
+ private XmlParser newParser() throws Exception {
+ XmlParser xmlParser = new XmlParser(newSaxParser());
+ xmlParser.setErrorHandler(getErrorHandler());
+ xmlParser.setTrimWhitespace(!isKeepWhitespace());
+ return xmlParser;
+ }
+
+ private XmlNodePrinter newPrinter(OutputStream stream) {
+ XmlNodePrinter xmlNodePrinter = new XmlNodePrinter(new PrintWriter(stream));
+ xmlNodePrinter.setNamespaceAware(isNamespaceAware());
+ return xmlNodePrinter;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
new file mode 100644
index 0000000..6b8bb68
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/dataformat/XmlSlurperDataFormat.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.dataformat;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import groovy.util.XmlSlurper;
+import org.apache.camel.Exchange;
+
+/**
+ * DataFormat for using groovy.util.XmlSlurper as parser for XML data
+ */
+public class XmlSlurperDataFormat extends AbstractXmlDataFormat {
+
+ public XmlSlurperDataFormat() {
+ this(true);
+ }
+
+ public XmlSlurperDataFormat(boolean namespaceAware) {
+ super(namespaceAware);
+ }
+
+ @Override
+ public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
+ throw new UnsupportedOperationException("XmlSlurper does not support marshalling");
+ }
+
+ @Override
+ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+ return newSlurper().parse(stream);
+ }
+
+ private XmlSlurper newSlurper() throws Exception {
+ XmlSlurper slurper = new XmlSlurper(newSaxParser());
+ slurper.setErrorHandler(getErrorHandler());
+ slurper.setKeepWhitespace(isKeepWhitespace());
+ return slurper;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
new file mode 100644
index 0000000..79e84ee
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/CamelGroovyMethods.java
@@ -0,0 +1,383 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend;
+
+import java.lang.reflect.Method;
+
+import groovy.lang.Closure;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.DataFormatClause;
+import org.apache.camel.builder.ExpressionClause;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.groovy.dataformat.XmlParserDataFormat;
+import org.apache.camel.groovy.dataformat.XmlSlurperDataFormat;
+import org.apache.camel.model.AggregateDefinition;
+import org.apache.camel.model.CatchDefinition;
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.DataFormatDefinition;
+import org.apache.camel.model.DelayDefinition;
+import org.apache.camel.model.DynamicRouterDefinition;
+import org.apache.camel.model.FilterDefinition;
+import org.apache.camel.model.IdempotentConsumerDefinition;
+import org.apache.camel.model.InterceptDefinition;
+import org.apache.camel.model.InterceptSendToEndpointDefinition;
+import org.apache.camel.model.LoopDefinition;
+import org.apache.camel.model.MulticastDefinition;
+import org.apache.camel.model.OnCompletionDefinition;
+import org.apache.camel.model.OnExceptionDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RecipientListDefinition;
+import org.apache.camel.model.ResequenceDefinition;
+import org.apache.camel.model.RoutingSlipDefinition;
+import org.apache.camel.model.SplitDefinition;
+import org.apache.camel.model.ThrottleDefinition;
+import org.apache.camel.model.TryDefinition;
+import org.apache.camel.model.WireTapDefinition;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.support.ExpressionSupport;
+
+/**
+ * Extension class containing static methods that mainly allow to use Closures
+ * instead of Predicates, Expressions, Processors, or AggregationStrategies
+ */
+public final class CamelGroovyMethods {
+
+ private CamelGroovyMethods() {
+ // Utility Class
+ }
+
+ // Extension Methods that use Closures to encapsulate logic
+
+ public static ProcessorDefinition<?> process(ProcessorDefinition<?> self,
+ Closure<?> processorLogic) {
+ return self.process(toProcessor(processorLogic));
+ }
+
+ public WireTapDefinition<?> newExchange(WireTapDefinition<?> self,
+ Closure<?> processorLogic) {
+ return self.newExchange(toProcessor(processorLogic));
+ }
+
+ public static OnExceptionDefinition onRedelivery(OnExceptionDefinition self,
+ Closure<Exchange> processorLogic) {
+ return self.onRedelivery(toProcessor(processorLogic));
+ }
+
+ public static ProcessorDefinition<?> enrich(ProcessorDefinition<?> self, String resourceUri,
+ Closure<Exchange> aggregationLogic) {
+ return self.enrich(resourceUri, toAggregationStrategy(aggregationLogic));
+ }
+
+ public static ProcessorDefinition<?> pollEnrich(ProcessorDefinition<?> self,
+ String resourceUri, Closure<Exchange> aggregationLogic) {
+ return self.pollEnrich(resourceUri, toAggregationStrategy(aggregationLogic));
+ }
+
+ public static ProcessorDefinition<?> pollEnrich(ProcessorDefinition<?> self,
+ String resourceUri, long timeout, Closure<Exchange> aggregationLogic) {
+ return self.pollEnrich(resourceUri, timeout, toAggregationStrategy(aggregationLogic));
+ }
+
+ public static MulticastDefinition aggregationStrategy(MulticastDefinition self,
+ Closure<Exchange> aggregationLogic) {
+ return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
+ }
+
+ public static RecipientListDefinition<?> aggregationStrategy(RecipientListDefinition<?> self,
+ Closure<Exchange> aggregationLogic) {
+ return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
+ }
+
+ public static SplitDefinition aggregationStrategy(SplitDefinition self,
+ Closure<Exchange> aggregationLogic) {
+ return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
+ }
+
+ public static AggregateDefinition aggregationStrategy(AggregateDefinition self,
+ Closure<Exchange> aggregationLogic) {
+ return self.aggregationStrategy(toAggregationStrategy(aggregationLogic));
+ }
+
+ public static MulticastDefinition onPrepare(MulticastDefinition self,
+ Closure<Exchange> processorLogic) {
+ return self.onPrepare(toProcessor(processorLogic));
+ }
+
+ public static RecipientListDefinition<?> onPrepare(RecipientListDefinition<?> self,
+ Closure<Exchange> processorLogic) {
+ return self.onPrepare(toProcessor(processorLogic));
+ }
+
+ public static SplitDefinition onPrepare(SplitDefinition self, Closure<Exchange> processorLogic) {
+ return self.onPrepare(toProcessor(processorLogic));
+ }
+
+ public static WireTapDefinition<?> onPrepare(WireTapDefinition<?> self,
+ Closure<Exchange> processorLogic) {
+ return self.onPrepare(toProcessor(processorLogic));
+ }
+
+ // Extension Methods that use Closures as expressions
+
+ public static ProcessorDefinition<?> script(ProcessorDefinition<?> self,
+ Closure<?> expression) {
+ return self.script(toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> transform(ProcessorDefinition<?> self,
+ Closure<?> expression) {
+ return self.transform(toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> setProperty(ProcessorDefinition<?> self, String name,
+ Closure<?> expression) {
+ return self.setProperty(name, toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> setHeader(ProcessorDefinition<?> self, String name,
+ Closure<?> expression) {
+ return self.setHeader(name, toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> setBody(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.setBody(toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> setFaultBody(ProcessorDefinition<?> self,
+ Closure<?> expression) {
+ return self.setFaultBody(toExpression(expression));
+ }
+
+ public static ProcessorDefinition<?> sort(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.sort(toExpression(expression));
+ }
+
+ public static IdempotentConsumerDefinition idempotentConsumer(ProcessorDefinition<?> self,
+ Closure<?> expression) {
+ return self.idempotentConsumer(toExpression(expression));
+ }
+
+ public static IdempotentConsumerDefinition idempotentConsumer(ProcessorDefinition<?> self,
+ IdempotentRepository<?> rep, Closure<?> expression) {
+ return self.idempotentConsumer(toExpression(expression), rep);
+ }
+
+ public static RecipientListDefinition<?> recipientList(ProcessorDefinition<?> self,
+ Closure<?> recipients) {
+ return self.recipientList(toExpression(recipients));
+ }
+
+ public static RecipientListDefinition<?> recipientList(ProcessorDefinition<?> self,
+ String delimiter, Closure<?> recipients) {
+ return self.recipientList(toExpression(recipients), delimiter);
+ }
+
+ public static RoutingSlipDefinition<?> routingSlip(ProcessorDefinition<?> self,
+ Closure<?> recipients) {
+ return self.routingSlip(toExpression(recipients));
+ }
+
+ public static RoutingSlipDefinition<?> routingSlip(ProcessorDefinition<?> self,
+ String delimiter, Closure<?> recipients) {
+ return self.routingSlip(toExpression(recipients), delimiter);
+ }
+
+ public static DynamicRouterDefinition<?> dynamicRouter(ProcessorDefinition<?> self,
+ Closure<?> expression) {
+ return self.dynamicRouter(toExpression(expression));
+ }
+
+ public static SplitDefinition split(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.split(toExpression(expression));
+ }
+
+ public static ResequenceDefinition resequence(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.resequence(toExpression(expression));
+ }
+
+ public static AggregateDefinition aggregate(ProcessorDefinition<?> self,
+ Closure<?> correlationExpression) {
+ return self.aggregate(toExpression(correlationExpression));
+ }
+
+ public static AggregateDefinition completionSize(AggregateDefinition self, Closure<?> expression) {
+ return self.completionSize(toExpression(expression));
+ }
+
+ public static AggregateDefinition completionTimeout(AggregateDefinition self,
+ Closure<?> expression) {
+ return self.completionTimeout(toExpression(expression));
+ }
+
+ public static DelayDefinition delay(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.delay(toExpression(expression));
+ }
+
+ public static ThrottleDefinition throttle(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.throttle(toExpression(expression));
+ }
+
+ public static LoopDefinition loop(ProcessorDefinition<?> self, Closure<?> expression) {
+ return self.loop(toExpression(expression));
+ }
+
+ public static WireTapDefinition<?> newExchangeBody(WireTapDefinition<?> self,
+ Closure<?> expression) {
+ return self.newExchangeBody(toExpression(expression));
+ }
+
+ public static WireTapDefinition<?> newExchangeHeader(WireTapDefinition<?> self, String header,
+ Closure<?> expression) {
+ return self.newExchangeHeader(header, toExpression(expression));
+ }
+
+ // Extension Methods that use Closures as predicates
+
+ public static FilterDefinition filter(ProcessorDefinition<?> self, Closure<?> predicate) {
+ return self.filter(toExpression(predicate));
+ }
+
+ public static ProcessorDefinition<?> validate(ProcessorDefinition<?> self, Closure<?> predicate) {
+ return self.validate((Predicate) toExpression(predicate));
+ }
+
+ public static ChoiceDefinition when(ChoiceDefinition self, Closure<?> predicate) {
+ return self.when(toExpression(predicate));
+ }
+
+ public static TryDefinition onWhen(TryDefinition self, Closure<?> predicate) {
+ return self.onWhen(toExpression(predicate));
+ }
+
+ public static OnExceptionDefinition onWhen(OnExceptionDefinition self, Closure<?> predicate) {
+ return self.onWhen(toExpression(predicate));
+ }
+
+ public static OnExceptionDefinition handled(OnExceptionDefinition self, Closure<?> predicate) {
+ return self.handled((Predicate) toExpression(predicate));
+ }
+
+ public static OnExceptionDefinition continued(OnExceptionDefinition self, Closure<?> predicate) {
+ return self.continued((Predicate) toExpression(predicate));
+ }
+
+ public static OnExceptionDefinition retryWhile(OnExceptionDefinition self, Closure<?> predicate) {
+ return self.retryWhile(toExpression(predicate));
+ }
+
+ public static OnCompletionDefinition onWhen(OnCompletionDefinition self, Closure<?> predicate) {
+ return self.onWhen(toExpression(predicate));
+ }
+
+ public static CatchDefinition onWhen(CatchDefinition self, Closure<?> predicate) {
+ return self.onWhen(toExpression(predicate));
+ }
+
+ public static AggregateDefinition completionPredicate(AggregateDefinition self,
+ Closure<?> predicate) {
+ return self.completionPredicate(toExpression(predicate));
+ }
+
+ public static InterceptDefinition when(InterceptDefinition self, Closure<?> predicate) {
+ return self.when(toExpression(predicate));
+ }
+
+ public static InterceptSendToEndpointDefinition when(InterceptSendToEndpointDefinition self,
+ Closure<?> predicate) {
+ return self.when(toExpression(predicate));
+ }
+
+ // Bridging generic attribution of expressions, predicates etc.
+
+ public static AggregationStrategy aggregator(RouteBuilder self,
+ Closure<Exchange> aggregationLogic) {
+ return toAggregationStrategy(aggregationLogic);
+ }
+
+ public static Expression expression(RouteBuilder self, Closure<?> expression) {
+ return toExpression(expression);
+ }
+
+ public static Predicate predicate(RouteBuilder self, Closure<?> predicate) {
+ return toExpression(predicate);
+ }
+
+ public static Processor processor(RouteBuilder self, Closure<Exchange> processor) {
+ return toProcessor(processor);
+ }
+
+ public static <T> T expression(ExpressionClause<T> self, Closure<?> expression) {
+ return self.expression(toExpression(expression));
+ }
+
+ // Private Helpers
+
+ static ExpressionSupport toExpression(final Closure<?> closure) {
+ return new ClosureExpression(closure);
+ }
+
+ static Processor toProcessor(final Closure<?> closure) {
+ return new ClosureProcessor(closure);
+ }
+
+ static AggregationStrategy toAggregationStrategy(final Closure<Exchange> closure) {
+ return new ClosureAggregationStrategy(closure);
+ }
+
+ // Groovy-specific data formats
+
+ public static ProcessorDefinition<?> gnode(DataFormatClause<?> self, boolean namespaceAware) {
+ return dataFormat(self, parser(namespaceAware));
+ }
+
+ public static ProcessorDefinition<?> gnode(DataFormatClause<?> self) {
+ return gnode(self, true);
+ }
+
+ public static ProcessorDefinition<?> gpath(DataFormatClause<?> self, boolean namespaceAware) {
+ return dataFormat(self, slurper(namespaceAware));
+ }
+
+ public static ProcessorDefinition<?> gpath(DataFormatClause<?> self) {
+ return gpath(self, true);
+ }
+
+ private static DataFormatDefinition slurper(boolean namespaceAware) {
+ return new DataFormatDefinition(new XmlSlurperDataFormat(namespaceAware));
+ }
+
+ private static DataFormatDefinition parser(boolean namespaceAware) {
+ return new DataFormatDefinition(new XmlParserDataFormat(namespaceAware));
+ }
+
+ // DataFormatClause.dataFormat(DataFormatDefinition) is private...
+ private static ProcessorDefinition<?> dataFormat(DataFormatClause<?> self,
+ DataFormatDefinition format) {
+ try {
+ Method m = self.getClass().getDeclaredMethod("dataFormat", DataFormatDefinition.class);
+ m.setAccessible(true);
+ return (ProcessorDefinition<?>) m.invoke(self, format);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Unknown DataFormat operation", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
new file mode 100644
index 0000000..c290db8
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureAggregationStrategy.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend;
+
+import groovy.lang.Closure;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+
+class ClosureAggregationStrategy implements AggregationStrategy {
+
+ private final Closure<Exchange> closure;
+
+ ClosureAggregationStrategy(Closure<Exchange> closure) {
+ this.closure = closure;
+ }
+
+ @Override
+ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+ return ClosureSupport.call(closure, oldExchange, newExchange);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
new file mode 100644
index 0000000..1309b7c
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureExpression.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend;
+
+import groovy.lang.Closure;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.support.ExpressionSupport;
+
+/**
+ * Bridges a closure to ExpressionSupport
+ */
+class ClosureExpression extends ExpressionSupport {
+
+ private final Closure<?> closure;
+
+ ClosureExpression(Closure<?> closure) {
+ this.closure = closure;
+ }
+
+ @Override
+ public <T> T evaluate(Exchange exchange, Class<T> type) {
+ Object result = ClosureSupport.call(closure, exchange);
+ return exchange.getContext().getTypeConverter().convertTo(type, result);
+ }
+
+ @Override
+ protected String assertionFailureMessage(Exchange exchange) {
+ return closure.toString();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
new file mode 100644
index 0000000..415543f
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureProcessor.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend;
+
+import groovy.lang.Closure;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * Bridges a Closure to a Processor
+ */
+class ClosureProcessor implements Processor {
+
+ private final Closure<?> closure;
+
+ ClosureProcessor(Closure<?> closure) {
+ this.closure = closure;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ ClosureSupport.call(closure, exchange);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
new file mode 100644
index 0000000..be60ed2
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/java/org/apache/camel/groovy/extend/ClosureSupport.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.groovy.extend;
+
+import groovy.lang.Closure;
+
+import org.codehaus.groovy.runtime.InvokerInvocationException;
+
+final class ClosureSupport {
+
+ private ClosureSupport() {
+ }
+
+ static <T> T call(Closure<T> closure, Object... args) {
+ try {
+ return closure.call(args);
+ } catch (InvokerInvocationException e) {
+ if (e.getCause() instanceof RuntimeException) {
+ throw (RuntimeException) e.getCause();
+ } else {
+ throw e;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/META-INF/LICENSE.txt b/components/camel-groovy-dsl/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/META-INF/NOTICE.txt b/components/camel-groovy-dsl/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/META-INF/services/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/META-INF/services/camel/TypeConverter b/components/camel-groovy-dsl/src/main/resources/META-INF/services/camel/TypeConverter
new file mode 100644
index 0000000..8a0e315
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/META-INF/services/camel/TypeConverter
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+org.apache.camel.groovy.converter.TypeConverter
+org.apache.camel.groovy.converter.GPathResultConverter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/META-INF/services/groovy/groovyMethods
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/META-INF/services/groovy/groovyMethods b/components/camel-groovy-dsl/src/main/resources/META-INF/services/groovy/groovyMethods
new file mode 100644
index 0000000..7043aed
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/META-INF/services/groovy/groovyMethods
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.camel.language.groovy.CamelGroovyMethods
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/2a198c2f/components/camel-groovy-dsl/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
----------------------------------------------------------------------
diff --git a/components/camel-groovy-dsl/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/components/camel-groovy-dsl/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
new file mode 100644
index 0000000..10db1bc
--- /dev/null
+++ b/components/camel-groovy-dsl/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+moduleName=camel-groovy
+moduleVersion=2.15
+extensionClasses=org.apache.camel.groovy.extend.CamelGroovyMethods
+staticExtensionClasses=
\ No newline at end of file
[3/6] camel git commit: CAMEL-10930: Move groovy dsl into
camel-groovy-dsl
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/gdsl/CamelGroovyMethods.gdsl
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/gdsl/CamelGroovyMethods.gdsl b/components/camel-groovy/src/main/resources/gdsl/CamelGroovyMethods.gdsl
deleted file mode 100644
index eac8545..0000000
--- a/components/camel-groovy/src/main/resources/gdsl/CamelGroovyMethods.gdsl
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*******************************************************************************/
-contributor([context(ctype: 'org.apache.camel.model.ProcessorDefinition')]) {
- method name: 'process', type: 'org.apache.camel.model.ProcessorDefinition', params: [processorLogic: 'groovy.lang.Closure']
- method name: 'enrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', aggregationLogic: 'groovy.lang.Closure']
- method name: 'pollEnrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', aggregationLogic: 'groovy.lang.Closure']
- method name: 'pollEnrich', type: 'org.apache.camel.model.ProcessorDefinition', params: [resourceUri: 'java.lang.String', timeout: 'long', aggregationLogic: 'groovy.lang.Closure']
- method name: 'script', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'transform', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'setProperty', type: 'org.apache.camel.model.ProcessorDefinition', params: [name: 'java.lang.String', expression: 'groovy.lang.Closure']
- method name: 'setHeader', type: 'org.apache.camel.model.ProcessorDefinition', params: [name: 'java.lang.String', expression: 'groovy.lang.Closure']
- method name: 'setBody', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'setFaultBody', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'sort', type: 'org.apache.camel.model.ProcessorDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'idempotentConsumer', type: 'org.apache.camel.model.IdempotentConsumerDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'idempotentConsumer', type: 'org.apache.camel.model.IdempotentConsumerDefinition', params: [rep: 'org.apache.camel.spi.IdempotentRepository', expression: 'groovy.lang.Closure']
- method name: 'recipientList', type: 'org.apache.camel.model.RecipientListDefinition', params: [recipients: 'groovy.lang.Closure']
- method name: 'recipientList', type: 'org.apache.camel.model.RecipientListDefinition', params: [delimiter: 'java.lang.String', recipients: 'groovy.lang.Closure']
- method name: 'routingSlip', type: 'org.apache.camel.model.RoutingSlipDefinition', params: [recipients: 'groovy.lang.Closure']
- method name: 'routingSlip', type: 'org.apache.camel.model.RoutingSlipDefinition', params: [delimiter: 'java.lang.String', recipients: 'groovy.lang.Closure']
- method name: 'dynamicRouter', type: 'org.apache.camel.model.DynamicRouterDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'split', type: 'org.apache.camel.model.SplitDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'resequence', type: 'org.apache.camel.model.ResequenceDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'aggregate', type: 'org.apache.camel.model.AggregateDefinition', params: [correlationExpression: 'groovy.lang.Closure']
- method name: 'delay', type: 'org.apache.camel.model.DelayDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'throttle', type: 'org.apache.camel.model.ThrottleDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'loop', type: 'org.apache.camel.model.LoopDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'filter', type: 'org.apache.camel.model.FilterDefinition', params: [predicate: 'groovy.lang.Closure']
- method name: 'validate', type: 'org.apache.camel.model.ProcessorDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.groovy.extend.CamelGroovyMethods')]) {
- method name: 'newExchange', type: 'org.apache.camel.model.WireTapDefinition', params: [self: 'org.apache.camel.model.WireTapDefinition', processorLogic: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.OnExceptionDefinition')]) {
- method name: 'onRedelivery', type: 'org.apache.camel.model.OnExceptionDefinition', params: [processorLogic: 'groovy.lang.Closure']
- method name: 'onWhen', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
- method name: 'handled', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
- method name: 'continued', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
- method name: 'retryWhile', type: 'org.apache.camel.model.OnExceptionDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.MulticastDefinition')]) {
- method name: 'aggregationStrategy', type: 'org.apache.camel.model.MulticastDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
- method name: 'onPrepare', type: 'org.apache.camel.model.MulticastDefinition', params: [processorLogic: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.RecipientListDefinition')]) {
- method name: 'aggregationStrategy', type: 'org.apache.camel.model.RecipientListDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
- method name: 'onPrepare', type: 'org.apache.camel.model.RecipientListDefinition', params: [processorLogic: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.SplitDefinition')]) {
- method name: 'aggregationStrategy', type: 'org.apache.camel.model.SplitDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
- method name: 'onPrepare', type: 'org.apache.camel.model.SplitDefinition', params: [processorLogic: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.AggregateDefinition')]) {
- method name: 'aggregationStrategy', type: 'org.apache.camel.model.AggregateDefinition', params: [aggregationLogic: 'groovy.lang.Closure']
- method name: 'completionSize', type: 'org.apache.camel.model.AggregateDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'completionTimeout', type: 'org.apache.camel.model.AggregateDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'completionPredicate', type: 'org.apache.camel.model.AggregateDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.WireTapDefinition')]) {
- method name: 'onPrepare', type: 'org.apache.camel.model.WireTapDefinition', params: [processorLogic: 'groovy.lang.Closure']
- method name: 'newExchangeBody', type: 'org.apache.camel.model.WireTapDefinition', params: [expression: 'groovy.lang.Closure']
- method name: 'newExchangeHeader', type: 'org.apache.camel.model.WireTapDefinition', params: [header: 'java.lang.String', expression: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.ChoiceDefinition')]) {
- method name: 'when', type: 'org.apache.camel.model.ChoiceDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.TryDefinition')]) {
- method name: 'onWhen', type: 'org.apache.camel.model.TryDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.OnCompletionDefinition')]) {
- method name: 'onWhen', type: 'org.apache.camel.model.OnCompletionDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.CatchDefinition')]) {
- method name: 'onWhen', type: 'org.apache.camel.model.CatchDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.InterceptDefinition')]) {
- method name: 'when', type: 'org.apache.camel.model.InterceptDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.model.InterceptSendToEndpointDefinition')]) {
- method name: 'when', type: 'org.apache.camel.model.InterceptSendToEndpointDefinition', params: [predicate: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.builder.RouteBuilder')]) {
- method name: 'aggregator', type: 'org.apache.camel.processor.aggregate.AggregationStrategy', params: [aggregationLogic: 'groovy.lang.Closure']
- method name: 'expression', type: 'org.apache.camel.Expression', params: [expression: 'groovy.lang.Closure']
- method name: 'predicate', type: 'org.apache.camel.Predicate', params: [predicate: 'groovy.lang.Closure']
- method name: 'processor', type: 'org.apache.camel.Processor', params: [processor: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.builder.ExpressionClause')]) {
- method name: 'expression', type: 'T', params: [expression: 'groovy.lang.Closure']
-}
-contributor([context(ctype: 'org.apache.camel.builder.DataFormatClause')]) {
- method name: 'gnode', type: 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware: 'boolean']
- method name: 'gnode', type: 'org.apache.camel.model.ProcessorDefinition'
- method name: 'gpath', type: 'org.apache.camel.model.ProcessorDefinition', params: [namespaceAware: 'boolean']
- method name: 'gpath', type: 'org.apache.camel.model.ProcessorDefinition'
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy b/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
deleted file mode 100644
index 9f135f8..0000000
--- a/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.groovy
-
-import org.apache.camel.model.ChoiceDefinition;
-import org.apache.camel.model.ProcessorDefinition;
-
-/**
- */
-class ConfigureCamel implements Runnable {
-
- static void main(String[] args) {
- new ConfigureCamel().run();
- }
-
- void run() {
- ExpandoMetaClass.enableGlobally();
-
- ProcessorDefinition.metaClass.filter = { filter ->
- if (filter instanceof Closure) {
- filter = CamelGroovyMethods.toExpression(filter)
- }
- delegate.filter(filter);
- }
-
- ChoiceDefinition.metaClass.when = { filter ->
- if (filter instanceof Closure) {
- filter = CamelGroovyMethods.toExpression(filter)
- }
- delegate.when(filter);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
deleted file mode 100644
index a96fbfd..0000000
--- a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.converter
-
-import groovy.util.slurpersupport.GPathResult
-import org.apache.camel.CamelContext
-import org.apache.camel.Exchange
-import org.apache.camel.StringSource
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.impl.DefaultExchange
-import org.junit.Test
-import org.w3c.dom.Node
-import org.xml.sax.InputSource
-
-import javax.xml.parsers.DocumentBuilderFactory
-
-import static org.junit.Assert.assertEquals
-import static org.junit.Assert.assertNotNull
-
-public class GPathResultConverterTest {
- String xml = "<test><elem1>This is test</elem1></test>"
- CamelContext context = new DefaultCamelContext()
-
- @Test
- void "should convert string to GPathResult"() {
- Exchange exchange = new DefaultExchange(context)
- exchange.in.setBody(xml, String)
- GPathResult result = exchange.in.getBody(GPathResult)
- checkGPathResult(result)
- }
-
- @Test
- void "should convert string source to GPathResult"() {
- StringSource input = new StringSource(xml)
- Exchange exchange = new DefaultExchange(context)
- exchange.in.setBody(input, StringSource)
- GPathResult result = exchange.in.getBody(GPathResult)
- checkGPathResult(result)
- }
-
- @Test
- void "should convert node to GPathResult"() {
- Node node = DocumentBuilderFactory.newInstance().newDocumentBuilder()
- .parse(new InputSource(new StringReader(xml)))
- Exchange exchange = new DefaultExchange(context)
- exchange.in.setBody(node, Node)
- GPathResult result = exchange.in.getBody(GPathResult)
- checkGPathResult(result)
- }
-
- private void checkGPathResult(GPathResult gPathResult) {
- assertNotNull(gPathResult)
- assertEquals(gPathResult.name(), "test")
- assertEquals(gPathResult.elem1.text(), "This is test")
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
deleted file mode 100644
index 2766892..0000000
--- a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/CamelGroovyMethodsTest.groovy
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend
-
-import org.apache.camel.EndpointInject
-import org.apache.camel.Exchange
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.component.mock.MockEndpoint
-import org.apache.camel.test.junit4.CamelTestSupport
-import org.junit.Test
-
-/**
- * Test a few DSL extensions.
- */
-class CamelGroovyMethodsTest extends CamelTestSupport {
-
- private static final String HELLO = 'Hello'
- private static final String WORLD = 'World'
-
- @EndpointInject(uri = 'mock:test1')
- private MockEndpoint resultEndpoint;
- @EndpointInject(uri = 'mock:test2')
- private MockEndpoint otherEndpoint;
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
-
- def aggregation = { Exchange original, Exchange resource ->
- original.in.body += resource.in.body
- original
- }
-
- return new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
-
- from('direct:test1')
- .enrich('direct:enrich') { Exchange original, Exchange resource ->
- original.in.body += resource.in.body
- original
- }
- .to('mock:test1')
-
- from('direct:enrich')
- .transform(constant(WORLD))
-
- from('direct:test2')
- .pollEnrich('seda:enrich', aggregation)
- .to('mock:test1')
-
- from('direct:test3')
- .process { Exchange e ->
- e.in.with {
- body = HELLO
- headers[HELLO] = WORLD
- }
- }
- .to('mock:test1')
-
- from('direct:test4')
- .setHeader(HELLO) { Exchange e ->
- e.in.body.reverse()
- }
- .to('mock:test1')
-
- from('direct:test5')
- .setProperty(HELLO) { Exchange e ->
- e.in.body.reverse()
- }
- .to('mock:test1')
-
- from('direct:test6')
- .transform { Exchange e ->
- e.in.body.reverse()
- }
- .to('mock:test1')
-
- from('direct:test7')
- .setBody { Exchange e ->
- e.in.body.reverse()
- }
- .to('mock:test1')
-
- from('direct:test8')
- .unmarshal().gpath()
- // XmlSlurper proceeds to first node
- .transform { it.in.body.World.text() }
- .to('mock:test1')
-
- from('direct:test9')
- .unmarshal().gnode()
- // XmlParser proceeds to first node
- .transform { it.in.body.World.text() }
- .to('mock:test1')
-
- from('direct:test10')
- .marshal().gnode()
- .convertBodyTo(String)
- .to('mock:test1')
-
- from('direct:test11')
- .choice()
- .when { it.in.body == HELLO }.to('mock:test1')
- .otherwise().to('mock:test2')
-
- from('direct:test12')
- .setHeader(HELLO).expression { Exchange e ->
- e.in.body.reverse()
- }
- .to('mock:test1')
-
- from('direct:toD')
- .toD('mock:${header.foo}')
-
- }
-
- }
- }
-
- @Test
- void testClosureEnricherAggregation() {
- resultEndpoint.expectedBodiesReceived(HELLO + WORLD)
- template.sendBody('direct:test1', HELLO)
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosurePollingEnricherAggregation() {
- resultEndpoint.expectedBodiesReceived(HELLO + WORLD)
- template.sendBody('seda:enrich', WORLD)
- template.sendBody('direct:test2', HELLO)
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureProcessor() {
- resultEndpoint.expectedBodiesReceived(HELLO)
- resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
- template.sendBody('direct:test3', '')
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureSetHeader() {
- resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
- template.sendBody('direct:test4', WORLD.reverse())
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureSetHeaderWithExpressionClause() {
- resultEndpoint.expectedHeaderReceived(HELLO, WORLD)
- template.sendBody('direct:test4', WORLD.reverse())
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureSetProperty() {
- resultEndpoint.expectedPropertyReceived(HELLO, WORLD)
- template.sendBody('direct:test5', WORLD.reverse())
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureTransformer() {
- resultEndpoint.expectedBodiesReceived(HELLO)
- template.sendBody('direct:test6', HELLO.reverse())
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureSetBody() {
- resultEndpoint.expectedBodiesReceived(HELLO)
- template.sendBody('direct:test7', HELLO.reverse())
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureChoice1() {
- resultEndpoint.expectedBodiesReceived(HELLO)
- otherEndpoint.expectedMessageCount(0)
- template.sendBody('direct:test11', HELLO)
- resultEndpoint.assertIsSatisfied()
- otherEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testClosureChoice2() {
- resultEndpoint.expectedMessageCount(0)
- otherEndpoint.expectedBodiesReceived(WORLD)
- template.sendBody('direct:test11', WORLD)
- resultEndpoint.assertIsSatisfied()
- otherEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testXmlSlurper() {
- String text = "How are you?"
- resultEndpoint.expectedBodiesReceived(text)
- template.sendBody('direct:test8', "<Hello><World>${text}</World></Hello>")
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testXmlParser() {
- String text = "How are you?"
- resultEndpoint.expectedBodiesReceived(text)
- template.sendBody('direct:test9', "<Hello><World>${text}</World></Hello>")
- resultEndpoint.assertIsSatisfied()
- }
-
- @Test
- void testXmlPrinter() {
- String text = "<Hello><World>How are you?</World></Hello>"
- Node parsed = new XmlParser().parseText(text)
- resultEndpoint.expectedMessageCount(1)
- template.sendBody('direct:test10', parsed)
- // The created XML differs in terms of white spaces and line feeds.
- assertEquals(text.replaceAll('\\s+', ''), resultEndpoint.exchanges[0].in.body.replaceAll('\\s+', ''))
- }
-
- @Test
- void testToD() {
- resultEndpoint.expectedMessageCount(1)
- template.sendBodyAndHeader('direct:toD', WORLD, "foo", "test1")
- resultEndpoint.assertIsSatisfied()
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
deleted file mode 100644
index 71a9b73..0000000
--- a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureAggregationStrategyTest.groovy
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend
-
-import static org.junit.Assert.*
-import static org.apache.camel.groovy.extend.CamelGroovyMethods.toAggregationStrategy
-
-import org.apache.camel.CamelContext
-import org.apache.camel.Exchange
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.impl.DefaultExchange
-import org.junit.Before
-import org.junit.Test
-
-
-class ClosureAggregationStrategyTest {
-
- private Exchange exchange1
- private Exchange exchange2
- private static final String HELLO = "Hello"
- private static final String WORLD = "World"
-
- @Before
- public void setUp() throws Exception {
- CamelContext context = new DefaultCamelContext()
- exchange1 = new DefaultExchange(context);
- exchange2 = new DefaultExchange(context);
- }
-
- @Test
- public void testAggregationStrategy() {
- exchange1.in.body = HELLO
- exchange2.in.body = WORLD
- ClosureAggregationStrategy cas = toAggregationStrategy { Exchange oldExchange, Exchange newExchange ->
- newExchange.in.body = newExchange.in.body + ' ' + oldExchange.in.body
- newExchange
- }
- assertEquals(HELLO + ' ' + WORLD, cas.aggregate(exchange2, exchange1).in.body)
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
deleted file mode 100644
index ecd50a2..0000000
--- a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureExpressionTest.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend
-
-import static org.junit.Assert.*
-import static org.apache.camel.groovy.extend.CamelGroovyMethods.toExpression
-
-import org.apache.camel.Exchange
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.impl.DefaultExchange
-import org.junit.Before
-import org.junit.Test
-
-
-class ClosureExpressionTest {
-
- private Exchange exchange
- private static final String HELLO = "Hello"
-
- @Before
- public void setUp() throws Exception {
- exchange = new DefaultExchange(new DefaultCamelContext());
- exchange.in.body = HELLO
- }
-
- @Test
- public void testAsExpression() {
- ClosureExpression expression = toExpression { Exchange exchange ->
- exchange.in.body
- }
- assertEquals(HELLO, expression.evaluate(exchange))
- }
-
- @Test
- public void testAsPredicate() {
- ClosureExpression expressionTrue = toExpression { Exchange exchange ->
- exchange.in.body == HELLO
- }
- assertTrue(expressionTrue.evaluate(exchange))
- ClosureExpression expressionFalse = toExpression { Exchange exchange ->
- exchange.in.body != HELLO
- }
- assertFalse(expressionFalse.evaluate(exchange))
- }
-
- @Test
- public void testClosureException() {
- String unknownProperty = 'Gablorg'
- ClosureExpression expression = toExpression { Exchange exchange ->
- exchange."${unknownProperty}"
- }
- try {
- expression.evaluate(exchange)
- } catch (MissingPropertyException e) {
- assertTrue(e.message.contains(unknownProperty))
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
deleted file mode 100644
index 3733551..0000000
--- a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/extend/ClosureProcessorTest.groovy
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.groovy.extend
-
-import static org.junit.Assert.*
-import static org.apache.camel.groovy.extend.CamelGroovyMethods.toProcessor
-
-import org.apache.camel.Exchange
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.impl.DefaultExchange
-import org.junit.Before
-import org.junit.Test
-
-
-class ClosureProcessorTest {
-
- private Exchange exchange
- private static final String HELLO = "Hello"
-
- @Before
- public void setUp() throws Exception {
- exchange = new DefaultExchange(new DefaultCamelContext());
- }
-
- @Test
- public void testProcessor() {
- exchange.in.body = HELLO
- ClosureProcessor processor = toProcessor { Exchange exchange ->
- exchange.in.body = exchange.in.body.reverse()
- }
- processor.process(exchange)
- assertEquals(HELLO.reverse(), exchange.in.body )
- }
-
- @Test(expected=NullPointerException)
- public void testProcessorException() {
- exchange.in.body = null
- ClosureProcessor processor = toProcessor { Exchange exchange ->
- exchange.in.body = exchange.in.body.reverse()
- }
- processor.process(exchange)
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyExpressionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyExpressionTest.java b/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyExpressionTest.java
index 37d5d66..1e3efe9 100644
--- a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyExpressionTest.java
+++ b/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyExpressionTest.java
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
* @version
*/
public class GroovyExpressionTest extends CamelTestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(GroovyTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(GroovyExpressionTest.class);
protected Exchange exchange;
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java b/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
deleted file mode 100644
index ed5b932..0000000
--- a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.groovy;
-
-import groovy.lang.GroovyClassLoader;
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class GroovyTest extends CamelTestSupport {
- protected String expected = "<hello>world!</hello>";
- protected String groovyBuilderClass = "org.apache.camel.language.groovy.example.GroovyRoutes";
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- MockEndpoint resultEndpoint = getMockEndpoint("mock:results");
- resultEndpoint.expectedBodiesReceived(expected);
-
- template.sendBodyAndHeader("direct:a", expected, "foo", "bar");
-
- assertMockEndpointsSatisfied();
-
- log.debug("Should have received one exchange: " + resultEndpoint.getReceivedExchanges());
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- MockEndpoint resultEndpoint = getMockEndpoint("mock:results");
- resultEndpoint.expectedMessageCount(0);
-
- template.sendBodyAndHeader("direct:a", expected, "foo", "123");
-
- assertMockEndpointsSatisfied();
-
- log.debug("Should not have received any messages: " + resultEndpoint.getReceivedExchanges());
- }
-
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext answer = super.createCamelContext();
-
- GroovyClassLoader classLoader = new GroovyClassLoader();
- Class<?> type = classLoader.loadClass(groovyBuilderClass);
- Object object = answer.getInjector().newInstance(type);
- RouteBuilder builder = assertIsInstanceOf(RouteBuilder.class, object);
-
- log.info("Loaded builder: " + builder);
- answer.addRoutes(builder);
-
- return answer;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/91ff7db2/components/camel-groovy/src/test/resources/org/apache/camel/language/groovy/example/GroovyRoutes.groovy
----------------------------------------------------------------------
diff --git a/components/camel-groovy/src/test/resources/org/apache/camel/language/groovy/example/GroovyRoutes.groovy b/components/camel-groovy/src/test/resources/org/apache/camel/language/groovy/example/GroovyRoutes.groovy
deleted file mode 100644
index e1b5c5e..0000000
--- a/components/camel-groovy/src/test/resources/org/apache/camel/language/groovy/example/GroovyRoutes.groovy
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.groovy.example
-
-import org.apache.camel.language.groovy.GroovyRouteBuilder;
-
-class GroovyRoutes extends GroovyRouteBuilder {
-
- void configure() {
-
- from("direct:a").filter {e ->
- e.in.headers.foo == "bar"
- }.to("mock:results")
-
- }
-}
\ No newline at end of file