servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r394518 - in /incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms: JmsMarshaler.java JmsSenderComponent.java
Date Sun, 16 Apr 2006 17:27:34 GMT
Author: gnodet
Date: Sun Apr 16 10:27:33 2006
New Revision: 394518

URL: http://svn.apache.org/viewcvs?rev=394518&view=rev
Log:
SM-398: The JMSMarshaler class does not verify the JMS properties it creates comply with the
JMS specification naming constraints

Modified:
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsMarshaler.java
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsSenderComponent.java

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsMarshaler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsMarshaler.java?rev=394518&r1=394517&r2=394518&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsMarshaler.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsMarshaler.java
Sun Apr 16 10:27:33 2006
@@ -36,6 +36,8 @@
  */
 public class JmsMarshaler {
     private SourceMarshaler sourceMarshaler;
+    
+    private boolean needJavaIdentifiers;
 
     public JmsMarshaler() {
         this(new SourceMarshaler());
@@ -118,6 +120,32 @@
      * By default this includes all suitable typed values
      */
     protected boolean shouldIncludeHeader(NormalizedMessage normalizedMessage, String name,
Object value) {
-        return value instanceof String || value instanceof Number || value instanceof Date;
+        return (value instanceof String || value instanceof Number || value instanceof Date)
&&
+               (!isNeedJavaIdentifiers() || isJavaIdentifier(name));
     }
+    
+    private static boolean isJavaIdentifier(String s) {
+        int n = s.length();
+        if (n==0) return false;
+        if (!Character.isJavaIdentifierStart(s.charAt(0)))
+            return false;
+        for (int i = 1; i < n; i++)
+            if (!Character.isJavaIdentifierPart(s.charAt(i)))
+                return false;
+        return true;
+      }
+
+    /**
+     * @return Returns the needJavaIdentifiers.
+     */
+    public boolean isNeedJavaIdentifiers() {
+        return needJavaIdentifiers;
+    }
+
+    /**
+     * @param needJavaIdentifiers The needJavaIdentifiers to set.
+     */
+    public void setNeedJavaIdentifiers(boolean needJavaIdentifiers) {
+        this.needJavaIdentifiers = needJavaIdentifiers;
+    }    
 }

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsSenderComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsSenderComponent.java?rev=394518&r1=394517&r2=394518&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsSenderComponent.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/jms/JmsSenderComponent.java
Sun Apr 16 10:27:33 2006
@@ -60,6 +60,20 @@
         this.marshaler = marshaler;
     }
 
+    /**
+     * @return Returns the needJavaIdentifiers.
+     */
+    public boolean isNeedJavaIdentifiers() {
+        return this.marshaler.isNeedJavaIdentifiers();
+    }
+
+    /**
+     * @param needJavaIdentifiers The needJavaIdentifiers to set.
+     */
+    public void setNeedJavaIdentifiers(boolean needJavaIdentifiers) {
+        this.marshaler.setNeedJavaIdentifiers(needJavaIdentifiers);
+    }    
+    
     // Implementation methods
     //-------------------------------------------------------------------------
     protected void process(MessageExchange exchange, final NormalizedMessage inMessage) throws
Exception {



Mime
View raw message