subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r949194 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/
Date Fri, 28 May 2010 14:51:25 GMT
Author: hwright
Date: Fri May 28 14:51:24 2010
New Revision: 949194

URL: http://svn.apache.org/viewvc?rev=949194&view=rev
Log:
JavaHL: Use the standard InputStream to collect bytes, rather than a
home-grown variety.

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/SVNAdminTests.java
  (testLoadRepo): Use a generic InputStream.

* tests/org/apache/subversion/javahl/SVNTests.java
  (FileInputer): Remove.
  (createInitialRepository): Use a FileInputSream, rather than a custome class.

* native/SVNAdmin.h,
  native/SVNAdmin.cpp
  (load): Use the InputStream object.

* native/InputStream.h:
  Copied from Inputer.h, replace use of Inputer with InputStream.

* native/org_apache_subversion_javahl_SVNAdmin.cpp
  (Java_org_apache_subversion_javahl_SVNAdmin_load): Use InputStream.

* native/InputStream.cpp:
  Copied from Inputer.cpp, replace uses of Inputer with InputStream.
 
* native/Inputer.cpp:
  Remove.

* native/Inputer.h:
  Remove.

* src/org/apache/subversion/javahl/IInput.java:
  Remove.

* src/org/apache/subversion/javahl/ISVNAdmin.java,
  src/org/apache/subversion/javahl/SVNAdmin.java
  (load): Use a standard InputStream.

* src/org/tigris/subversion/javahl/SVNAdmin.java
  (load): Update wrapper to pass an InputStream to the Apache method.
  (InputWrapper): New.

* src/org/tigris/subversion/javahl/InputInterface.java:
  Revert changes made in r906648.

Added:
    subversion/trunk/subversion/bindings/javahl/native/InputStream.cpp
      - copied, changed from r949066, subversion/trunk/subversion/bindings/javahl/native/Inputer.cpp
    subversion/trunk/subversion/bindings/javahl/native/InputStream.h
      - copied, changed from r949066, subversion/trunk/subversion/bindings/javahl/native/Inputer.h
Removed:
    subversion/trunk/subversion/bindings/javahl/native/Inputer.cpp
    subversion/trunk/subversion/bindings/javahl/native/Inputer.h
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/IInput.java
Modified:
    subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp
    subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNAdmin.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNAdmin.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNAdmin.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/InputInterface.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java

Copied: subversion/trunk/subversion/bindings/javahl/native/InputStream.cpp (from r949066,
subversion/trunk/subversion/bindings/javahl/native/Inputer.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/InputStream.cpp?p2=subversion/trunk/subversion/bindings/javahl/native/InputStream.cpp&p1=subversion/trunk/subversion/bindings/javahl/native/Inputer.cpp&r1=949066&r2=949194&rev=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/Inputer.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/InputStream.cpp Fri May 28 14:51:24
2010
@@ -20,24 +20,24 @@
  * ====================================================================
  * @endcopyright
  *
- * @file Inputer.cpp
- * @brief Implementation of the class Inputer
+ * @file InputStream.cpp
+ * @brief Implementation of the class InputStream
  */
 
-#include "Inputer.h"
+#include "InputStream.h"
 #include "JNIUtil.h"
 #include "JNIByteArray.h"
 
 /**
- * Create an Inputer object.
+ * Create an InputStream object.
  * @param jthis the Java object to be stored
  */
-Inputer::Inputer(jobject jthis)
+InputStream::InputStream(jobject jthis)
 {
   m_jthis = jthis;
 }
 
-Inputer::~Inputer()
+InputStream::~InputStream()
 {
   // The m_jthis does not need to be destroyed, because it is the
   // passed in parameter to the Java method.
@@ -49,35 +49,35 @@ Inputer::~Inputer()
  * @param pool  the pool, from which the structure is allocated
  * @return the input stream
  */
-svn_stream_t *Inputer::getStream(const SVN::Pool &pool)
+svn_stream_t *InputStream::getStream(const SVN::Pool &pool)
 {
   // Create a stream with this as the baton and set the read and
   // close functions.
   svn_stream_t *ret = svn_stream_create(this, pool.pool());
-  svn_stream_set_read(ret, Inputer::read);
-  svn_stream_set_close(ret, Inputer::close);
+  svn_stream_set_read(ret, InputStream::read);
+  svn_stream_set_close(ret, InputStream::close);
   return ret;
 }
 
 /**
  * Implements svn_read_fn_t to read to data into Subversion.
- * @param baton     an Inputer object for the callback
+ * @param baton     an InputStream object for the callback
  * @param buffer    the buffer for the read data
  * @param len       on input the buffer len, on output the number of read bytes
  * @return a subversion error or SVN_NO_ERROR
  */
-svn_error_t *Inputer::read(void *baton, char *buffer, apr_size_t *len)
+svn_error_t *InputStream::read(void *baton, char *buffer, apr_size_t *len)
 {
   JNIEnv *env = JNIUtil::getEnv();
   // An object of our class is passed in as the baton.
-  Inputer *that = (Inputer*)baton;
+  InputStream *that = (InputStream*)baton;
 
   // The method id will not change during the time this library is
   // loaded, so it can be cached.
   static jmethodID mid = 0;
   if (mid == 0)
     {
-      jclass clazz = env->FindClass(JAVA_PACKAGE"/IInput");
+      jclass clazz = env->FindClass("java/io/InputStream");
       if (JNIUtil::isJavaExceptionThrown())
         return SVN_NO_ERROR;
 
@@ -122,22 +122,22 @@ svn_error_t *Inputer::read(void *baton, 
 
 /**
  * Implements svn_close_fn_t to close the input stream.
- * @param baton     an Inputer object for the callback
+ * @param baton     an InputStream object for the callback
  * @return a subversion error or SVN_NO_ERROR
  */
-svn_error_t *Inputer::close(void *baton)
+svn_error_t *InputStream::close(void *baton)
 {
   JNIEnv *env = JNIUtil::getEnv();
 
   // An object of our class is passed in as the baton
-  Inputer *that = (Inputer*)baton;
+  InputStream *that = (InputStream*)baton;
 
   // The method id will not change during the time this library is
   // loaded, so it can be cached.
   static jmethodID mid = 0;
   if (mid == 0)
     {
-      jclass clazz = env->FindClass(JAVA_PACKAGE"/IInput");
+      jclass clazz = env->FindClass("java/io/InputStream");
       if (JNIUtil::isJavaExceptionThrown())
         return SVN_NO_ERROR;
 

Copied: subversion/trunk/subversion/bindings/javahl/native/InputStream.h (from r949066, subversion/trunk/subversion/bindings/javahl/native/Inputer.h)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/InputStream.h?p2=subversion/trunk/subversion/bindings/javahl/native/InputStream.h&p1=subversion/trunk/subversion/bindings/javahl/native/Inputer.h&r1=949066&r2=949194&rev=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/Inputer.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/InputStream.h Fri May 28 14:51:24 2010
@@ -20,22 +20,22 @@
  * ====================================================================
  * @endcopyright
  *
- * @file Inputer.h
- * @brief Interface of the class Inputer
+ * @file InputStream.h
+ * @brief Interface of the class InputStream
  */
 
-#ifndef INPUTER_H
-#define INPUTER_H
+#ifndef INPUT_STREAM_H
+#define INPUT_STREAM_H
 
 #include <jni.h>
 #include "svn_io.h"
 #include "Pool.h"
 
 /**
- * This class contains a Java objects implementing the interface Inputer and
+ * This class contains a Java objects implementing the interface InputStream and
  * implements the functions read & close of svn_stream_t.
  */
-class Inputer
+class InputStream
 {
  private:
   /**
@@ -45,9 +45,9 @@ class Inputer
   static svn_error_t *read(void *baton, char *buffer, apr_size_t *len);
   static svn_error_t *close(void *baton);
  public:
-  Inputer(jobject jthis);
-  ~Inputer();
+  InputStream(jobject jthis);
+  ~InputStream();
   svn_stream_t *getStream(const SVN::Pool &pool);
 };
 
-#endif // INPUTER_H
+#endif // INPUT_STREAM_H

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp Fri May 28 14:51:24 2010
@@ -263,7 +263,7 @@ void SVNAdmin::listUnusedDBLogs(const ch
 }
 
 void SVNAdmin::load(const char *path,
-                    Inputer &dataIn,
+                    InputStream &dataIn,
                     OutputStream &messageOut,
                     bool ignoreUUID,
                     bool forceUUID,

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h Fri May 28 14:51:24 2010
@@ -32,7 +32,7 @@
 #include "SVNBase.h"
 #include "Revision.h"
 #include "OutputStream.h"
-#include "Inputer.h"
+#include "InputStream.h"
 #include "MessageReceiver.h"
 #include "StringArray.h"
 
@@ -50,7 +50,7 @@ class SVNAdmin : public SVNBase
   void rmtxns(const char *path, StringArray &transactions);
   jlong recover(const char *path);
   void lstxns(const char *path, MessageReceiver &messageReceiver);
-  void load(const char *path, Inputer &dataIn, OutputStream &messageOut,
+  void load(const char *path, InputStream &dataIn, OutputStream &messageOut,
             bool ignoreUUID, bool forceUUID, bool usePreCommitHook,
             bool usePostCommitHook, const char *relativePath);
   void listUnusedDBLogs(const char *path,

Modified: subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNAdmin.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNAdmin.cpp?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNAdmin.cpp
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNAdmin.cpp
Fri May 28 14:51:24 2010
@@ -31,7 +31,7 @@
 #include "JNIByteArray.h"
 #include "SVNAdmin.h"
 #include "Revision.h"
-#include "Inputer.h"
+#include "InputStream.h"
 #include "OutputStream.h"
 #include "MessageReceiver.h"
 #include "svn_props.h"
@@ -253,7 +253,7 @@ Java_org_apache_subversion_javahl_SVNAdm
   if (JNIUtil::isExceptionThrown())
     return;
 
-  Inputer inputData(jinputData);
+  InputStream inputData(jinputData);
   if (JNIUtil::isExceptionThrown())
     return;
 

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNAdmin.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNAdmin.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNAdmin.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNAdmin.java
Fri May 28 14:51:24 2010
@@ -25,6 +25,7 @@ package org.apache.subversion.javahl;
 
 import java.util.Set;
 import java.io.OutputStream;
+import java.io.InputStream;
 
 import org.apache.subversion.javahl.SVNAdmin.MessageReceiver;
 
@@ -134,7 +135,7 @@ public interface ISVNAdmin {
 	 * @throws ClientException  throw in case of problem
 	 * @since 1.5
 	 */
-	public abstract void load(String path, IInput dataInput,
+	public abstract void load(String path, InputStream dataInput,
 			OutputStream messageOutput, boolean ignoreUUID, boolean forceUUID,
 			boolean usePreCommitHook, boolean usePostCommitHook,
 			String relativePath) throws ClientException;

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNAdmin.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNAdmin.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNAdmin.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNAdmin.java
Fri May 28 14:51:24 2010
@@ -25,6 +25,7 @@ package org.apache.subversion.javahl;
 
 import java.util.Set;
 import java.io.OutputStream;
+import java.io.InputStream;
 
 /**
  * This class offers the same commands as the svnadmin commandline
@@ -185,7 +186,7 @@ public class SVNAdmin implements ISVNAdm
      * @throws ClientException  throw in case of problem
      * @since 1.5
      */
-    public native void load(String path, IInput dataInput,
+    public native void load(String path, InputStream dataInput,
                             OutputStream messageOutput, boolean ignoreUUID,
                             boolean forceUUID, boolean usePreCommitHook,
                             boolean usePostCommitHook, String relativePath)

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/InputInterface.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/InputInterface.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/InputInterface.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/InputInterface.java
Fri May 28 14:51:24 2010
@@ -23,11 +23,24 @@
 
 package org.tigris.subversion.javahl;
 
+import java.io.IOException;
+
 /**
  * Interface for data to be received from subversion
  * used for SVNAdmin.load and SVNAdmin.dump
  */
 public interface InputInterface
-    extends org.apache.subversion.javahl.IInput
 {
+    /**
+     * read the number of data.length bytes from input.
+     * @param data          array to store the read bytes.
+     * @throws IOException  throw in case of problems.
+     */
+    public int read(byte [] data) throws IOException;
+
+    /**
+     * close the input
+     * @throws IOException throw in case of problems.
+     */
+    public void close() throws IOException;
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java
Fri May 28 14:51:24 2010
@@ -25,6 +25,7 @@ package org.tigris.subversion.javahl;
 
 import java.util.Set;
 import java.io.OutputStream;
+import java.io.InputStream;
 import java.io.IOException;
 
 /**
@@ -289,7 +290,8 @@ public class SVNAdmin
     {
         try
         {
-            aSVNAdmin.load(path, dataInput, new OutputWrapper(messageOutput),
+            aSVNAdmin.load(path, new InputWrapper(dataInput),
+                           new OutputWrapper(messageOutput),
                            ignoreUUID, forceUUID, usePreCommitHook,
                            usePostCommitHook, relativePath);
         }
@@ -516,4 +518,33 @@ public class SVNAdmin
             outputer.close();
         }
     }
+
+    private class InputWrapper extends InputStream
+    {
+        private InputInterface inputer;
+
+        InputWrapper(InputInterface inputer)
+        {
+            this.inputer = inputer;
+        }
+
+        public int read() throws IOException
+        {
+            byte[] b = new byte[1];
+            if (inputer.read(b) > 0)
+                return b[0];
+            else
+                return -1;
+        }
+
+        public int read(byte[] b) throws IOException
+        {
+            return inputer.read(b);
+        }
+
+        public void close() throws IOException
+        {
+            inputer.close();
+        }
+    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
Fri May 28 14:51:24 2010
@@ -25,7 +25,9 @@ package org.apache.subversion.javahl;
 import org.apache.subversion.javahl.callback.*;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.OutputStream;
+import java.io.InputStream;
 import java.io.IOException;
 import java.util.Map;
 
@@ -98,7 +100,7 @@ public class SVNAdminTests extends SVNTe
         String testSrcdir = System.getProperty("test.srcdir",
                 "subversion/bindings/javahl");
         File dump = new File(testSrcdir, "tests/data/issue2979.dump");
-        IInput input = new FileInputer(dump);
+        InputStream input = new FileInputStream(dump);
         OutputStream loadLog = new IgnoreOutputer();
         admin.load(thisTest.getRepositoryPath(),
                    input, loadLog, true, true, false, false, null);

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java?rev=949194&r1=949193&r2=949194&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java
Fri May 28 14:51:24 2010
@@ -441,48 +441,6 @@ class SVNTests extends TestCase
     }
 
     /**
-     * internal class which implements the InputInterface to read the data
-     * from a file.
-     */
-    public class FileInputer implements IInput
-    {
-        /**
-         * input file stream
-         */
-        FileInputStream myStream;
-
-        /**
-         * create a new object
-         * @param inputName     the file from which the data is read
-         * @throws IOException If <code>inputName</code> is not
-         * found.
-         */
-        public FileInputer(File inputName) throws IOException
-        {
-            myStream = new FileInputStream(inputName);
-        }
-
-        /**
-         * read the number of data.length bytes from input.
-         * @param data          array to store the read bytes.
-         * @throws IOException  throw in case of problems.
-         */
-        public int read(byte[] data) throws IOException
-        {
-            return myStream.read(data);
-        }
-
-        /**
-         * close the input
-         * @throws IOException throw in case of problems.
-         */
-        public void close() throws IOException
-        {
-            myStream.close();
-        }
-    }
-
-    /**
      * Represents the repository and (possibly) the working copy for
      * one test.
      */
@@ -705,7 +663,8 @@ class SVNTests extends TestCase
                          conf.getAbsolutePath(), fsType);
             if (loadGreek)
             {
-                admin.load(repos.getAbsolutePath(), new FileInputer(greekDump),
+                admin.load(repos.getAbsolutePath(),
+                           new FileInputStream(greekDump),
                            new IgnoreOutputer(), false, false, false, false,
                            null);
             }



Mime
View raw message