FileDocCategorySizeDatePackage
JNI.javaAPI DocAndroid 1.5 API2141Wed May 06 22:41:10 BST 2009org.clearsilver

JNI

public class JNI extends Object
Loads the ClearSilver JNI library.

By default, it attempts to load the library 'clearsilver-jni' from the path specified in the 'java.library.path' system property.

If this fails, the JVM exits with a code of 1. However, this strategy can be changed using {@link #setFailureCallback(Runnable)}.

Fields Summary
public static Runnable
EXIT_JVM
Failure callback strategy that writes a message to sysout, then calls System.exit(1).
public static Runnable
THROW_ERROR
Failure callback strategy that throws an UnsatisfiedLinkError, which should be caught be client code.
private static Runnable
failureCallback
private static Object
callbackLock
private static String
libraryName
Constructors Summary
Methods Summary
public static voidloadLibrary()
Attempts to load the ClearSilver JNI library.

see
#setFailureCallback(Runnable)

        
              
      
    try {
      System.loadLibrary(libraryName);
    } catch (UnsatisfiedLinkError e) {
      synchronized (callbackLock) {
        if (failureCallback != null) {
          failureCallback.run();
        }
      }
    }    
  
public static voidsetFailureCallback(java.lang.Runnable failureCallback)
Sets a callback for what should happen if the JNI library cannot be loaded. The default is {@link #EXIT_JVM}.

see
#EXIT_JVM
see
#THROW_ERROR

    synchronized(callbackLock) {
      JNI.failureCallback = failureCallback;
    }
  
public static voidsetLibraryName(java.lang.String libraryName)
Set name of JNI library to load. Default is 'clearsilver-jni'.

    JNI.libraryName = libraryName;