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


Java JavaEmbedUtils.initialize方法代码示例

本文整理汇总了Java中org.jruby.javasupport.JavaEmbedUtils.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java JavaEmbedUtils.initialize方法的具体用法?Java JavaEmbedUtils.initialize怎么用?Java JavaEmbedUtils.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.javasupport.JavaEmbedUtils的用法示例。


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

示例1: getInitRuby

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
protected Callable<Ruby> getInitRuby(final Writer out, final Writer err) {
    return new Callable<Ruby>() {
        @Override public Ruby call() throws Exception {
            RubyInstanceConfig config = new RubyInstanceConfig();
            config.setCompileMode(CompileMode.OFF);
            List<String> loadPaths = new ArrayList<String>();
            setModule(loadPaths);
            String appRubyPath = System.getProperty(PROP_APPLICATION_RUBYPATH);
            if (appRubyPath != null) {
                StringTokenizer tok = new StringTokenizer(appRubyPath, ";");
                while (tok.hasMoreTokens()) {
                    loadPaths.add(tok.nextToken().replace('/', File.separatorChar));
                }
            }
            config.setOutput(new PrintStream(new WriterOutputStream(out)));
            config.setError(new PrintStream(new WriterOutputStream(err)));
            Ruby interpreter = JavaEmbedUtils.initialize(loadPaths, config);
            interpreter.evalScriptlet("require 'selenium/webdriver'");
            interpreter.evalScriptlet("require 'marathon/results'");
            interpreter.evalScriptlet("require 'marathon/playback-" + framework + "'");
            return interpreter;
        }
    };
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:RubyScript.java

示例2: evaluate

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
public Object evaluate(final String expression, final Map<String, ?> values) throws ExpressionEvaluationException {
    LOG.debug("Evaluating JRuby expression: {1}", expression);
    try {
        final RubyInstanceConfig config = new RubyInstanceConfig();
        config.setCompatVersion(CompatVersion.RUBY1_9);
        final Ruby runtime = JavaEmbedUtils.initialize(new ArrayList<String>(), config);

        final StringBuilder localVars = new StringBuilder();
        for (final Entry<String, ?> entry : values.entrySet()) {
            runtime.getGlobalVariables().set("$" + entry.getKey(), JavaEmbedUtils.javaToRuby(runtime, entry.getValue()));
            localVars.append(entry.getKey()) //
                .append("=$") //
                .append(entry.getKey()) //
                .append("\n");
        }
        final IRubyObject result = runtime.evalScriptlet(localVars + expression);
        return JavaEmbedUtils.rubyToJava(runtime, result, Object.class);
    } catch (final RuntimeException ex) {
        throw new ExpressionEvaluationException("Evaluating JRuby expression failed: " + expression, ex);
    }
}
 
开发者ID:sebthom,项目名称:oval,代码行数:22,代码来源:ExpressionLanguageJRubyImpl.java

示例3: asciidoctor

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
@Bean
public Asciidoctor asciidoctor() {
    RubyInstanceConfig rubyInstanceConfig = new RubyInstanceConfig();
    rubyInstanceConfig.setLoader(this.getClass().getClassLoader());
    JavaEmbedUtils.initialize(Arrays.asList("META-INF/jruby.home/lib/ruby/2.0", "classpath:/gems/asciidoctor-1.5.4/lib"), rubyInstanceConfig);
    return create(this.getClass().getClassLoader());
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:8,代码来源:DocumentController.java

示例4: doCompile

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
public JRubyCompiledScript doCompile(Script script) throws ScriptCompilationException {
    Ruby runtime = JavaEmbedUtils.initialize(new ArrayList());
    IRubyObject rubyScript = JavaEmbedUtils.javaToRuby(runtime, script.getScriptAsString());
    try {
        Node node = runtime.parse(rubyScript.asSymbol(), "<unknown>", null, 0);
        return new JRubyCompiledScript(runtime, node);
    } catch (Exception e) {
        throw new ScriptExecutionException("Failed to execute script [" + script.getName() + "]", e);
    }
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:11,代码来源:JRubyLocalScriptExecutor.java

示例5: RSpecTestRunner

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
public RSpecTestRunner(Class<?> testClass) throws InitializationError {
    super(testClass);

    rubyConfig = new RubyInstanceConfig();
    Map<String, String> environment = new HashMap<>(System.getenv());
    environment.put("GEM_HOME", GEM_HOME.toString());
    environment.put("GEM_PATH", GEM_HOME.toString());
    rubyConfig.setEnvironment(environment);

    runtime = JavaEmbedUtils.initialize(singletonList("src/test/ruby"), rubyConfig);
    invokeFunction(null, "require", "test_runner");
}
 
开发者ID:haplo-org,项目名称:haplo-safe-view-templates,代码行数:13,代码来源:RSpecTestRunner.java

示例6: initializeRuntime

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
/**
 * Initializes an instance of the {@link org.jruby.Ruby} runtime.
 */
private static Ruby initializeRuntime() {
	return JavaEmbedUtils.initialize(Collections.EMPTY_LIST);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:JRubyScriptUtils.java

示例7: initializeRuntime

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
/**
 * Initializes an instance of the {@link org.jruby.Ruby} runtime.
 */
@SuppressWarnings("unchecked")
private static Ruby initializeRuntime() {
	return JavaEmbedUtils.initialize(Collections.EMPTY_LIST);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:JRubyScriptUtils.java

示例8: createJRubyAsciidoctorInstance

import org.jruby.javasupport.JavaEmbedUtils; //导入方法依赖的package包/类
private static Asciidoctor createJRubyAsciidoctorInstance(Map<String, Object> environmentVars) {

        RubyInstanceConfig config = createOptimizedConfiguration();
        injectEnvironmentVariables(config, environmentVars);

        Ruby rubyRuntime = JavaEmbedUtils.initialize(Collections.EMPTY_LIST, config);

        JRubyRuntimeContext.set(rubyRuntime);

        JRubyAsciidoctorModuleFactory jRubyAsciidoctorModuleFactory = new JRubyAsciidoctorModuleFactory(rubyRuntime);

        AsciidoctorModule asciidoctorModule = jRubyAsciidoctorModuleFactory.createAsciidoctorModule();

        JRubyAsciidoctor jRubyAsciidoctor = new JRubyAsciidoctor(asciidoctorModule, rubyRuntime);
        return jRubyAsciidoctor;
    }
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:17,代码来源:JRubyAsciidoctor.java


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