subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r918233 - in /subversion/trunk/subversion/bindings/javahl: native/SVNAdmin.cpp native/SVNAdmin.h native/org_apache_subversion_javahl_SVNAdmin.cpp src/org/apache/subversion/javahl/SVNAdmin.java src/org/tigris/subversion/javahl/SVNAdmin.java
Date Tue, 02 Mar 2010 22:44:11 GMT
Author: hwright
Date: Tue Mar  2 22:44:10 2010
New Revision: 918233

URL: http://svn.apache.org/viewvc?rev=918233&view=rev
Log:
JavaHL: Convert on output parameter for SVNAdmin to a Set.

[ in subversion/bindings/javahl/ ]
* native/SVNAdmin.cpp,
  native/SVNAdmin.h
  (lslocks): Rewrite to create the Set of Locks.

* native/org_apache_subversion_javahl_SVNAdmin.cpp
  (Java_org_apache_subversion_javahl_SVNAdmin_lslocks): Return the jobject.

* src/org/apache/subversion/javahl/SVNAdmin.java
  (lslocks): Return a Set<Lock>.

* src/org/tigris/subversion/javahl/SVNAdmin.java
  (lslock): Update wrapper.

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/SVNAdmin.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNAdmin.java

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp?rev=918233&r1=918232&r2=918233&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.cpp Tue Mar  2 22:44:10 2010
@@ -498,7 +498,7 @@
                                  requestPool.pool()), );
 }
 
-jobjectArray SVNAdmin::lslocks(const char *path)
+jobject SVNAdmin::lslocks(const char *path)
 {
   SVN::Pool requestPool;
   SVN_JNI_NULL_PTR_EX(path, "path", NULL);
@@ -522,24 +522,41 @@
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
 
-  jobjectArray ret = env->NewObjectArray(count, clazz, NULL);
+  jclass sclazz = env->FindClass("java/util/Set");
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
 
-  env->DeleteLocalRef(clazz);
+  static jmethodID init_mid = 0;
+  if (init_mid == 0)
+    {
+      init_mid = env->GetMethodID(sclazz, "<init>", "()V");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  static jmethodID add_mid = 0;
+  if (add_mid == 0)
+    {
+      add_mid = env->GetMethodID(sclazz, "add",
+                                 "(Ljava/lang/Object;)Z");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  jobject map = env->NewObject(sclazz, init_mid);
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
 
-  int i = 0;
   for (hi = apr_hash_first (requestPool.pool(), locks);
        hi;
-       hi = apr_hash_next (hi), ++i)
+       hi = apr_hash_next (hi))
     {
       void *val;
       apr_hash_this (hi, NULL, NULL, &val);
       svn_lock_t *lock = (svn_lock_t *)val;
       jobject jLock = CreateJ::Lock(lock);
-      env->SetObjectArrayElement(ret, i, jLock);
+
+      env->CallObjectMethod(map, add_mid, jLock);
       if (JNIUtil::isJavaExceptionThrown())
         return NULL;
 
@@ -548,7 +565,15 @@
         return NULL;
     }
 
-  return ret;
+  env->DeleteLocalRef(clazz);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  env->DeleteLocalRef(sclazz);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  return map;
 }
 
 void SVNAdmin::rmlocks(const char *path, Targets &locks)

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h?rev=918233&r1=918232&r2=918233&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNAdmin.h Tue Mar  2 22:44:10 2010
@@ -40,7 +40,7 @@
 {
  public:
   void rmlocks(const char *path, Targets &locks);
-  jobjectArray lslocks(const char *path);
+  jobject lslocks(const char *path);
   void verify(const char *path, Outputer &messageOut,
               Revision &revisionStart, Revision &revisionEnd);
   void setRevProp(const char *path, Revision &revision,

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=918233&r1=918232&r2=918233&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
Tue Mar  2 22:44:10 2010
@@ -428,7 +428,7 @@
   cl->verify(path, messageOut, revisionStart, revisionEnd);
 }
 
-JNIEXPORT jobjectArray JNICALL
+JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_SVNAdmin_lslocks
 (JNIEnv *env, jobject jthis, jstring jpath)
 {

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=918233&r1=918232&r2=918233&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
Tue Mar  2 22:44:10 2010
@@ -23,6 +23,8 @@
 
 package org.apache.subversion.javahl;
 
+import java.util.Set;
+
 /**
  * This class offers the same commands as the svnadmin commandline
  * client.
@@ -317,7 +319,7 @@
      * @throws ClientException  throw in case of problem
      * @since 1.2
      */
-    public native Lock[] lslocks(String path) throws ClientException;
+    public native Set<Lock> lslocks(String path) throws ClientException;
 
     /**
      * remove multiple locks from the repository

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=918233&r1=918232&r2=918233&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
Tue Mar  2 22:44:10 2010
@@ -23,6 +23,8 @@
 
 package org.tigris.subversion.javahl;
 
+import java.util.Set;
+
 /**
  * This class offers the same commands as the svnadmin commandline
  * client.
@@ -447,13 +449,15 @@
     {
         try
         {
-            org.apache.subversion.javahl.Lock[] aLocks =
+            Set<org.apache.subversion.javahl.Lock> aLocks =
                                                     aSVNAdmin.lslocks(path);
-            Lock[] locks = new Lock[aLocks.length];
+            Lock[] locks = new Lock[aLocks.size()];
             
-            for (int i = 0; i < aLocks.length; i++)
+            int i = 0;
+            for (org.apache.subversion.javahl.Lock lock : aLocks)
             {
-                locks[i] = new Lock(aLocks[i]);
+                locks[i] = new Lock(lock);
+                i++;
             }
 
             return locks;



Mime
View raw message