Author: ips
Date: Wed Jan  5 14:57:07 2005
New Revision: 124294

URL: http://svn.apache.org/viewcvs?view=rev&rev=124294
Log:
refactored to use Jakarta Commons IO instead of our own IoUtils class

Modified:
   incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java
   incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java
   incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java
   
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java

Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java
Url: 
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java?view=diff&rev=124294&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java&r1=124293&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java&r2=124294
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java     
(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/IoUtils.java     Wed Jan 
 5 14:57:07 2005
@@ -42,8 +42,10 @@
  */
 public abstract class IoUtils
 {
+
    private static final Log LOG = LogFactory.getLog( IoUtils.class );
-    public static final Messages MSG = MessagesImpl.getInstance();
+   private static final Messages MSG = MessagesImpl.getInstance();
+
    /**
     * Copies an input stream to an output stream.
     *
@@ -243,4 +245,5 @@
       copy( in, out );
       return out.toString( encoding );
    }
-}
\ No newline at end of file
+
+}

Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java
Url: 
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java?view=diff&rev=124294&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java&r1=124293&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java&r2=124294
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java   
(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/JaxpUtils.java   Wed Jan 
 5 14:57:07 2005
@@ -15,15 +15,15 @@
  
*=============================================================================*/
 package org.apache.ws.util;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.util.i18n.Keys;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.ws.util.i18n.MessagesImpl;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-import org.apache.ws.util.i18n.MessagesImpl;
-import org.apache.ws.util.i18n.Messages;
-import org.apache.ws.util.i18n.Keys;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -47,161 +47,161 @@
     private static final Log LOG = LogFactory.getLog( JaxpUtils.class );
     public static final Messages MSG = MessagesImpl.getInstance();
 
-   /**
-    * DOCUMENT_ME
-    */
-   private static final Object TRANSFORMER_LOCK = new Object(  );
-
-   /**
-    * DOCUMENT_ME
-    */
-   private static final String INDENT_SPACES = "2";
-
-   /**
-    * thread local that gives each thread its own TransformerFactory (since it 
is not thread-safe)
-    */
-   public static ThreadLocal TRANSFORMER_FACTORIES =
-      new ThreadLocal(  )
-      {
-         protected synchronized Object initialValue(  )
-         {
-            return TransformerFactory.newInstance(  );
-         }
-      };
-
-   /**
-    * thread local that gives each thread its own DocumentBuilderFactory 
(since it is not thread-safe)
-    */
-   public static ThreadLocal DOCUMENT_BUILDER_FACTORIES =
-      new ThreadLocal(  )
-      {
-         protected synchronized Object initialValue(  )
-         {
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(  
);
-            dbf.setNamespaceAware( true );
-
-            return ( dbf );
-         }
-      };
-
-   /**
-    * Loads a DOM Document from an InputSource.
-    *
-    * @param in_source
-    *
-    * @return Document
-    *
-    * @throws ParserConfigurationException
-    * @throws SAXException
-    * @throws IOException
-    */
-   public static Document loadDocument( InputSource in_source )
-   throws ParserConfigurationException, 
-          SAXException, 
-          IOException
-   {
-      DocumentBuilderFactory dbf = (DocumentBuilderFactory) 
DOCUMENT_BUILDER_FACTORIES.get(  );
-      DocumentBuilder        db = dbf.newDocumentBuilder(  );
-
-      return ( db.parse( in_source ) );
-   }
-
-   /**
-    * Method to load a DOM Document from an InputStream.
-    *
-    * @param in_stream
-    *
-    * @return Document
-    *
-    * @throws ParserConfigurationException
-    * @throws SAXException
-    * @throws IOException
-    */
-   public static Document loadDocument( InputStream in_stream )
-   throws ParserConfigurationException, 
-          SAXException, 
-          IOException
-   {
-      InputStreamReader utf8_stream = new InputStreamReader( in_stream, 
"UTF-8" );
-      Document          doc = loadDocument( new InputSource( utf8_stream ) );
-      utf8_stream.close(  );
-
-      return ( doc );
-   }
-
-   /**
-    * Converts a string containing an XML document into a [EMAIL PROTECTED] 
Document}.
-    *
-    * @param xml_string
-    *
-    * @return the W3C DOM document
-    *
-    * @throws ParserConfigurationException
-    * @throws SAXException
-    * @throws IOException
-    */
-   public static Document toDocument( String xml_string )
-   throws ParserConfigurationException, 
-          SAXException, 
-          IOException
-   {
-      LOG.debug(MSG.getMessage( Keys.LOAD_XML_STRING,xml_string ));
-      return ( loadDocument( IoUtils.toInputStream( xml_string ) ) );
-   }
-
-   /**
-    * Converts an XML [EMAIL PROTECTED] Node} into a string containing the 
corresponding XML. ***NOTE*** requires an XSLT
-    * implementation (ie - Xalan) in the classpath at runtime
-    *
-    * @param node a DOM node
-    *
-    * @return String representation of the node
-    *
-    * @throws Exception
-    */
-   public static String toString( Node node )
-   throws Exception
-   {
-      return ( toString( node, false ) );
-   }
-
-   /**
-    * Converts an XML [EMAIL PROTECTED] Node} into a string containing the 
corresponding XML, optionally pretty-printed with
-    * indenting and newlines. ***NOTE*** requires an XSLT implementation (ie - 
Xalan) in the classpath at runtime
-    *
-    * @param node         a DOM node
-    * @param indentOutput whether or not to indent the output XML
-    *
-    * @return String representation of the node
-    *
-    * @throws Exception
-    */
-   public static String toString( Node    node,
-                                  boolean indentOutput )
-   throws Exception
-   {
-      /**
-       * Due to a bug in the Transformer implementation we need to
-       * synchronize access to the transform() method.
-       */
-      synchronized ( TRANSFORMER_LOCK )
-      {
-         TransformerFactory transformer_factory = (TransformerFactory) 
TRANSFORMER_FACTORIES.get(  );
-         Transformer        transformer = transformer_factory.newTransformer(  
);
-
-         if ( indentOutput )
-         {
-            transformer.setOutputProperty( 
TransformConstants.OUTPUT_PROP_INDENT, "yes" );
-            transformer.setOutputProperty( 
TransformConstants.OUTPUT_PROP_INDENT_AMOUNT, INDENT_SPACES );
-         }
-
-         DOMSource             dom_source = new DOMSource( node );
-         ByteArrayOutputStream doc_stream = new ByteArrayOutputStream(  );
-         StreamResult          result     = new StreamResult( doc_stream );
-
-         transformer.transform( dom_source, result );
-
-         return ( doc_stream.toString(  ) );
-      }
-   }
+    /**
+     * DOCUMENT_ME
+     */
+    private static final Object TRANSFORMER_LOCK = new Object();
+
+    /**
+     * DOCUMENT_ME
+     */
+    private static final String INDENT_SPACES = "2";
+
+    /**
+     * thread local that gives each thread its own TransformerFactory (since 
it is not thread-safe)
+     */
+    public static ThreadLocal TRANSFORMER_FACTORIES =
+            new ThreadLocal()
+            {
+                protected synchronized Object initialValue()
+                {
+                    return TransformerFactory.newInstance();
+                }
+            };
+
+    /**
+     * thread local that gives each thread its own DocumentBuilderFactory 
(since it is not thread-safe)
+     */
+    public static ThreadLocal DOCUMENT_BUILDER_FACTORIES =
+            new ThreadLocal()
+            {
+                protected synchronized Object initialValue()
+                {
+                    DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
+                    dbf.setNamespaceAware( true );
+
+                    return ( dbf );
+                }
+            };
+
+    /**
+     * Loads a DOM Document from an InputSource.
+     *
+     * @param in_source
+     *
+     * @return Document
+     *
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public static Document loadDocument( InputSource in_source )
+            throws ParserConfigurationException,
+            SAXException,
+            IOException
+    {
+        DocumentBuilderFactory dbf = (DocumentBuilderFactory) 
DOCUMENT_BUILDER_FACTORIES.get();
+        DocumentBuilder db = dbf.newDocumentBuilder();
+
+        return ( db.parse( in_source ) );
+    }
+
+    /**
+     * Method to load a DOM Document from an InputStream.
+     *
+     * @param in_stream
+     *
+     * @return Document
+     *
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public static Document loadDocument( InputStream in_stream )
+            throws ParserConfigurationException,
+            SAXException,
+            IOException
+    {
+        InputStreamReader utf8_stream = new InputStreamReader( in_stream, 
"UTF-8" );
+        Document doc = loadDocument( new InputSource( utf8_stream ) );
+        utf8_stream.close();
+
+        return ( doc );
+    }
+
+    /**
+     * Converts a string containing an XML document into a [EMAIL PROTECTED] 
Document}.
+     *
+     * @param xmlString
+     *
+     * @return the W3C DOM document
+     *
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public static Document toDocument( String xmlString )
+            throws ParserConfigurationException,
+            SAXException,
+            IOException
+    {
+        LOG.debug( MSG.getMessage( Keys.LOAD_XML_STRING, xmlString ) );
+        return ( loadDocument( IoUtils.toInputStream( xmlString ) ) );
+    }
+
+    /**
+     * Converts an XML [EMAIL PROTECTED] Node} into a string containing the 
corresponding XML. ***NOTE*** requires an XSLT
+     * implementation (ie - Xalan) in the classpath at runtime
+     *
+     * @param node a DOM node
+     *
+     * @return String representation of the node
+     *
+     * @throws Exception
+     */
+    public static String toString( Node node )
+            throws Exception
+    {
+        return ( toString( node, false ) );
+    }
+
+    /**
+     * Converts an XML [EMAIL PROTECTED] Node} into a string containing the 
corresponding XML, optionally pretty-printed with
+     * indenting and newlines. ***NOTE*** requires an XSLT implementation (ie 
- Xalan) in the classpath at runtime
+     *
+     * @param node         a DOM node
+     * @param indentOutput whether or not to indent the output XML
+     *
+     * @return String representation of the node
+     *
+     * @throws Exception
+     */
+    public static String toString( Node node,
+                                   boolean indentOutput )
+            throws Exception
+    {
+        /**
+         * Due to a bug in the Transformer implementation we need to
+         * synchronize access to the transform() method.
+         */
+        synchronized ( TRANSFORMER_LOCK )
+        {
+            TransformerFactory transformer_factory = (TransformerFactory) 
TRANSFORMER_FACTORIES.get();
+            Transformer transformer = transformer_factory.newTransformer();
+
+            if ( indentOutput )
+            {
+                transformer.setOutputProperty( 
TransformConstants.OUTPUT_PROP_INDENT, "yes" );
+                transformer.setOutputProperty( 
TransformConstants.OUTPUT_PROP_INDENT_AMOUNT, INDENT_SPACES );
+            }
+
+            DOMSource dom_source = new DOMSource( node );
+            ByteArrayOutputStream doc_stream = new ByteArrayOutputStream();
+            StreamResult result = new StreamResult( doc_stream );
+
+            transformer.transform( dom_source, result );
+
+            return ( doc_stream.toString() );
+        }
+    }
 }

Modified: 
incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java
Url: 
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java?view=diff&rev=124294&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java&r1=124293&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java&r2=124294
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java     
(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/soap/SoapClient.java     
Wed Jan  5 14:57:07 2005
@@ -15,10 +15,11 @@
  
*=============================================================================*/
 package org.apache.ws.util.soap;
 
-import org.apache.ws.util.IoUtils;
-import org.apache.ws.util.i18n.MessagesImpl;
-import org.apache.ws.util.i18n.Messages;
+import org.apache.commons.io.CopyUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.ws.util.i18n.Keys;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.ws.util.i18n.MessagesImpl;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -107,7 +108,7 @@
       ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(  );
 
       // Copy the SOAP message to the open connection.
-      IoUtils.copy( soapMessage, byteOutStream );
+      CopyUtils.copy( soapMessage, byteOutStream );
       soapMessage.close(  );
 
       byte[] buf = byteOutStream.toByteArray(  );
@@ -141,7 +142,7 @@
          inStream = httpConn.getErrorStream(  );
       }
 
-      return IoUtils.toString( inStream );
+      return IOUtils.toString( inStream );
    }
 
    private static void validateArgs( String[] args )

Modified: 
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
Url: 
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java?view=diff&rev=124294&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r1=124293&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r2=124294
==============================================================================
--- 
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
   (original)
+++ 
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
   Wed Jan  5 14:57:07 2005
@@ -16,14 +16,15 @@
 package org.apache.ws.resource.properties;
 
 import junit.framework.TestCase;
+import org.apache.commons.io.CopyUtils;
 import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
-import org.apache.ws.util.IoUtils;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
 import org.apache.xmlbeans.impl.tool.SchemaCompiler;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -67,7 +68,7 @@
    {
       InputStream xsdInStream = ClassLoader.getSystemResourceAsStream( 
RESOURCE_PATH_SUSHI_PROPS_XSD );
       File xsdFile = new File( BASE_TMP_DIR, "SushiProperties.xsd" );
-      IoUtils.copy( xsdInStream, xsdFile );
+      CopyUtils.copy( xsdInStream, new FileOutputStream( xsdFile ) );
       if ( ! compileSchema( xsdFile ) )
       {
          throw new RuntimeException();

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to