camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [1/2] camel git commit: CAMEL-9488: Camel script - Add missing languages.
Date Thu, 17 Mar 2016 08:36:24 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 47c9c416b -> 1cc925e76


CAMEL-9488: Camel script - Add missing languages.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/66991413
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/66991413
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/66991413

Branch: refs/heads/camel-2.16.x
Commit: 669914139b8d34723bcf7851f6b2f27255508b18
Parents: 47c9c41
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jan 6 19:06:17 2016 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Thu Mar 17 09:33:24 2016 +0100

----------------------------------------------------------------------
 .../component/language/LanguageEndpoint.java    |  2 +-
 .../builder/script/JavaScriptLanguage.java      | 46 ++++++++++++++++++
 .../camel/builder/script/PhpLanguage.java       | 46 ++++++++++++++++++
 .../camel/builder/script/PythonLanguage.java    | 46 ++++++++++++++++++
 .../camel/builder/script/RubyLanguage.java      | 46 ++++++++++++++++++
 .../org/apache/camel/language/javaScript        | 18 +++++++
 .../services/org/apache/camel/language/php      | 18 +++++++
 .../services/org/apache/camel/language/python   | 18 +++++++
 .../services/org/apache/camel/language/ruby     | 18 +++++++
 .../LanguageECMAScriptAsJavaScriptTest.java     | 51 --------------------
 10 files changed, 257 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/camel-core/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
b/camel-core/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
index 9bacf5b..b69bc58 100644
--- a/camel-core/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
@@ -47,7 +47,7 @@ public class LanguageEndpoint extends ResourceEndpoint {
     private Language language;
     private Expression expression;
     private boolean contentResolvedFromResource;
-    @UriPath(enums = "bean,constant,el,exchangeProperty,file,groovy,header,jsonpath,jxpath,mvel,ognl,ref,simple,spel,sql,terser,tokenize,xpath,xquery,xtokenize")
@Metadata(required = "true")
+    @UriPath(enums = "bean,constant,el,exchangeProperty,file,groovy,header,javascript,jsonpath,jxpath,mvel,ognl,php,python,ref,ruby,simple,spel,sql,terser,tokenize,xpath,xquery,xtokenize")
@Metadata(required = "true")
     private String languageName;
     // resourceUri is optional in the language endpoint
     @UriPath(description = "Path to the resource, or a reference to lookup a bean in the
Registry to use as the resource") @Metadata(required = "false")

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/java/org/apache/camel/builder/script/JavaScriptLanguage.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/java/org/apache/camel/builder/script/JavaScriptLanguage.java
b/components/camel-script/src/main/java/org/apache/camel/builder/script/JavaScriptLanguage.java
new file mode 100644
index 0000000..eafbe22
--- /dev/null
+++ b/components/camel-script/src/main/java/org/apache/camel/builder/script/JavaScriptLanguage.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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.builder.script;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.LanguageSupport;
+
+public class JavaScriptLanguage extends LanguageSupport {
+
+    @Override
+    public Predicate createPredicate(String predicate) {
+        Language language = getCamelContext().resolveLanguage("js");
+        if (language != null) {
+            return language.createPredicate(predicate);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Expression createExpression(String expression) {
+        Language language = getCamelContext().resolveLanguage("js");
+        if (language != null) {
+            return language.createExpression(expression);
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/java/org/apache/camel/builder/script/PhpLanguage.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/java/org/apache/camel/builder/script/PhpLanguage.java
b/components/camel-script/src/main/java/org/apache/camel/builder/script/PhpLanguage.java
new file mode 100644
index 0000000..be2a5ce
--- /dev/null
+++ b/components/camel-script/src/main/java/org/apache/camel/builder/script/PhpLanguage.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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.builder.script;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.LanguageSupport;
+
+public class PhpLanguage extends LanguageSupport {
+
+    @Override
+    public Predicate createPredicate(String predicate) {
+        Language language = getCamelContext().resolveLanguage("php");
+        if (language != null) {
+            return language.createPredicate(predicate);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Expression createExpression(String expression) {
+        Language language = getCamelContext().resolveLanguage("php");
+        if (language != null) {
+            return language.createExpression(expression);
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/java/org/apache/camel/builder/script/PythonLanguage.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/java/org/apache/camel/builder/script/PythonLanguage.java
b/components/camel-script/src/main/java/org/apache/camel/builder/script/PythonLanguage.java
new file mode 100644
index 0000000..9dfb288
--- /dev/null
+++ b/components/camel-script/src/main/java/org/apache/camel/builder/script/PythonLanguage.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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.builder.script;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.LanguageSupport;
+
+public class PythonLanguage extends LanguageSupport {
+
+    @Override
+    public Predicate createPredicate(String predicate) {
+        Language language = getCamelContext().resolveLanguage("python");
+        if (language != null) {
+            return language.createPredicate(predicate);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Expression createExpression(String expression) {
+        Language language = getCamelContext().resolveLanguage("python");
+        if (language != null) {
+            return language.createExpression(expression);
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/java/org/apache/camel/builder/script/RubyLanguage.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/java/org/apache/camel/builder/script/RubyLanguage.java
b/components/camel-script/src/main/java/org/apache/camel/builder/script/RubyLanguage.java
new file mode 100644
index 0000000..5f95a88
--- /dev/null
+++ b/components/camel-script/src/main/java/org/apache/camel/builder/script/RubyLanguage.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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.builder.script;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.LanguageSupport;
+
+public class RubyLanguage extends LanguageSupport {
+
+    @Override
+    public Predicate createPredicate(String predicate) {
+        Language language = getCamelContext().resolveLanguage("jruby");
+        if (language != null) {
+            return language.createPredicate(predicate);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Expression createExpression(String expression) {
+        Language language = getCamelContext().resolveLanguage("jruby");
+        if (language != null) {
+            return language.createExpression(expression);
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/javaScript
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/javaScript
b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/javaScript
new file mode 100644
index 0000000..8051107
--- /dev/null
+++ b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/javaScript
@@ -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.
+#
+
+class=org.apache.camel.builder.script.JavaScriptLanguage
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/php
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/php
b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/php
new file mode 100644
index 0000000..f708b18
--- /dev/null
+++ b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/php
@@ -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.
+#
+
+class=org.apache.camel.builder.script.PhpLanguage
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/python
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/python
b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/python
new file mode 100644
index 0000000..01db3cb
--- /dev/null
+++ b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/python
@@ -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.
+#
+
+class=org.apache.camel.builder.script.PythonLanguage
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/ruby
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/ruby
b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/ruby
new file mode 100644
index 0000000..0a8efcd
--- /dev/null
+++ b/components/camel-script/src/main/resources/META-INF/services/org/apache/camel/language/ruby
@@ -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.
+#
+
+class=org.apache.camel.builder.script.RubyLanguage
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/66991413/components/camel-script/src/test/java/org/apache/camel/builder/script/LanguageECMAScriptAsJavaScriptTest.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/test/java/org/apache/camel/builder/script/LanguageECMAScriptAsJavaScriptTest.java
b/components/camel-script/src/test/java/org/apache/camel/builder/script/LanguageECMAScriptAsJavaScriptTest.java
deleted file mode 100644
index 0c214ab..0000000
--- a/components/camel-script/src/test/java/org/apache/camel/builder/script/LanguageECMAScriptAsJavaScriptTest.java
+++ /dev/null
@@ -1,51 +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.builder.script;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Tests a routing expression using ECMAScript which will be resolved as java script
- */
-@Ignore("May fail on CI servers")
-public class LanguageECMAScriptAsJavaScriptTest extends CamelTestSupport {
-
-    @Test
-    public void testSendMatchingMessage() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived(7, 9);
-
-        sendBody("direct:start", 3);
-        sendBody("direct:start", 4);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                from("direct:start")
-                    .to("language:ECMAScript:classpath:myJavascript.js")
-                    .to("mock:result");
-            }
-        };
-    }
-}


Mime
View raw message