subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r905828 - in /subversion/trunk: ./ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subversion/bindings/javahl/src/org/tigris/subversion/javahl/
Date Tue, 02 Feb 2010 22:54:26 GMT
Author: hwright
Date: Tue Feb  2 22:54:25 2010
New Revision: 905828

URL: http://svn.apache.org/viewvc?rev=905828&view=rev
Log:
Revert r905689 and r905805, in preparation for a different, but more correct,
method of wrapping the new javahl packages.

As it turns out, in programming, as in life, the quick-and-easy fix is rarely
the optimal long-term solution.

Added:
    subversion/trunk/subversion/bindings/javahl/native/org_tigris_subversion_javahl_NativeResources.cpp
      - copied unchanged from r905688, subversion/trunk/subversion/bindings/javahl/native/org_tigris_subversion_javahl_NativeResources.cpp
    subversion/trunk/subversion/bindings/javahl/native/org_tigris_subversion_javahl_Version.cpp
      - copied unchanged from r905688, subversion/trunk/subversion/bindings/javahl/native/org_tigris_subversion_javahl_Version.cpp
Removed:
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_NativeResources.cpp
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_Version.cpp
Modified:
    subversion/trunk/build.conf
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeResources.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeResources.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Version.java

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=905828&r1=905827&r2=905828&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Tue Feb  2 22:54:25 2010
@@ -59,7 +59,7 @@
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_NodeKind.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_NotifyAction.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_NotifyStatus.h
-        subversion/bindings/javahl/include/org_apache_subversion_javahl_NativeResources.h
+        subversion/bindings/javahl/include/org_tigris_subversion_javahl_NativeResources.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_Operation.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_Path.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_PromptUserPassword2.h
@@ -70,7 +70,7 @@
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_SVNClientLogLevel.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_ScheduleKind.h
         subversion/bindings/javahl/include/org_tigris_subversion_javahl_StatusKind.h
-        subversion/bindings/javahl/include/org_apache_subversion_javahl_Version.h
+        subversion/bindings/javahl/include/org_tigris_subversion_javahl_Version.h
 
 
 test-scripts =

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeResources.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeResources.java?rev=905828&r1=905827&r2=905828&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeResources.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeResources.java
Tue Feb  2 22:54:25 2010
@@ -27,7 +27,7 @@
  * Handles activities related to management of native resouces
  * (e.g. loading of native libraries).
  */
-public class NativeResources
+class NativeResources
 {
     /**
      * Version information about the underlying native libraries.

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeResources.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeResources.java?rev=905828&r1=905827&r2=905828&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeResources.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeResources.java
Tue Feb  2 22:54:25 2010
@@ -23,13 +23,110 @@
 
 package org.tigris.subversion.javahl;
 
-import org.apache.subversion.javahl.*;
-
 /**
  * Handles activities related to management of native resouces
  * (e.g. loading of native libraries).
  */
-class NativeResources extends org.apache.subversion.javahl.NativeResources
+class NativeResources
 {
-  static Version version = new Version();
+    /**
+     * Version information about the underlying native libraries.
+     */
+    static Version version;
+
+    /**
+     * Load the required native library whose path is specified by the
+     * system property <code>subversion.native.library</code> (which
+     * can be passed to the JVM on start-up using an argument like
+     * <code>-Dsubversion.native.library=/usr/local/lib/libsvnjavahl-1.so</code>).
+     * If the system property is not specified or cannot be loaded,
+     * attempt to load the library using its expected name, and the
+     * platform-dependent loading mechanism.
+     *
+     * @throws UnsatisfiedLinkError If the native library cannot be
+     * loaded.
+     * @throws LinkageError If the version of the loaded native
+     * library is not compatible with this version of JavaHL's Java
+     * APIs.
+     * @since 1.3.0
+     */
+    public static synchronized void loadNativeLibrary()
+    {
+        UnsatisfiedLinkError loadException = null;
+
+        // If the user specified the fully qualified path to the
+        // native library, try loading that first.
+        try
+        {
+            String specifiedLibraryName =
+                System.getProperty("subversion.native.library");
+            if (specifiedLibraryName != null)
+            {
+                System.load(specifiedLibraryName);
+                init();
+                return;
+            }
+        }
+        catch (UnsatisfiedLinkError ex)
+        {
+            // Since the user explicitly specified this path, this is
+            // the best error to return if no other method succeeds.
+            loadException = ex;
+        }
+
+        // Try to load the library by its name.  Failing that, try to
+        // load it by its old name.
+        String[] libraryNames = {"svnjavahl-1", "libsvnjavahl-1", "svnjavahl"};
+        for (int i = 0; i < libraryNames.length; i++)
+        {
+            try
+            {
+                System.loadLibrary(libraryNames[i]);
+                init();
+                return;
+            }
+            catch (UnsatisfiedLinkError ex)
+            {
+                if (loadException == null)
+                {
+                    loadException = ex;
+                }
+            }
+        }
+
+        // Re-throw the most relevant exception.
+        if (loadException == null)
+        {
+            // This could only happen as the result of a programming error.
+            loadException = new UnsatisfiedLinkError("Unable to load JavaHL " +
+                                                     "native library");
+        }
+        throw loadException;
+    }
+
+    /**
+     * Initializer for native resources to be invoked <em>after</em>
+     * the native library has been loaded.  Sets library version
+     * information, and initializes the re-entrance hack for native
+     * code.
+     * @throws LinkageError If the version of the loaded native
+     * library is not compatible with this version of JavaHL's Java
+     * APIs.
+     */
+    private static final void init()
+    {
+        initNativeLibrary();
+        version = new Version();
+        if (!version.isAtLeast(1, 5, 0))
+        {
+            throw new LinkageError("Native library version must be at least " +
+                                   "1.5.0, but is only " + version);
+        }
+    }
+
+    /**
+     * Initialize the native library layer.
+     * @since 1.5.0
+     */
+    private static native void initNativeLibrary();
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Version.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Version.java?rev=905828&r1=905827&r2=905828&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Version.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Version.java
Tue Feb  2 22:54:25 2010
@@ -23,8 +23,6 @@
 
 package org.tigris.subversion.javahl;
 
-import org.apache.subversion.javahl.*;
-
 /**
  * Encapsulates version information about the underlying native
  * libraries.  Basically a wrapper for <a
@@ -32,4 +30,68 @@
  */
 public class Version
 {
+    /**
+     * @return The full version string for the loaded JavaHL library,
+     * as defined by <code>MAJOR.MINOR.PATCH INFO</code>.
+     * @since 1.4.0
+     */
+    public String toString()
+    {
+        StringBuffer version = new StringBuffer();
+        version.append(getMajor())
+            .append('.').append(getMinor())
+            .append('.').append(getPatch())
+            .append(getNumberTag())
+            .append(getTag());
+        return version.toString();
+    }
+
+    /**
+     * @return The major version number for the loaded JavaHL library.
+     * @since 1.4.0
+     */
+    public native int getMajor();
+
+    /**
+     * @return The minor version number for the loaded JavaHL library.
+     * @since 1.4.0
+     */
+    public native int getMinor();
+
+    /**
+     * @return The patch-level version number for the loaded JavaHL
+     * library.
+     * @since 1.4.0
+     */
+    public native int getPatch();
+
+    /**
+     * @return Whether the JavaHL native library version is at least
+     * of <code>major.minor.patch</code> level.
+     * @since 1.5.0
+     */
+    public boolean isAtLeast(int major, int minor, int patch)
+    {
+        int actualMajor = getMajor();
+        int actualMinor = getMinor();
+        return ((major < actualMajor)
+                || (major == actualMajor && minor < actualMinor)
+                || (major == actualMajor && minor == actualMinor &&
+                    patch <= getPatch()));
+    }
+
+    /**
+     * @return Some text further describing the library version
+     * (e.g. <code>" (r1234)"</code>, <code>" (Alpha 1)"</code>,
+     * <code>" (dev build)"</code>, etc.).
+     * @since 1.4.0
+     */
+    private native String getTag();
+
+    /**
+     * @return Some text further describing the library version
+     * (e.g. "r1234", "Alpha 1", "dev build", etc.).
+     * @since 1.4.0
+     */
+    private native String getNumberTag();
 }



Mime
View raw message