camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r773787 - in /camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/component/bean/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/component/xslt/
Date Tue, 12 May 2009 05:32:23 GMT
Author: ningjiang
Date: Tue May 12 05:32:23 2009
New Revision: 773787

URL: http://svn.apache.org/viewvc?rev=773787&view=rev
Log:
Merged revisions 773781 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r773781 | ningjiang | 2009-05-12 12:58:13 +0800 (Tue, 12 May 2009) | 1 line
  
  CAMEL-1602 support to get the namespces from a customerized XPath
........

Added:
    camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
  (with props)
Modified:
    camel/branches/camel-1.x/   (props changed)
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/bean/XPathAnnotationExpressionFactory.java
    camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java
    camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 12 05:32:23 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/bean/XPathAnnotationExpressionFactory.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/bean/XPathAnnotationExpressionFactory.java?rev=773787&r1=773786&r2=773787&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/bean/XPathAnnotationExpressionFactory.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/bean/XPathAnnotationExpressionFactory.java
Tue May 12 05:32:23 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.component.bean;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
@@ -24,6 +25,7 @@
 import org.apache.camel.language.LanguageAnnotation;
 import org.apache.camel.language.NamespacePrefix;
 import org.apache.camel.language.XPath;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Factory for the XPath expression annotations.
@@ -36,15 +38,23 @@
     public Expression createExpression(CamelContext camelContext, Annotation annotation,
LanguageAnnotation languageAnnotation, Class expressionReturnType) {
         String xpath = getExpressionFromAnnotation(annotation);
         XPathBuilder builder = XPathBuilder.xpath(xpath);
-        if (annotation instanceof XPath) {
-            XPath xpathAnnotation = (XPath) annotation;
-            NamespacePrefix[] namespaces = xpathAnnotation.namespaces();
-            if (namespaces != null) {
-                for (NamespacePrefix namespacePrefix : namespaces) {
-                    builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
-                }
+        NamespacePrefix[] namespaces = getExpressionNameSpacePrefix(annotation);
+        if (namespaces != null) {
+            for (NamespacePrefix namespacePrefix : namespaces) {
+                builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
             }
+
         }
         return builder;
     }
+    
+    protected NamespacePrefix[] getExpressionNameSpacePrefix(Annotation annotation) {
+        try {
+            Method method = annotation.getClass().getMethod("namespaces");
+            Object value = ObjectHelper.invokeMethod(method, annotation);
+            return (NamespacePrefix[])value;
+        } catch (NoSuchMethodException e) {
+            throw new IllegalArgumentException("Cannot determine the annotation: " + annotation
+ " as it does not have an namespaces() method");
+        }        
+    }
 }

Modified: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java?rev=773787&r1=773786&r2=773787&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java
Tue May 12 05:32:23 2009
@@ -121,6 +121,7 @@
             // to access the message header and body at same time, 
             // then create the message that we want, splitter will
             // take care rest of them.
+            // *NOTE* this feature requires Camel version >= 1.6.1
             List<Message> answer = new ArrayList<Message>();
             String[] parts = header.split(",");
             for (String part : parts) {

Added: camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java?rev=773787&view=auto
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
(added)
+++ camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
Tue May 12 05:32:23 2009
@@ -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.component.xslt;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.component.bean.XPathAnnotationExpressionFactory;
+import org.apache.camel.language.LanguageAnnotation;
+import org.apache.camel.language.NamespacePrefix;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+@LanguageAnnotation(language = "xpath", factory = XPathAnnotationExpressionFactory.class)
+public @interface MyXPath {
+    String value();
+
+    NamespacePrefix[] namespaces() default {
+    @NamespacePrefix(prefix = "n1", uri = "http://example.org/ns1"),
+    @NamespacePrefix(prefix = "n2", uri = "http://example.org/ns2")};
+}

Propchange: camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java?rev=773787&r1=773786&r2=773787&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java
(original)
+++ camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java
Tue May 12 05:32:23 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.xslt;
 
-import org.apache.camel.language.XPath;
 
 /**
  * @version $Revision$
@@ -24,7 +23,7 @@
 public class TestBean {
     private String subject;
 
-    public void onMethod(@XPath("/*/@subject")String subject) {
+    public void onMethod(@MyXPath("/*/@subject")String subject) {
         this.subject = subject;
     }
 



Mime
View raw message