Class InterfaceAdapter
java.lang.Object
org.mozilla.javascript.InterfaceAdapter
Adapter to use JS function as implementation of Java interfaces with
single method or multiple methods with the same signature.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Object
create
(Context cx, Class<?> cl, ScriptableObject object) Make glue object implementing interface cl that will call the supplied JS function when called.invoke
(ContextFactory cf, Object target, Scriptable topScope, Object thisObject, Method method, Object[] args) (package private) Object
invokeImpl
(Context cx, Object target, Scriptable topScope, Object thisObject, Method method, Object[] args) private static boolean
isFunctionalMethodCandidate
(Method method) We have to ignore java8 default methods and methods like 'equals', 'hashCode' and 'toString' as it occurs for example in the Comparator interface.
-
Field Details
-
proxyHelper
-
-
Constructor Details
-
InterfaceAdapter
-
-
Method Details
-
create
Make glue object implementing interface cl that will call the supplied JS function when called. Only interfaces were all methods have the same signature is supported.- Returns:
- The glue object or null if
cl
is not interface or has methods with different signatures.
-
isFunctionalMethodCandidate
We have to ignore java8 default methods and methods like 'equals', 'hashCode' and 'toString' as it occurs for example in the Comparator interface.- Returns:
- true, if the function
-
invoke
public Object invoke(ContextFactory cf, Object target, Scriptable topScope, Object thisObject, Method method, Object[] args) -
invokeImpl
-