servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r412243 - in /incubator/servicemix/trunk/servicemix-core/src: main/java/org/apache/servicemix/jbi/jaxp/ test/java/org/apache/servicemix/jbi/jaxp/
Date Wed, 07 Jun 2006 00:50:19 GMT
Author: chirino
Date: Tue Jun  6 17:50:19 2006
New Revision: 412243

URL: http://svn.apache.org/viewvc?rev=412243&view=rev
Log:
Fixed the MACROMAN error that would happen when the message exchange was logged.

Modified:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java?rev=412243&r1=412242&r2=412243&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
Tue Jun  6 17:50:19 2006
@@ -15,16 +15,12 @@
  */
 package org.apache.servicemix.jbi.jaxp;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.xalan.xsltc.trax.DOM2SAX;
-import org.apache.xalan.xsltc.trax.SAX2DOM;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
 
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.NormalizedMessage;
@@ -42,13 +38,16 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xalan.xsltc.trax.DOM2SAX;
+import org.apache.xalan.xsltc.trax.SAX2DOM;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
 
 /**
  * A helper class to transform from one type of {@link Source} to another
@@ -63,15 +62,8 @@
     private DocumentBuilderFactory documentBuilderFactory;
     private TransformerFactory transformerFactory;
 
-    public static final String defaultCharEncodingName;
-    
-    static {
-        String canonName = new java.io.OutputStreamWriter( 
-                new java.io.ByteArrayOutputStream()).getEncoding();
+    public static final String defaultCharEncodingName = "UTF-8";
         
-        defaultCharEncodingName = Charset.forName(canonName).displayName();
-    }
-    
     public SourceTransformer() {
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java?rev=412243&r1=412242&r2=412243&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java
Tue Jun  6 17:50:19 2006
@@ -15,14 +15,15 @@
  */
 package org.apache.servicemix.jbi.jaxp;
 
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.Serializable;
 import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 
 /**
  * A helper class which provides a JAXP {@link Source} from a String
@@ -33,7 +34,8 @@
 public class StringSource extends StreamSource implements Serializable {
     
     private String text;
-
+    private String encoding="UTF-8";
+    
     public StringSource(String text) {
         this.text = text;
     }
@@ -43,8 +45,18 @@
         setSystemId(systemId);
     }
 
+    public StringSource(String text, String systemId, String encoding) {
+        this.text = text;
+        this.encoding=encoding;
+        setSystemId(systemId);
+    }
+
     public InputStream getInputStream() {
-        return new ByteArrayInputStream(text.getBytes());
+        try {
+            return new ByteArrayInputStream(text.getBytes(encoding));
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     public Reader getReader() {

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java?rev=412243&r1=412242&r2=412243&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java
Tue Jun  6 17:50:19 2006
@@ -48,9 +48,6 @@
         DOMSource domsource = transformer.toDOMSourceFromStream(new StringSource(
             "<definition xmlns:tns='http://foo.bar.com'><value>J├╝rgen</value></definition>"));
         assertNotNull(domsource);
-        
-        // 2006-04-28 JMa: You'll get a SAXParseException:
-        // [Fatal Error] :1:51: Invalid byte 1 of 1-byte UTF-8 sequence.
     }
 
 }



Mime
View raw message