org.qi4j.scripting.jruby
Class JRubyMixin

java.lang.Object
  extended by org.qi4j.scripting.jruby.JRubyMixin
All Implemented Interfaces:
InvocationHandler, ScriptReloadable

@AppliesTo(value=JRubyMixin.AppliesTo.class)
public class JRubyMixin
extends Object
implements InvocationHandler, ScriptReloadable

Generic mixin that implements interfaces by delegating to Ruby functions using JRuby. Each method in an interface is declared by a Ruby method in a file located in classpath with the name ".rb", where the interface name includes the package, and has "." replaced with "/".

Example: org/qi4j/samples/hello/domain/HelloWorldSpeaker.rb


Nested Class Summary
static class JRubyMixin.AppliesTo
           
 
Constructor Summary
JRubyMixin()
           
 
Method Summary
protected  String getFunction(Method aMethod)
           
protected static URL getFunctionResoure(Method method)
           
 Object invoke(Object proxy, Method method, Object[] args)
           
 void reloadScripts()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRubyMixin

public JRubyMixin()
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

reloadScripts

public void reloadScripts()
Specified by:
reloadScripts in interface ScriptReloadable

getFunction

protected String getFunction(Method aMethod)
                      throws IOException
Throws:
IOException

getFunctionResoure

protected static URL getFunctionResoure(Method method)