com.kenai.jaffl.provider
Class NativeInvocationHandler

java.lang.Object
  extended by com.kenai.jaffl.provider.NativeInvocationHandler
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class NativeInvocationHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

InvocationHandler used to map invocations on a java interface to the correct native function.


Constructor Summary
NativeInvocationHandler(Library library, java.lang.Class<?> interfaceClass, java.util.Map<LibraryOption,?> optionsMap)
          Creates a new InvocationHandler instance.
 
Method Summary
 java.lang.Object invoke(java.lang.Object self, java.lang.reflect.Method method, java.lang.Object[] argArray)
           
static
<T> T
wrapInterface(Library library, java.lang.Class<T> interfaceClass, java.util.Map<LibraryOption,?> optionsMap)
          Creates a new InvocationHandler mapping methods in the interfaceClass to functions in the native library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeInvocationHandler

public NativeInvocationHandler(Library library,
                               java.lang.Class<?> interfaceClass,
                               java.util.Map<LibraryOption,?> optionsMap)
Creates a new InvocationHandler instance.

Parameters:
library - the native library to call
interfaceClass - the interface that defines the methods in the native library that will be accessed via this handler.
optionsMap - a dictionary of options to apply to this library.
Method Detail

wrapInterface

public static <T> T wrapInterface(Library library,
                                  java.lang.Class<T> interfaceClass,
                                  java.util.Map<LibraryOption,?> optionsMap)
Creates a new InvocationHandler mapping methods in the interfaceClass to functions in the native library.

Type Parameters:
T - the type of interfaceClass
Parameters:
libraryName - the native library to load
interfaceClass - the interface that contains the native method description
optionsMap - a dictionary of options to apply to this library.
Returns:
a new instance of interfaceClass that can be used to call functions in the native library.

invoke

public java.lang.Object invoke(java.lang.Object self,
                               java.lang.reflect.Method method,
                               java.lang.Object[] argArray)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable