synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r605048 - in /webservices/synapse/trunk/java/modules/core/src: main/java/org/apache/synapse/mediators/annotations/ main/java/org/apache/synapse/mediators/ext/ test/java/org/apache/synapse/mediators/ext/
Date Tue, 18 Dec 2007 00:09:51 GMT
Author: antelder
Date: Mon Dec 17 16:09:47 2007
New Revision: 605048

URL: http://svn.apache.org/viewvc?rev=605048&view=rev
Log:
Change @Napmespaces annotation to use an array of string values with each string being the
profix and namespace combined, as was discussed on the mailing list

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/annotations/Namespaces.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java
    webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand.java
    webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand2.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/annotations/Namespaces.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/annotations/Namespaces.java?rev=605048&r1=605047&r2=605048&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/annotations/Namespaces.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/annotations/Namespaces.java
Mon Dec 17 16:09:47 2007
@@ -29,18 +29,17 @@
 
 /**
  * Annotation used to declare namespaces available to be used in XPATH expressions
+ * 
+ * To support setting multiple namespaces with arbitrary prefixes the namespace and 
+ * namespace prefix are held in as a single string value seperated by a colon. For
+ * example, "ns:http://tempuri.org" represents the namespace uri http://tempuri.org
+ * and the namespace prefix "ns", and the complete Namespaces annotation for that
+ * example would be @Namespaces({"ns:http://tempuri.org"})
  */
 @Target({TYPE, FIELD, METHOD})
 @Retention(RUNTIME)
 public @interface Namespaces {
 
-    String[] value() default {"",""};
-
-    String ns() default "";
-    String ns1() default "";
-    String ns2() default "";
-    String ns3() default "";
-    String ns4() default "";
-    String ns5() default "";
+    String[] value();
 
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java?rev=605048&r1=605047&r2=605048&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java
Mon Dec 17 16:09:47 2007
@@ -234,51 +234,25 @@
 
         // First add any default namespaces
         if (defaultNamespaces != null) {
-            if (defaultNamespaces.value()[0].length()>0) {
-                allNamespaces.put(defaultNamespaces.value()[0], defaultNamespaces.value()[1]);
-            }
-            if (defaultNamespaces.ns() != null && defaultNamespaces.ns().length()
> 0) {
-                allNamespaces.put("ns", defaultNamespaces.ns());
-            }
-            if (defaultNamespaces.ns1() != null && defaultNamespaces.ns1().length()
> 0) {
-                allNamespaces.put("ns1", defaultNamespaces.ns());
-            }
-            if (defaultNamespaces.ns2() != null && defaultNamespaces.ns2().length()
> 0) {
-                allNamespaces.put("ns2", defaultNamespaces.ns());
-            }
-            if (defaultNamespaces.ns3() != null && defaultNamespaces.ns3().length()
> 0) {
-                allNamespaces.put("ns3", defaultNamespaces.ns());
-            }
-            if (defaultNamespaces.ns4() != null && defaultNamespaces.ns4().length()
> 0) {
-                allNamespaces.put("ns4", defaultNamespaces.ns());
-            }
-            if (defaultNamespaces.ns5() != null && defaultNamespaces.ns5().length()
> 0) {
-                allNamespaces.put("ns5", defaultNamespaces.ns());
+            for (String namespaceValue : defaultNamespaces.value()) {
+                int i = namespaceValue.indexOf(':');
+                if (i > 0) {
+                    String prefix = namespaceValue.substring(0, i);
+                    String namespace = namespaceValue.substring(i+1);
+                    allNamespaces.put(prefix, namespace);
+                }
             }
         }
 
         // add any namespaces which will overwrite any previously added default namespaces
         if (namespaces != null) {
-            if (namespaces.value()[0].length()>0) {
-                allNamespaces.put(namespaces.value()[0], namespaces.value()[1]);
-            }
-            if (namespaces.ns() != null && namespaces.ns().length() > 0) {
-                allNamespaces.put("ns", namespaces.ns());
-            }
-            if (namespaces.ns1() != null && namespaces.ns1().length() > 0) {
-                allNamespaces.put("ns1", namespaces.ns());
-            }
-            if (namespaces.ns2() != null && namespaces.ns2().length() > 0) {
-                allNamespaces.put("ns2", namespaces.ns());
-            }
-            if (namespaces.ns3() != null && namespaces.ns3().length() > 0) {
-                allNamespaces.put("ns3", namespaces.ns());
-            }
-            if (namespaces.ns4() != null && namespaces.ns4().length() > 0) {
-                allNamespaces.put("ns4", namespaces.ns());
-            }
-            if (namespaces.ns5() != null && namespaces.ns5().length() > 0) {
-                allNamespaces.put("ns5", namespaces.ns());
+            for (String namespaceValue : namespaces.value()) {
+                int i = namespaceValue.indexOf(':');
+                if (i > 0) {
+                    String prefix = namespaceValue.substring(0, i);
+                    String namespace = namespaceValue.substring(i+1);
+                    allNamespaces.put(prefix, namespace);
+                }
             }
         }
         return allNamespaces;

Modified: webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand.java?rev=605048&r1=605047&r2=605048&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand.java
Mon Dec 17 16:09:47 2007
@@ -24,7 +24,7 @@
 import org.apache.synapse.mediators.annotations.ReadFromMessage;
 import org.apache.synapse.mediators.annotations.UpdateMessage;
 
-@Namespaces({"myns", "http://myns"})
+@Namespaces({"myns:http://myns"})
 public class AnnotatedCommand {
 
     @ReadFromMessage("/beforeField")
@@ -36,11 +36,11 @@
     @ReadAndUpdate("/@ReadAndUpdateField")
     String ReadAndUpdateField;
     
-    @Namespaces(ns="http://ns")
+    @Namespaces({"ns:http://ns"})
     @UpdateMessage("/afterField")
     String nsTest1;
 
-    @Namespaces({"xns", "http://xns"})
+    @Namespaces({"xns:http://xns"})
     @UpdateMessage("/afterField")
     String nsTest2;
 

Modified: webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand2.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand2.java?rev=605048&r1=605047&r2=605048&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand2.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/AnnotatedCommand2.java
Mon Dec 17 16:09:47 2007
@@ -22,17 +22,17 @@
 import org.apache.synapse.mediators.annotations.Namespaces;
 import org.apache.synapse.mediators.annotations.ReadFromMessage;
 
-@Namespaces({"soapenv", "http://schemas.xmlsoap.org/soap/envelope/"})
+@Namespaces({"soapenv:http://schemas.xmlsoap.org/soap/envelope/"})
 public class AnnotatedCommand2 {
 
     static String fieldResult;
     static String methodResult;
     
-    @Namespaces({"m", "http://services.samples/xsd"})
+    @Namespaces({"m:http://services.samples/xsd"})
     @ReadFromMessage("/soapenv:Envelope/soapenv:Body/m:getQuote/m:request/m:symbol")
     String beforeField;
 
-    @Namespaces({"m", "http://services.samples/xsd"})
+    @Namespaces({"m:http://services.samples/xsd"})
     @ReadFromMessage("/soapenv:Envelope/soapenv:Body/m:getQuote/m:request/m:symbol")
     public void setSymbol(String s) {
         methodResult = s;



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message