You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/06/11 12:29:47 UTC

svn commit: r953643 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/

Author: hwright
Date: Fri Jun 11 10:29:47 2010
New Revision: 953643

URL: http://svn.apache.org/viewvc?rev=953643&view=rev
Log:
JavaHL: In a place we use a local file path, use a File object instead of a
String.  This will eventually propogate through JavaHL, this commit just
introduces the needed infrastructure, and a sample switch.

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/SVNTests.java
  (setUp, createInitialRepository): Use the File directly in the updated API.

* native/org_apache_subversion_javahl_SVNAdmin.cpp
  (Java_org_apache_subversion_javahl_SVNAdmin_create): Update for the new
    File arguments.

* native/File.h:
  New.

* native/File.cpp:
  New.

* src/org/apache/subversion/javahl/ISVNAdmin.java,
  src/org/apache/subversion/javahl/SVNAdmin.java
  (create): Use a File where we want a local path.

* src/org/tigris/subversion/javahl/SVNAdmin.java
  (create): Update the compat wrapper.

Added:
    subversion/trunk/subversion/bindings/javahl/native/File.cpp   (with props)
    subversion/trunk/subversion/bindings/javahl/native/File.h   (with props)
Modified:
    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/SVNAdmin.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java

Added: subversion/trunk/subversion/bindings/javahl/native/File.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/File.cpp?rev=953643&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/File.cpp (added)
+++ subversion/trunk/subversion/bindings/javahl/native/File.cpp Fri Jun 11 10:29:47 2010
@@ -0,0 +1,86 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ * @endcopyright
+ *
+ * @file File.cpp
+ * @brief Implementation of the class File
+ */
+
+#include "File.h"
+#include "JNIUtil.h"
+#include "JNIByteArray.h"
+
+/**
+ * Create an File object.
+ * @param jthis the Java object to be stored
+ */
+File::File(jobject jthis)
+  : stringHolder(NULL)
+{
+  m_jthis = jthis;
+}
+
+File::~File()
+{
+  // The m_jthis does not need to be destroyed, because it is the
+  // passed in parameter to the Java method.
+  delete stringHolder;
+}
+
+/**
+ * Create an absolute path from the File object, make it internal style,
+ * and return it.
+ * @return the input stream
+ */
+const char *File::getAbsPath()
+{
+  if (stringHolder == NULL)
+    {
+      if (m_jthis == NULL)
+        return NULL;
+
+      JNIEnv *env = JNIUtil::getEnv();
+
+      jclass clazz = env->FindClass("java/io/File");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      static jmethodID mid = 0;
+      if (mid == 0)
+        {
+          mid = env->GetMethodID(clazz, "getAbsolutePath",
+                                 "()Ljava/lang/String;");
+          if (JNIUtil::isJavaExceptionThrown())
+            return NULL;
+        }
+
+      jstring jabsolutePath = (jstring) env->CallObjectMethod(m_jthis, mid);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      stringHolder = new JNIStringHolder(jabsolutePath);
+
+      env->DeleteLocalRef(clazz);
+      env->DeleteLocalRef(jabsolutePath);
+    }
+
+  return static_cast<const char *>(*stringHolder);
+}

Propchange: subversion/trunk/subversion/bindings/javahl/native/File.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/bindings/javahl/native/File.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/File.h?rev=953643&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/File.h (added)
+++ subversion/trunk/subversion/bindings/javahl/native/File.h Fri Jun 11 10:29:47 2010
@@ -0,0 +1,53 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ * @endcopyright
+ *
+ * @file File.h
+ * @brief Interface of the class File
+ */
+
+#ifndef FILE_H
+#define FILE_H
+
+#include <jni.h>
+#include "svn_io.h"
+#include "Pool.h"
+#include "JNIStringHolder.h"
+
+/**
+ * This class contains a Java objects implementing the interface File and
+ * implements the functions read & close of svn_stream_t.
+ */
+class File
+{
+ private:
+  /**
+   * A local reference to the Java object.
+   */
+  jobject m_jthis;
+  JNIStringHolder *stringHolder;
+ public:
+  File(jobject jthis);
+  ~File();
+  const char *getAbsPath();
+};
+
+#endif // FILE_H

Propchange: subversion/trunk/subversion/bindings/javahl/native/File.h
------------------------------------------------------------------------------
    svn:eol-style = native

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=953643&r1=953642&r2=953643&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 Jun 11 10:29:47 2010
@@ -34,6 +34,7 @@
 #include "InputStream.h"
 #include "OutputStream.h"
 #include "MessageReceiver.h"
+#include "File.h"
 #include "svn_props.h"
 #include "svn_private_config.h"
 
@@ -72,8 +73,8 @@ Java_org_apache_subversion_javahl_SVNAdm
 
 JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_SVNAdmin_create
-(JNIEnv *env, jobject jthis, jstring jpath, jboolean jdisableFsyncCommit,
- jboolean jkeepLog, jstring jconfigpath, jstring jfstype)
+(JNIEnv *env, jobject jthis, jobject jpath, jboolean jdisableFsyncCommit,
+ jboolean jkeepLog, jobject jconfigpath, jstring jfstype)
 {
   JNIEntry(SVNAdmin, create);
   SVNAdmin *cl = SVNAdmin::getCppObject(jthis);
@@ -83,11 +84,11 @@ Java_org_apache_subversion_javahl_SVNAdm
       return;
     }
 
-  JNIStringHolder path(jpath);
+  File path(jpath);
   if (JNIUtil::isExceptionThrown())
     return;
 
-  JNIStringHolder configpath(jconfigpath);
+  File configpath(jconfigpath);
   if (JNIUtil::isExceptionThrown())
     return;
 
@@ -95,8 +96,8 @@ Java_org_apache_subversion_javahl_SVNAdm
   if (JNIUtil::isExceptionThrown())
     return;
 
-  cl->create(path, jdisableFsyncCommit? true : false, jkeepLog? true : false,
-             configpath, fstype);
+  cl->create(path.getAbsPath(), jdisableFsyncCommit? true : false,
+             jkeepLog? true : false, configpath.getAbsPath(), fstype);
 }
 
 JNIEXPORT void JNICALL

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=953643&r1=953642&r2=953643&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 Jun 11 10:29:47 2010
@@ -26,6 +26,7 @@ package org.apache.subversion.javahl;
 import java.util.Set;
 import java.io.OutputStream;
 import java.io.InputStream;
+import java.io.File;
 
 import org.apache.subversion.javahl.SVNAdmin.MessageReceiver;
 
@@ -60,8 +61,8 @@ public interface ISVNAdmin {
 	 * @param fstype                the type of the filesystem (BDB or FSFS)
 	 * @throws ClientException  throw in case of problem
 	 */
-	public abstract void create(String path, boolean disableFsyncCommit,
-			boolean keepLog, String configPath, String fstype)
+	public abstract void create(File path, boolean disableFsyncCommit,
+			boolean keepLog, File configPath, String fstype)
 			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=953643&r1=953642&r2=953643&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 Jun 11 10:29:47 2010
@@ -26,6 +26,7 @@ package org.apache.subversion.javahl;
 import java.util.Set;
 import java.io.OutputStream;
 import java.io.InputStream;
+import java.io.File;
 
 /**
  * This class offers the same commands as the svnadmin commandline
@@ -98,8 +99,8 @@ public class SVNAdmin implements ISVNAdm
      * @param fstype                the type of the filesystem (BDB or FSFS)
      * @throws ClientException  throw in case of problem
      */
-    public native void create(String path, boolean disableFsyncCommit,
-                              boolean keepLog, String configPath,
+    public native void create(File path, boolean disableFsyncCommit,
+                              boolean keepLog, File configPath,
                               String fstype) throws ClientException;
 
     /**

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=953643&r1=953642&r2=953643&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 Jun 11 10:29:47 2010
@@ -26,6 +26,7 @@ package org.tigris.subversion.javahl;
 import java.util.Set;
 import java.io.OutputStream;
 import java.io.InputStream;
+import java.io.File;
 import java.io.IOException;
 
 /**
@@ -101,7 +102,8 @@ public class SVNAdmin
             throws ClientException
     {
         try {
-            aSVNAdmin.create(path, disableFsyncCommit, keepLog, configPath,
+            aSVNAdmin.create(new File(path), disableFsyncCommit, keepLog,
+                             configPath == null ? null : new File(configPath),
                              fstype);
         } catch (org.apache.subversion.javahl.ClientException ex) {
             throw new ClientException(ex);

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=953643&r1=953642&r2=953643&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 Jun 11 10:29:47 2010
@@ -233,8 +233,7 @@ class SVNTests extends TestCase
         File greekFiles = buildGreekFiles();
         greekRepos = new File(localTmp, "repos");
         greekDump = new File(localTmp, "greek_dump");
-        admin.create(greekRepos.getAbsolutePath(), true,false, null,
-                     this.fsType);
+        admin.create(greekRepos, true,false, null, this.fsType);
         addExpectedCommitItem(greekFiles.getAbsolutePath(), null, null,
                               NodeKind.none, CommitItemStateFlags.Add);
         client.doImport(greekFiles.getAbsolutePath(), makeReposUrl(greekRepos),
@@ -659,8 +658,7 @@ class SVNTests extends TestCase
             File repos = new File(repositories, this.testName);
             removeDirOrFile(repos);
             // create and load the repository from the default repository dump
-            admin.create(repos.getAbsolutePath(), true, false,
-                         conf.getAbsolutePath(), fsType);
+            admin.create(repos, true, false, conf, fsType);
             if (loadGreek)
             {
                 admin.load(repos.getAbsolutePath(),