[jbossws-commits] JBossWS SVN: r8676 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws: core/binding and 6 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Nov 7 09:09:40 EST 2008


Author: richard.opalka at jboss.com
Date: 2008-11-07 09:09:39 -0500 (Fri, 07 Nov 2008)
New Revision: 8676

Added:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamResult.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java
Removed:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/binding/BufferedStreamResult.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java
Modified:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/Base64Serializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/CalendarSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/DateSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/ElementSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/HexSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/JBossXBSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/NullValueSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPElementSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SimpleSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchHTTPBinding.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/XMLFragment.java
Log:
[JBWS-2318] refactoring utility classes

Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/binding/BufferedStreamResult.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/binding/BufferedStreamResult.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/binding/BufferedStreamResult.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.binding;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-
-import javax.xml.transform.stream.StreamResult;
-
-import org.jboss.ws.WSException;
-import org.jboss.wsf.common.IOUtils;
-
-/**
- * @author Heiko.Braun at jboss.org
- * @author Thomas.Diesler at jboss.org
- * @since 06.02.2007
- */
-public class BufferedStreamResult extends StreamResult
-{
-   ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-
-   public BufferedStreamResult()
-   {
-   }
-
-   public BufferedStreamResult(String xmlFragment)
-   {
-      try
-      {
-         IOUtils.copyStream(getOutputStream(), new ByteArrayInputStream(xmlFragment.getBytes("UTF-8")));
-      }
-      catch (IOException e)
-      {
-         WSException.rethrow(e);
-      }
-   }
-
-   @Override
-   public Writer getWriter()
-   {
-      return null;
-   }
-
-   @Override
-   public OutputStream getOutputStream()
-   {
-      return baos;
-   }
-
-   @Override
-   public void setWriter(Writer writer)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   @Override
-   public void setOutputStream(OutputStream outputStream)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public String toString()
-   {
-      String result = null;
-      try
-      {
-         result = baos.toString("UTF-8");
-      }
-      catch (UnsupportedEncodingException e)
-      {
-         WSException.rethrow(e);
-      }
-
-      return result;
-   }
-}

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/Base64Serializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/Base64Serializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/Base64Serializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -26,11 +26,11 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
 import org.jboss.ws.extensions.xop.XOPContext;
 import org.jboss.ws.extensions.xop.jaxrpc.XOPMarshallerImpl;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.common.JavaUtils;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;

Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -1,128 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.jaxrpc.binding;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-
-import javax.xml.transform.stream.StreamSource;
-
-import org.jboss.ws.WSException;
-import org.jboss.wsf.common.IOUtils;
-
-/**
- * A StreamSource that can be read repeatedly. 
- * 
- * @author Thomas.Diesler at jboss.org
- * @since 29-Mar-2007
- */
-public class BufferedStreamSource extends StreamSource
-{
-   private byte[] bytes;
-   private char[] chars;
-
-   public BufferedStreamSource(StreamSource source)
-   {
-      try
-      {
-         InputStream ins = source.getInputStream();
-         if (ins != null)
-         {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-            IOUtils.copyStream(baos, ins);
-            bytes = baos.toByteArray();
-         }
-
-         Reader rd = source.getReader();
-         if (ins == null && rd != null)
-         {
-            char[] auxbuf = new char[1024];
-            CharArrayWriter wr = new CharArrayWriter(auxbuf.length);
-            int r = rd.read(auxbuf);
-            while (r > 0)
-            {
-               wr.write(auxbuf, 0, r);
-               r = rd.read(auxbuf);
-            }
-            chars = wr.toCharArray();
-         }
-      }
-      catch (IOException ex)
-      {
-         WSException.rethrow(ex);
-      }
-   }
-
-   public BufferedStreamSource(byte[] bytes)
-   {
-      this.bytes = bytes;
-   }
-
-   @Override
-   public InputStream getInputStream()
-   {
-      return (bytes != null ? new ByteArrayInputStream(bytes) : null);
-   }
-
-   @Override
-   public Reader getReader()
-   {
-      return (chars != null ? new CharArrayReader(chars) : null);
-   }
-
-   @Override
-   public void setInputStream(InputStream inputStream)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   @Override
-   public void setReader(Reader reader)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public String toString()
-   {
-      String retStr = null;
-      if (bytes != null)
-      {
-         try
-         {
-            retStr = new String(bytes, "UTF-8");
-         }
-         catch (UnsupportedEncodingException e)
-         {
-            WSException.rethrow(e);
-         }
-      }
-      else if (chars != null)
-         retStr = new String(chars);
-      return "" + retStr;
-   }
-}

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/CalendarSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/CalendarSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/CalendarSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -29,9 +29,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.ws.Constants;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;
 import org.w3c.dom.NamedNodeMap;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/DateSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/DateSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/DateSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -30,9 +30,9 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;
 import org.w3c.dom.NamedNodeMap;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/ElementSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/ElementSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/ElementSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -26,9 +26,9 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.common.DOMWriter;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/HexSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/HexSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/HexSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -26,9 +26,9 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.common.JavaUtils;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/JBossXBSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/JBossXBSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/JBossXBSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -30,7 +30,6 @@
 import org.apache.xerces.xs.XSModel;
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.ComplexTypeSerializer;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.jaxrpc.SerializationContextJAXRPC;
@@ -39,6 +38,7 @@
 import org.jboss.ws.core.jaxrpc.binding.jbossxb.JBossXBMarshallerImpl;
 import org.jboss.ws.core.soap.XMLFragment;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.w3c.dom.NamedNodeMap;
 
 /**

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/NullValueSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/NullValueSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/NullValueSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -27,9 +27,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.ws.Constants;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.w3c.dom.NamedNodeMap;
 

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -29,9 +29,9 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;
 import org.w3c.dom.NamedNodeMap;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -28,7 +28,6 @@
 import org.jboss.ws.Constants;
 import org.jboss.ws.WSException;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.AbstractSerializerFactory;
 import org.jboss.ws.core.binding.SerializerSupport;
@@ -37,6 +36,7 @@
 import org.jboss.ws.core.soap.SOAPContentElement;
 import org.jboss.ws.core.soap.XMLFragment;
 import org.jboss.ws.metadata.umdm.ParameterMetaData;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.common.JavaUtils;
 import org.w3c.dom.NamedNodeMap;
 

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPElementSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPElementSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SOAPElementSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -27,9 +27,9 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.common.DOMWriter;
 import org.w3c.dom.NamedNodeMap;
 

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SimpleSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SimpleSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/SimpleSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -27,9 +27,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.util.NotImplementedException;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.core.binding.SerializerSupport;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.xb.binding.NamespaceRegistry;
 import org.jboss.xb.binding.SimpleTypeBindings;
 import org.w3c.dom.NamedNodeMap;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -34,10 +34,10 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
 import org.jboss.ws.core.binding.ComplexTypeSerializer;
 import org.jboss.ws.core.binding.SerializationContext;
 import org.jboss.ws.extensions.xop.jaxws.AttachmentMarshallerImpl;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 import org.jboss.wsf.spi.binding.BindingCustomization;
 import org.w3c.dom.NamedNodeMap;
 

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchHTTPBinding.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchHTTPBinding.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchHTTPBinding.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -24,7 +24,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.ws.core.HTTPMessageImpl;
 import org.jboss.ws.core.MessageAbstraction;
-import org.jboss.ws.core.binding.BufferedStreamResult;
+import org.jboss.ws.util.xml.BufferedStreamResult;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/XMLFragment.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/XMLFragment.java	2008-11-07 13:02:35 UTC (rev 8675)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/XMLFragment.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -39,8 +39,8 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.WSException;
-import org.jboss.ws.core.binding.BufferedStreamResult;
-import org.jboss.ws.core.jaxrpc.binding.BufferedStreamSource;
+import org.jboss.ws.util.xml.BufferedStreamResult;
+import org.jboss.ws.util.xml.BufferedStreamSource;
 import org.jboss.wsf.common.DOMUtils;
 import org.jboss.wsf.common.DOMWriter;
 import org.w3c.dom.Element;

Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamResult.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamResult.java	                        (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamResult.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.util.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.ws.WSException;
+import org.jboss.wsf.common.IOUtils;
+
+/**
+ * Buffered StreamResult Utility class
+ * @author Richard.Opalka at jboss.org
+ * @author Heiko.Braun at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ * @since 06.02.2007
+ */
+public final class BufferedStreamResult extends StreamResult
+{
+   
+   private final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+
+   public BufferedStreamResult()
+   {
+   }
+
+   public BufferedStreamResult(String xmlFragment)
+   {
+      try
+      {
+         IOUtils.copyStream(getOutputStream(), new ByteArrayInputStream(xmlFragment.getBytes("UTF-8")));
+      }
+      catch (IOException e)
+      {
+         WSException.rethrow(e);
+      }
+   }
+
+   @Override
+   public final OutputStream getOutputStream()
+   {
+      return baos;
+   }
+
+   @Override
+   public final String toString()
+   {
+      try
+      {
+         return baos.toString("UTF-8");
+      }
+      catch (UnsupportedEncodingException e)
+      {
+         WSException.rethrow(e);
+      }
+
+      return null;
+   }
+
+   @Override
+   public final Writer getWriter()
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final void setWriter(Writer writer)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final void setOutputStream(OutputStream outputStream)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+}

Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java	                        (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java	2008-11-07 14:09:39 UTC (rev 8676)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.util.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.ws.WSException;
+import org.jboss.wsf.common.IOUtils;
+
+/**
+ * A StreamSource that can be read repeatedly. 
+ * @author Thomas.Diesler at jboss.org
+ * @author Richard.Opalka at jboss.org
+ * @since 29-Mar-2007
+ */
+public final class BufferedStreamSource extends StreamSource
+{
+   private byte[] bytes;
+   private char[] chars;
+
+   public BufferedStreamSource(StreamSource source)
+   {
+      try
+      {
+         final InputStream sourceInputStream = source.getInputStream();
+         if (sourceInputStream != null)
+         {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+            IOUtils.copyStream(baos, sourceInputStream);
+            bytes = baos.toByteArray();
+         }
+
+         final Reader sourceReader = source.getReader();
+         if ((sourceInputStream == null) && (sourceReader != null))
+         {
+            final char[] buffer = new char[1024];
+            final CharArrayWriter charArrayWriter = new CharArrayWriter(buffer.length);
+            int countOfReadChars = sourceReader.read(buffer);
+            while (countOfReadChars > 0)
+            {
+               charArrayWriter.write(buffer, 0, countOfReadChars);
+               countOfReadChars = sourceReader.read(buffer);
+            }
+            chars = charArrayWriter.toCharArray();
+         }
+      }
+      catch (IOException ex)
+      {
+         WSException.rethrow(ex);
+      }
+   }
+
+   public BufferedStreamSource(byte[] bytes)
+   {
+      this.bytes = bytes;
+   }
+
+   @Override
+   public final InputStream getInputStream()
+   {
+      return (bytes != null ? new ByteArrayInputStream(bytes) : null);
+   }
+
+   @Override
+   public final Reader getReader()
+   {
+      return (chars != null ? new CharArrayReader(chars) : null);
+   }
+
+   @Override
+   public final String toString()
+   {
+      String retVal = null;
+      if (bytes != null)
+      {
+         try
+         {
+            retVal = new String(bytes, "UTF-8");
+         }
+         catch (UnsupportedEncodingException e)
+         {
+            WSException.rethrow(e);
+         }
+      }
+      else if (chars != null)
+      {
+         retVal = new String(chars);
+      }
+         
+      return "" + retVal;
+   }
+
+   @Override
+   public final void setInputStream(InputStream inputStream)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final void setReader(Reader reader)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+}




More information about the jbossws-commits mailing list