本文整理了Java中com.eclipsesource.v8.V8.registerCallback()
方法的一些代码示例,展示了V8.registerCallback()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.registerCallback()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:registerCallback
暂无
代码示例来源:origin: eclipsesource/J2V8
/**
* Register a Java method reflectively given it's name a signature. The option to include
* the JS Object in the callback can be specified by setting includeReceiver true.
*
* @param object The Java Object on which the method is defined.
* @param methodName The name of the method to register.
* @param jsFunctionName The name of the JavaScript function to register the
* method with.
* @param parameterTypes The parameter types of the method.
* @param includeReceiver True if the first parameter should include the JS Object,
* false otherwise.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final Object object, final String methodName, final String jsFunctionName, final Class<?>[] parameterTypes, final boolean includeReceiver) {
v8.checkThread();
checkReleased();
try {
Method method = object.getClass().getMethod(methodName, parameterTypes);
method.setAccessible(true);
v8.registerCallback(object, method, getHandle(), jsFunctionName, includeReceiver);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (SecurityException e) {
throw new IllegalStateException(e);
}
return this;
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Register a Java method as a JavaScript function. When the JS Function is invoked
* the Java method will be called.
*
* @param callback The JavaCallback to call when the JSFunction is invoked.
* @param jsFunctionName The name of the JSFunction.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final JavaCallback callback, final String jsFunctionName) {
v8.checkThread();
checkReleased();
v8.registerCallback(callback, getHandle(), jsFunctionName);
return this;
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Register a Java method reflectively given it's name a signature. The option to include
* the JS Object in the callback can be specified by setting includeReceiver true.
*
* @param object The Java Object on which the method is defined.
* @param methodName The name of the method to register.
* @param jsFunctionName The name of the JavaScript function to register the
* method with.
* @param parameterTypes The parameter types of the method.
* @param includeReceiver True if the first parameter should include the JS Object,
* false otherwise.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final Object object, final String methodName, final String jsFunctionName, final Class<?>[] parameterTypes, final boolean includeReceiver) {
v8.checkThread();
checkReleased();
try {
Method method = object.getClass().getMethod(methodName, parameterTypes);
method.setAccessible(true);
v8.registerCallback(object, method, getHandle(), jsFunctionName, includeReceiver);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (SecurityException e) {
throw new IllegalStateException(e);
}
return this;
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Register a Java method as a JavaScript function. When the JS Function is invoked
* the Java method will be called.
*
* @param callback The JavaCallback to call when the JSFunction is invoked.
* @param jsFunctionName The name of the JSFunction.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final JavaCallback callback, final String jsFunctionName) {
v8.checkThread();
checkReleased();
v8.registerCallback(callback, getHandle(), jsFunctionName);
return this;
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_win32_x86_64
/**
* Register a Java method reflectively given it's name a signature. The option to include
* the JS Object in the callback can be specified by setting includeReceiver true.
*
* @param object The Java Object on which the method is defined.
* @param methodName The name of the method to register.
* @param jsFunctionName The name of the JavaScript function to register the
* method with.
* @param parameterTypes The parameter types of the method.
* @param includeReceiver True if the first parameter should include the JS Object,
* false otherwise.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final Object object, final String methodName, final String jsFunctionName, final Class<?>[] parameterTypes, final boolean includeReceiver) {
v8.checkThread();
checkReleased();
try {
Method method = object.getClass().getMethod(methodName, parameterTypes);
method.setAccessible(true);
v8.registerCallback(object, method, getHandle(), jsFunctionName, includeReceiver);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (SecurityException e) {
throw new IllegalStateException(e);
}
return this;
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_macosx_x86_64
/**
* Register a Java method reflectively given it's name a signature. The option to include
* the JS Object in the callback can be specified by setting includeReceiver true.
*
* @param object The Java Object on which the method is defined.
* @param methodName The name of the method to register.
* @param jsFunctionName The name of the JavaScript function to register the
* method with.
* @param parameterTypes The parameter types of the method.
* @param includeReceiver True if the first parameter should include the JS Object,
* false otherwise.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final Object object, final String methodName, final String jsFunctionName, final Class<?>[] parameterTypes, final boolean includeReceiver) {
v8.checkThread();
checkReleased();
try {
Method method = object.getClass().getMethod(methodName, parameterTypes);
method.setAccessible(true);
v8.registerCallback(object, method, getHandle(), jsFunctionName, includeReceiver);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (SecurityException e) {
throw new IllegalStateException(e);
}
return this;
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_macosx_x86_64
/**
* Register a Java method as a JavaScript function. When the JS Function is invoked
* the Java method will be called.
*
* @param callback The JavaCallback to call when the JSFunction is invoked.
* @param jsFunctionName The name of the JSFunction.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final JavaCallback callback, final String jsFunctionName) {
v8.checkThread();
checkReleased();
v8.registerCallback(callback, getHandle(), jsFunctionName);
return this;
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_win32_x86_64
/**
* Register a Java method as a JavaScript function. When the JS Function is invoked
* the Java method will be called.
*
* @param callback The JavaCallback to call when the JSFunction is invoked.
* @param jsFunctionName The name of the JSFunction.
*
* @return The receiver.
*/
public V8Object registerJavaMethod(final JavaCallback callback, final String jsFunctionName) {
v8.checkThread();
checkReleased();
v8.registerCallback(callback, getHandle(), jsFunctionName);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!