subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1497898 - in /subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote: RemoteSession.java UpdateReporter.java
Date Fri, 28 Jun 2013 19:35:17 GMT
Author: brane
Date: Fri Jun 28 19:35:17 2013
New Revision: 1497898

URL: http://svn.apache.org/r1497898
Log:
Extend the JavaHL reporter infrastructure.

[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* RemoteSession.java
  (RemoteSession.reporterReference): New (weak) reference to active reporter.
  (RemoteSession.disposeReporter): Dispose callback for reporter instances.
  (RemoteSession.disposeEditor): Make argument more abstract and update docs.
  (RemoteSession.dispose): Deactivate any open reporters.
  (RemoteSession.check_inactive): Helper for editor/reporter validity check.
  (RemoteSession.getCommitEditor): Use check_inactive to validate state.

* remote/UpdateReporter.java (UpdateReporter.nativeDispose): New.
  (UpdateReporter.dispose): Notify session and call nativeDispose.

Modified:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java?rev=1497898&r1=1497897&r2=1497898&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
Fri Jun 28 19:35:17 2013
@@ -57,6 +57,17 @@ public class RemoteSession extends JNIOb
             }
             editorReference = null;
         }
+        if (reporterReference != null)
+        {
+            // Deactivate the open reporter
+            ISVNReporter rp = reporterReference.get();
+            if (rp != null)
+            {
+                rp.dispose();
+                reporterReference.clear();
+            }
+            reporterReference = null;
+        }
         nativeDispose();
     }
 
@@ -114,13 +125,10 @@ public class RemoteSession extends JNIOb
                                       boolean keepLocks)
             throws ClientException
     {
-        if (editorReference != null && editorReference.get() != null)
-            throw new IllegalStateException("An editor is already active");
-
+        check_inactive(editorReference, reporterReference);
         ISVNEditor ed =
             CommitEditor.createInstance(this, revisionProperties,
                                         commitCallback, lockTokens, keepLocks);
-
         if (editorReference != null)
             editorReference.clear();
         editorReference = new WeakReference<ISVNEditor>(ed);
@@ -235,18 +243,19 @@ public class RemoteSession extends JNIOb
     private class RemoteSessionContext extends OperationContext {}
 
     /*
-     * A reference to the current open editor. We need this in order
+     * A reference to the current active editor. We need this in order
      * to dispose/abort the editor when the session is disposed. And
-     * furthermore, there can be only one editor active at any time.
+     * furthermore, there can be only one editor or reporter active at
+     * any time.
      */
     private WeakReference<ISVNEditor> editorReference;
 
     /*
-     * The commit editor callse this when disposed to clear the
+     * The commit editor calls this when disposed to clear the
      * reference. Note that this function will be called during our
      * dispose, so make sure they don't step on each others' toes.
      */
-    void disposeEditor(CommitEditor editor)
+    void disposeEditor(ISVNEditor editor)
     {
         if (editorReference == null)
             return;
@@ -259,6 +268,31 @@ public class RemoteSession extends JNIOb
     }
 
     /*
+     * A reference to the current active reporter. We need this in
+     * order to dispose/abort the report when the session is
+     * disposed. And furthermore, there can be only one reporter or
+     * editor active at any time.
+     */
+    private WeakReference<ISVNReporter> reporterReference;
+
+    /*
+     * The update reporter calls this when disposed to clear the
+     * reference. Note that this function will be called during our
+     * dispose, so make sure they don't step on each others' toes.
+     */
+    void disposeReporter(ISVNReporter reporter)
+    {
+        if (reporterReference == null)
+            return;
+        ISVNReporter rp = reporterReference.get();
+        if (rp == null)
+            return;
+        if (rp != reporter)
+            throw new IllegalStateException("Disposing unknown reporter");
+        reporterReference.clear();
+    }
+
+    /*
      * Private helper methods.
      */
     private final static void maybe_clear(Map clearable)
@@ -270,4 +304,14 @@ public class RemoteSession extends JNIOb
                 // ignored
             }
     }
+
+    private final static
+        void check_inactive(WeakReference<ISVNEditor> editorReference,
+                            WeakReference<ISVNReporter> reporterReference)
+    {
+        if (editorReference != null && editorReference.get() != null)
+            throw new IllegalStateException("An editor is already active");
+        if (reporterReference != null && reporterReference.get() != null)
+            throw new IllegalStateException("A reporter is already active");
+    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java?rev=1497898&r1=1497897&r2=1497898&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java
Fri Jun 28 19:35:17 2013
@@ -36,7 +36,11 @@ import org.apache.subversion.javahl.Clie
  */
 public class UpdateReporter extends JNIObject implements ISVNReporter
 {
-    public void dispose() {/* TODO: */}
+    public void dispose()
+    {
+        session.disposeReporter(this);
+        nativeDispose();
+    }
 
     public void setPath(String path,
                         long revision,
@@ -74,6 +78,11 @@ public class UpdateReporter extends JNIO
         throw new RuntimeException("Not implemented: abortReport");
     }
 
+    /*
+     * Wrapped private native implementation declarations.
+     */
+    private /*TODO:native*/ void nativeDispose() {;}
+
     /**
      * This constructor is called from the factory to get an instance.
      */
@@ -86,4 +95,3 @@ public class UpdateReporter extends JNIO
     /** Stores a reference to the session that created this reporter. */
     protected RemoteSession session;
 }
-



Mime
View raw message