All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.east301.keyring.osx.NativeLibraryManager Maven / Gradle / Ivy

The newest version!
/**
 * @author  $Author: east301 $
 * @date    $Date: 2012/10/21 11:18:21 $
 * @version $Revision: fb93b8608b64 $
 */

package net.east301.keyring.osx;

import com.sun.jna.Native;
import net.east301.keyring.BackendNotSupportedException;

/**
 * Global native library manager
 */
class NativeLibraryManager {

    public static synchronized void loadNativeLibraries() throws BackendNotSupportedException {
        if (CoreFoundation != null && Security != null) { return; }

        try {
            CoreFoundation = (CoreFoundationLibrary)Native.loadLibrary(
                    "CoreFoundation", CoreFoundationLibrary.class);
            Security = (SecurityLibrary)Native.loadLibrary(
                    "Security", SecurityLibrary.class);
        } catch (UnsatisfiedLinkError ex) {
            throw new BackendNotSupportedException("Failed to load native library");
        }
    }

    /**
     * An instance of CoreFoundationLibrary
     */
    public static CoreFoundationLibrary CoreFoundation = null;

    /**
     * An instance of SecurityLibrary
     */
    public static SecurityLibrary Security = null;

} // class NativeLibraryManager




© 2015 - 2024 Weber Informatics LLC | Privacy Policy