You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/03/20 12:41:12 UTC
svn commit: r639253 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/language/
components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/
components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/
componen...
Author: jstrachan
Date: Thu Mar 20 04:41:11 2008
New Revision: 639253
URL: http://svn.apache.org/viewvc?rev=639253&view=rev
Log:
tidied up the javadoc a little and added a test case for @JXPath injection
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Bean.java
- copied, changed from r638976, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java
activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPath.java
- copied, changed from r638976, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java (with props)
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/XPath.java
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
activemq/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQuery.java
Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Bean.java (from r638976, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Bean.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Bean.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java&r1=638976&r2=639253&rev=639253&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Bean.java Thu Mar 20 04:41:11 2008
@@ -23,11 +23,14 @@
import java.lang.annotation.ElementType;
/**
+ * Used to inject a bean expression into a field, property, method or parameter when using
+ * <a href="http://activemq.apache.org/camel/bean-integration.html">Bean Integration</a>.
+ *
* @version $Revision$
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@LanguageAnnotation(language = "simple")
-public @interface Simple {
- public String value();
+@LanguageAnnotation(language = "bean")
+public @interface Bean {
+ public abstract String value();
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java?rev=639253&r1=639252&r2=639253&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java Thu Mar 20 04:41:11 2008
@@ -23,6 +23,9 @@
import java.lang.annotation.ElementType;
/**
+ * Used to inject a simple expression into a field, property, method or parameter when using
+ * <a href="http://activemq.apache.org/camel/bean-integration.html">Bean Integration</a>.
+ *
* @version $Revision$
*/
@Retention(RetentionPolicy.RUNTIME)
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/XPath.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/XPath.java?rev=639253&r1=639252&r2=639253&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/XPath.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/XPath.java Thu Mar 20 04:41:11 2008
@@ -25,7 +25,8 @@
import java.lang.annotation.Target;
/**
- * Used to inject an XPath expression into a field, property, method or parameter.
+ * Used to inject an XPath expression into a field, property, method or parameter when using
+ * <a href="http://activemq.apache.org/camel/bean-integration.html">Bean Integration</a>.
*
* @version $Revision$
*/
Copied: activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPath.java (from r638976, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPath.java?p2=activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPath.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java&r1=638976&r2=639253&rev=639253&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/Simple.java (original)
+++ activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPath.java Thu Mar 20 04:41:11 2008
@@ -15,19 +15,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.language;
+package org.apache.camel.language.jxpath;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
+import org.apache.camel.language.LanguageAnnotation;
+
/**
+ * An annotation used to inject a <a href="http://commons.apache.org/jxpath/">JXPath</a>
+ * expression into a method parameter when using
+ * <a href="http://activemq.apache.org/camel/bean-integration.html">Bean Integration</a>
+ *
* @version $Revision$
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@LanguageAnnotation(language = "simple")
-public @interface Simple {
- public String value();
+@LanguageAnnotation(language = "jxpath")
+public @interface JXPath {
+ public abstract String value();
}
Added: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java?rev=639253&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java (added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java Thu Mar 20 04:41:11 2008
@@ -0,0 +1,74 @@
+/**
+ *
+ * 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.jxpath;
+
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.jndi.JndiContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.naming.Context;
+
+/**
+ * @version $Revision: 630568 $
+ */
+public class BeanWithJXPathInjectionTest extends ContextTestSupport {
+ private static final transient Log LOG = LogFactory.getLog(BeanWithJXPathInjectionTest.class);
+ protected MyBean myBean = new MyBean();
+
+ public void testSendMessage() throws Exception {
+
+ template.sendBody("direct:in", new PersonBean("James", "London"));
+
+ assertEquals("bean foo: " + myBean, "James", myBean.name);
+ assertNotNull("Should pass body as well", myBean.body);
+ }
+
+ @Override
+ protected Context createJndiContext() throws Exception {
+ JndiContext answer = new JndiContext();
+ answer.bind("myBean", myBean);
+ return answer;
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:in").beanRef("myBean");
+ }
+ };
+ }
+
+ public static class MyBean {
+ public PersonBean body;
+ public String name;
+
+ @Override
+ public String toString() {
+ return "MyBean[foo: " + name + " body: " + body + "]";
+ }
+
+ public void read(PersonBean body, @JXPath("in/body/name") String name) {
+ this.name = name;
+ this.body = body;
+ LOG.info("read() method called on " + this);
+ }
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/BeanWithJXPathInjectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java?rev=639253&r1=639252&r2=639253&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java (original)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java Thu Mar 20 04:41:11 2008
@@ -32,6 +32,11 @@
this.location = location;
}
+ @Override
+ public String toString() {
+ return "PersonBean[name: " + name + " location: " + location + "]";
+ }
+
public String getLocation() {
return location;
}
Modified: activemq/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQuery.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQuery.java?rev=639253&r1=639252&r2=639253&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQuery.java (original)
+++ activemq/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQuery.java Thu Mar 20 04:41:11 2008
@@ -26,8 +26,8 @@
import java.lang.annotation.Target;
/**
- * An annotation for injection of XQuery expressions
- * into method parameters, fields or properties
+ * An annotation for injection of an XQuery expressions into a field, property, method or parameter when using
+ * <a href="http://activemq.apache.org/camel/bean-integration.html">Bean Integration</a>.
*
* @version $Revision$
*/