com.kenai.jaffl.provider
Class NativeInvocationHandler
java.lang.Object
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.
Method Summary |
java.lang.Object |
invoke(java.lang.Object self,
java.lang.reflect.Method method,
java.lang.Object[] argArray)
|
static
|
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 |
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 callinterfaceClass
- 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.
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 loadinterfaceClass
- the interface that contains the native method descriptionoptionsMap
- 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