当前位置: 首页>>代码示例>>Java>>正文


Java V8类代码示例

本文整理汇总了Java中com.eclipsesource.v8.V8的典型用法代码示例。如果您正苦于以下问题:Java V8类的具体用法?Java V8怎么用?Java V8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


V8类属于com.eclipsesource.v8包,在下文中一共展示了V8类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eval

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Override
public Object eval(final String script, final ScriptContext context) throws ScriptException {
    try {
        final Object[] result = new Object[1];
        concurrentV8.run(new ConcurrentV8Runnable() {
            @Override
            public void run(V8 v8) {

                // TODO: Incorporate usage of the ScriptContext.
                result[0] = v8.executeScript(script);
            }
        });
        return result[0];
    } catch (Exception e) {

        // TODO: Add checking to throw a NoSuchMethodException.
        throw new ScriptException(e);
    }
}
 
开发者ID:alicorn-systems,项目名称:v8-adapter,代码行数:20,代码来源:V8ScriptingEngine.java

示例2: run

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Override
public void run() {
    long start = System.currentTimeMillis();

    V8 runtime = V8.createV8Runtime();
    runtime.registerJavaMethod(new JavaVoidCallback() {
        public void invoke(final V8Object receiver, final V8Array parameters) {

            if (parameters.length() > 0) {
                jcdemoString(parameters);
            }

        }
    }, "call");
    runtime.add("screenWidth", JustConfig.screenWidth);
    runtime.add("screenHeight", JustConfig.screenHeight - JustConfig.navbarheight - JustConfig.statusbarheight);
    runtime.executeScript(js);

    long end = System.currentTimeMillis();
    time = end - start;
    handler.sendEmptyMessage(0);
}
 
开发者ID:LiuHongtao,项目名称:JustDraw,代码行数:23,代码来源:JCDemoActivity.java

示例3: start

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public void start(V8Object worker, String... s) {
	String script = (String) s[0];
	V8Executor executor = new V8Executor(script, true, "messageHandler") {
		@Override
		protected void setup(V8 runtime) {
			configureWorker(runtime);
		}
	};
	worker.getRutime().registerV8Executor(worker, executor);
	executor.start();
}
 
开发者ID:irbull,项目名称:j2v8_examples,代码行数:12,代码来源:WebWorker.java

示例4: invokeFunction

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Override
public Object invokeFunction(final String name, final Object... args) throws ScriptException, NoSuchMethodException {
    try {
        final Object[] result = new Object[1];
        concurrentV8.run(new ConcurrentV8Runnable() {
            @Override
            public void run(V8 v8) {
                result[0] = v8.executeJSFunction(name, V8JavaObjectUtils.translateJavaArgumentsToJavascript(args, v8, V8JavaAdapter.getCacheForRuntime(v8)));
            }
        });
        return result[0];
    } catch (Exception e) {

        // TODO: Add checking to throw a NoSuchMethodException.
        throw new ScriptException(e);
    }
}
 
开发者ID:alicorn-systems,项目名称:v8-adapter,代码行数:18,代码来源:V8ScriptingEngine.java

示例5: run

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Override
public void run() {
    long start = System.currentTimeMillis();

    V8 v8Runtime = JustJsCore.getRuntime();
    mJustWindow = new JustWindow(v8Runtime, mViewGroup);
    v8Runtime.add("window", mJustWindow.getV8Object());

    JustJsCore.run(js);

    mJustWindow.drawWindow();

    JustJsCore.clean(mJustWindow);

    long end = System.currentTimeMillis();
    time = end - start;
    handler.sendEmptyMessage(0);
}
 
开发者ID:LiuHongtao,项目名称:JustDraw,代码行数:19,代码来源:V8Activity.java

示例6: getRuntime

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public static V8 getRuntime() {
    mRuntime = V8.createV8Runtime();
    mRuntime.registerJavaMethod(new JavaVoidCallback() {
        public void invoke(final V8Object receiver, final V8Array parameters) {
            if (parameters.length() > 0) {
                Object msg = parameters.get(0);
                Log.d(LOG_TAG, msg.toString());
                if (msg instanceof Releasable) {
                    ((Releasable) msg).release();
                }
            }
        }
    }, "log");
    mRuntime.add("screenWidth", JustConfig.screenWidth);
    mRuntime.add("screenHeight", JustConfig.screenHeight - JustConfig.navbarheight - JustConfig.statusbarheight);
    return mRuntime;
}
 
开发者ID:LiuHongtao,项目名称:JustDraw,代码行数:18,代码来源:JustJsCore.java

示例7: DetermineBasalAdapterJS

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public DetermineBasalAdapterJS(ScriptReader scriptReader, Profile profile) throws IOException {
    Log.d(TAG, "START");
    mV8rt = V8.createV8Runtime();
    mScriptReader  = scriptReader;
    realmManager = new RealmManager();

    initProfile(profile);
    initMealData();
    initGlucoseStatus();
    initIobData(profile);
    initCurrentTemp();

    initLogCallback();

    initProcessExitCallback();

    initModuleParent();

    loadScript();

    realmManager.closeRealm();
    Log.d(TAG, "DetermineBasalAdapterJS: FINISH");
}
 
开发者ID:timomer,项目名称:HAPP,代码行数:24,代码来源:DetermineBasalAdapterJS.java

示例8: DetermineBasalAdapterJS

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public DetermineBasalAdapterJS(ScriptReader scriptReader, Profile profile) throws IOException {
    Log.d(TAG, "START");
    mV8rt = V8.createV8Runtime();
    mScriptReader  = scriptReader;
    realmManager = new RealmManager();

    Date dateVar = new Date();

    initProfile(profile);
    initGlucoseStatus();
    initIobData(profile);
    initCurrentTemp();

    initLogCallback();

    initProcessExitCallback();

    initModuleParent();

    loadScript();
    realmManager.closeRealm();
    Log.d(TAG, "DetermineBasalAdapterJS: FINISH");
}
 
开发者ID:timomer,项目名称:HAPP,代码行数:24,代码来源:DetermineBasalAdapterJS.java

示例9: exec

import com.eclipsesource.v8.V8; //导入依赖的package包/类
/**
 * Unpack and execute a nodejs library. Once unpack this method will execute one of these scripts
 * in the following order: 1) [library].js; 2) main.js; 3) index.js.
 *
 * The first file found will be executed.
 *
 * @param library Library to unpack and execute this library.
 * @throws Throwable If something goes wrong.
 */
public void exec(final String library, final Throwing.Consumer<V8> callback) throws Throwable {
  Path basedir = deploy(library);
  List<String> candidates = Arrays.asList(
      basedir.getFileName().toString() + ".js",
      "main.js",
      "index.js");

  Path main = candidates.stream()
      .map(it -> basedir.resolve(it))
      .filter(it -> it.toFile().exists())
      .findFirst()
      .orElseThrow(() -> new FileNotFoundException(candidates.toString()));

  callback.accept(node.getRuntime());

  node.exec(main.toFile());

  while (node.isRunning()) {
    node.handleMessage();
  }
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:31,代码来源:Nodejs.java

示例10: getInvocable

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Nullable
public V8 getInvocable() {
  if (Strings.isNullOrEmpty(gcsJSPath())) {
    return null;
  }

  if (mRuntime == null) {
    V8 runtime = V8.createV8Runtime();
    for (String script : getScripts()) {
      runtime.executeScript(script);
    }
    mRuntime = runtime;
  }
  return mRuntime;
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:16,代码来源:JSTransform.java

示例11: shouldNotGeneratePropertiesForGettersAndSettersWithoutAnnotations

import com.eclipsesource.v8.V8; //导入依赖的package包/类
@Test
public void shouldNotGeneratePropertiesForGettersAndSettersWithoutAnnotations() {
    final String readBooleanGetterScript = "x.fullySetUp;";
    V8JavaAdapter.injectClass(WannabeBeanNoAnnotations.class, v8);

    Assert.assertNotEquals(3344, v8.executeIntegerScript("var x = new WannabeBeanNoAnnotations(); x.i = 6688; x.i;"));
    Assert.assertEquals(V8.getUndefined(), v8.executeScript(readBooleanGetterScript));

    Assert.assertNotEquals(6688, v8.executeIntegerScript("x.j = 3344; x.j;"));
    Assert.assertEquals(V8.getUndefined(), v8.executeScript(readBooleanGetterScript));
}
 
开发者ID:alicorn-systems,项目名称:v8-adapter,代码行数:12,代码来源:V8JavaAdapterTest.java

示例12: V8VizJS

import com.eclipsesource.v8.V8; //导入依赖的package包/类
/**
 * creates and initializes V8 engine with viz.js
 * 
 * @throws IOException
 */
public V8VizJS() throws IOException {
	runtime = V8.createV8Runtime();
	runtime.executeVoidScript(JSPRINTFUNCTION);
	messages = runtime.getArray(JSMESSAGESARRAY);
	runtime.executeVoidScript(getVizCode());
	vizFunction = (V8Function) runtime.getObject("Viz");
}
 
开发者ID:plantuml,项目名称:vizjs,代码行数:13,代码来源:V8VizJS.java

示例13: JustContext

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public JustContext(V8 v8Runtime) {
    super(v8Runtime);

    mPaintFill.setStyle(Paint.Style.FILL);
    mPaintStroke.setStyle(Paint.Style.STROKE);
    mPaintFill.setFlags(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setFlags(Paint.ANTI_ALIAS_FLAG);
}
 
开发者ID:LiuHongtao,项目名称:JustDraw,代码行数:9,代码来源:JustContext.java

示例14: JustCanvas

import com.eclipsesource.v8.V8; //导入依赖的package包/类
public JustCanvas(V8 v8Runtime, Context context) {
    super(v8Runtime);
    mJustView = new JustView(context);

    mJustContext = new JustContext(v8Runtime);
    mObject.add("context", mJustContext.getObject());
}
 
开发者ID:LiuHongtao,项目名称:JustDraw,代码行数:8,代码来源:JustCanvas.java

示例15: configureWorker

import com.eclipsesource.v8.V8; //导入依赖的package包/类
private void configureWorker(V8 runtime) {
	runtime.registerJavaMethod(this, "start", "Worker", new Class<?>[] { V8Object.class, String[].class }, true);
	V8Object worker = runtime.getObject("Worker");
	V8Object prototype = runtime.executeObjectScript("Worker.prototype");
	prototype.registerJavaMethod(this, "terminate", "terminate", new Class<?>[] { V8Object.class, Object[].class },
			true);
	prototype.registerJavaMethod(this, "postMessage", "postMessage",
			new Class<?>[] { V8Object.class, String[].class }, true);
	runtime.registerJavaMethod(WebWorker.this, "print", "print", new Class<?>[] { String.class });
	worker.setPrototype(prototype);
	worker.release();
	prototype.release();
}
 
开发者ID:irbull,项目名称:j2v8_examples,代码行数:14,代码来源:WebWorker.java


注:本文中的com.eclipsesource.v8.V8类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。