TorqueBox 3.1.2

org.torquebox.core.util
Class RuntimeHelper

java.lang.Object
  extended by org.torquebox.core.util.RuntimeHelper

public class RuntimeHelper
extends Object

Ruby reflection helper utilities.

Author:
Bob McWhirter

Constructor Summary
RuntimeHelper()
           
 
Method Summary
static Object call(org.jruby.Ruby ruby, Object target, String name, Object[] parameters)
           
static Object callIfPossible(org.jruby.Ruby ruby, Object target, String name, Object[] parameters)
           
static org.jruby.RubyHash convertJavaMapToRubyHash(org.jruby.Ruby runtime, Map map)
           
static org.jruby.RubyThread currentThread(org.jruby.Ruby ruby)
           
static boolean defined(org.jruby.Ruby ruby, Object target, String name)
           
static org.jruby.runtime.builtin.IRubyObject evalScriptlet(org.jruby.Ruby ruby, String script)
           
static org.jruby.runtime.builtin.IRubyObject evalScriptlet(org.jruby.Ruby ruby, String script, boolean logErrors)
           
static org.jruby.runtime.builtin.IRubyObject executeScript(org.jruby.Ruby ruby, String script, String location)
           
static Object getIfPossible(org.jruby.Ruby ruby, Object target, String name)
           
static org.jruby.runtime.builtin.IRubyObject instantiate(org.jruby.Ruby ruby, String className)
           
static org.jruby.runtime.builtin.IRubyObject instantiate(org.jruby.Ruby ruby, String className, Object[] parameters)
           
static Object invokeClassMethod(org.jruby.Ruby ruby, String className, String name, Object[] parameters)
           
static void require(org.jruby.Ruby ruby, String requirement)
           
static boolean requireIfAvailable(org.jruby.Ruby ruby, String requirement)
           
static boolean requireIfAvailable(org.jruby.Ruby ruby, String requirement, boolean logErrors)
          Calls "require 'requirement'" in the Ruby provided.
static void requireTorqueBoxInit(org.jruby.Ruby ruby)
          Looks in application ROOT/config and application ROOT for configurationFile and requires it if possible.
static void requireUnlessDefined(org.jruby.Ruby ruby, String requirement, String constant)
           
static boolean setIfPossible(org.jruby.Ruby ruby, Object target, String name, Object value)
          Set a property on a Ruby object, if possible.
protected static
<R> R
withinContext(org.jruby.Ruby ruby, Callable<R> block)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeHelper

public RuntimeHelper()
Method Detail

setIfPossible

public static boolean setIfPossible(org.jruby.Ruby ruby,
                                    Object target,
                                    String name,
                                    Object value)
Set a property on a Ruby object, if possible.

If the target responds to name=, the property will be set. Otherwise, not.

Parameters:
ruby - The Ruby interpreter.
target - The target object.
name - The basic name of the property.
value - The value to attempt to set.
Returns:
true if successful, otherwise false

getIfPossible

public static Object getIfPossible(org.jruby.Ruby ruby,
                                   Object target,
                                   String name)

call

public static Object call(org.jruby.Ruby ruby,
                          Object target,
                          String name,
                          Object[] parameters)

callIfPossible

public static Object callIfPossible(org.jruby.Ruby ruby,
                                    Object target,
                                    String name,
                                    Object[] parameters)

defined

public static boolean defined(org.jruby.Ruby ruby,
                              Object target,
                              String name)

invokeClassMethod

public static Object invokeClassMethod(org.jruby.Ruby ruby,
                                       String className,
                                       String name,
                                       Object[] parameters)

require

public static void require(org.jruby.Ruby ruby,
                           String requirement)

requireTorqueBoxInit

public static void requireTorqueBoxInit(org.jruby.Ruby ruby)
Looks in application ROOT/config and application ROOT for configurationFile and requires it if possible.


requireIfAvailable

public static boolean requireIfAvailable(org.jruby.Ruby ruby,
                                         String requirement)

requireIfAvailable

public static boolean requireIfAvailable(org.jruby.Ruby ruby,
                                         String requirement,
                                         boolean logErrors)
Calls "require 'requirement'" in the Ruby provided.


requireUnlessDefined

public static void requireUnlessDefined(org.jruby.Ruby ruby,
                                        String requirement,
                                        String constant)

evalScriptlet

public static org.jruby.runtime.builtin.IRubyObject evalScriptlet(org.jruby.Ruby ruby,
                                                                  String script)

evalScriptlet

public static org.jruby.runtime.builtin.IRubyObject evalScriptlet(org.jruby.Ruby ruby,
                                                                  String script,
                                                                  boolean logErrors)

executeScript

public static org.jruby.runtime.builtin.IRubyObject executeScript(org.jruby.Ruby ruby,
                                                                  String script,
                                                                  String location)

instantiate

public static org.jruby.runtime.builtin.IRubyObject instantiate(org.jruby.Ruby ruby,
                                                                String className)

instantiate

public static org.jruby.runtime.builtin.IRubyObject instantiate(org.jruby.Ruby ruby,
                                                                String className,
                                                                Object[] parameters)

currentThread

public static org.jruby.RubyThread currentThread(org.jruby.Ruby ruby)

convertJavaMapToRubyHash

public static org.jruby.RubyHash convertJavaMapToRubyHash(org.jruby.Ruby runtime,
                                                          Map map)

withinContext

protected static <R> R withinContext(org.jruby.Ruby ruby,
                                     Callable<R> block)

TorqueBox 3.1.2

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.