com.kenai.jaffl.provider

Class NativeInvocationHandler

public class NativeInvocationHandler extends Object implements InvocationHandler

InvocationHandler used to map invocations on a java interface to the correct native function.
Constructor Summary
NativeInvocationHandler(Library library, Class<?> interfaceClass, Map<LibraryOption,?> optionsMap)
Creates a new InvocationHandler instance.
Method Summary
Objectinvoke(Object self, Method method, Object[] argArray)
static <T> TwrapInterface(Library library, Class<T> interfaceClass, Map<LibraryOption,?> optionsMap)
Creates a new InvocationHandler mapping methods in the interfaceClass to functions in the native library.

Constructor Detail

NativeInvocationHandler

public NativeInvocationHandler(Library library, Class<?> interfaceClass, 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

invoke

public Object invoke(Object self, Method method, Object[] argArray)

wrapInterface

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

Parameters: the type of interfaceClass 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.