當前位置: 首頁>>代碼示例>>Java>>正文


Java ScriptingContainer.parse方法代碼示例

本文整理匯總了Java中org.jruby.embed.ScriptingContainer.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java ScriptingContainer.parse方法的具體用法?Java ScriptingContainer.parse怎麽用?Java ScriptingContainer.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jruby.embed.ScriptingContainer的用法示例。


在下文中一共展示了ScriptingContainer.parse方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeJRubyRuntime

import org.jruby.embed.ScriptingContainer; //導入方法依賴的package包/類
private void initializeJRubyRuntime() {
    container = new ScriptingContainer(org.jruby.embed.LocalContextScope.SINGLETHREAD);

    if (jobConf != null) {
        container.getLoadPaths().add(jobConf.get(CONF_JRB_LOAD_PATH));
    }

    if (rbScriptParam.startsWith(MODE_METHOD_MARK)) {
        mode = MODE.METHOD;
        evaluateMethod = rbScriptParam.substring(1);
        container.setAttribute(AttributeName.SHARING_VARIABLES, false);
        receiver = container.runScriptlet(rbEnvScript);
    } else {
        mode = MODE.EVAL;
        evalUnit = container.parse(rbScriptParam);
    }

    LOG.info("initialized JRuby runtime (" +
            container.getCompatVersion() + ", " +
            container.getCompileMode()
            + ")");
}
 
開發者ID:gree,項目名稱:hive-ruby-scripting,代碼行數:23,代碼來源:GenericUDFRubyExec.java

示例2: setup

import org.jruby.embed.ScriptingContainer; //導入方法依賴的package包/類
@Override
public void setup(OperatorContext context)
{
  sc = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
  for (String s : setupScripts) {
    EvalUnit unit = sc.parse(s);
    unit.run();
  }
  if (type == Type.EVAL) {
    unit = sc.parse(script);
  }
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:13,代碼來源:RubyOperator.java

示例3: loadConfiguration

import org.jruby.embed.ScriptingContainer; //導入方法依賴的package包/類
/**
 * Load the Haml viewer configuration for the view.
 *
 * @param configuration The configuration object
 */
public void loadConfiguration(Configuration configuration)
        throws ConfigurationException {

    List<String> loadPaths = new ArrayList<String>();
    // SINGLETHREAD is not threadsafe: http://www.ruby-forum.com/topic/206056#new
    container = new ScriptingContainer(LocalContextScope.THREADSAFE);
    scriptingContainerConfiguration = configuration;

    RubyInstanceConfig config = container.getProvider().getRubyInstanceConfig();

    if (scriptingContainerConfiguration != null) {

        jrubyhome = scriptingContainerConfiguration.getChildValue("jruby_home");

        if (jrubyhome != null) {
            config.setJRubyHome(jrubyhome);
            loadPaths.add(jrubyhome);
        }

        String userHamlScript = scriptingContainerConfiguration.getChildValue("haml");
        if (userHamlScript != null) {
            haml_rb = userHamlScript; //just a bit of inversion of control
        }
    }

    haml_rb_unit = container.parse(haml_rb);

    log.info("haml enabled ... have fun!");
}
 
開發者ID:florinpatrascu,項目名稱:jpublish,代碼行數:35,代碼來源:HamlViewRenderer.java

示例4: getScript

import org.jruby.embed.ScriptingContainer; //導入方法依賴的package包/類
public JavaEmbedUtils.EvalUnit getScript() throws FileNotFoundException {
    if (this.unit == null) {
        if (!this.configFile.exists()) {
            throw new FileNotFoundException("Configuration file does not exist");
        }

        ScriptingContainer scriptingContainer = new ScriptingContainer(
                LocalContextScope.THREADSAFE,
                LocalVariableBehavior.PERSISTENT);

        scriptingContainer.setOutput(new PrintStream(new NullOutputStream()));

        StringBuilder script = new StringBuilder()
                .append("require 'compass'\n")
                .append("require 'compass/sass_compiler'\n")
                .append("Compass.reset_configuration!\n")
                .append("Compass.add_project_configuration configLocation\n")

                        // remove color codes since they cannot be proceeded correctly by IDE consoles
                .append("Compass.configuration.color_output = false\n")

                .append("Compass.configure_sass_plugin!\n")
                .append("Compass.configuration.on_stylesheet_saved { |filename| callback_logger.onStylesheetSaved(filename) }\n")
                .append("Compass.configuration.on_stylesheet_error { |filename, message| callback_logger.onStylesheetError(filename, message) }\n")
                .append("Compass.configuration.on_sprite_saved { |filename| callback_logger.onSpriteSaved(filename) }\n")
                .append("Dir.chdir(File.dirname(configLocation)) do\n")
                .append("  Compass.sass_compiler.compile!\n")
                .append("end\n");

        scriptingContainer.put("configLocation", this.configFile.getAbsolutePath().replaceAll("\\\\", "/"));
        scriptingContainer.put("callback_logger", callbackLogger);
        this.unit = scriptingContainer.parse(script.toString());
    }

    return this.unit;
}
 
開發者ID:ricardjp,項目名稱:jcompass,代碼行數:37,代碼來源:CompassCompiler.java


注:本文中的org.jruby.embed.ScriptingContainer.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。