org.jruby.javasupport
Class RubyInvocationHandler

java.lang.Object
  extended byorg.jruby.javasupport.RubyInvocationHandler
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class RubyInvocationHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

A RubyInvocationHandler intercepts method calls to Proxy objects and forwards them on to the corresponding RubyObject. Arguments passed to and sent from the method are translated between Java and Ruby objects. A new RubyInvocationHandler instance is created for each Proxy object created by RubyProxyFactory.


Method Summary
protected  Ruby getRuby()
          Get the Ruby instance that should be used.
protected  IRubyObject getRubyObject()
          Get the RubyObject that we should forward method calls to.
protected  RubyProxyFactory getRubyProxyFactory()
          Get the RubyProxyFactory instance that created this handler.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          The invoke method is called by Java's reflection whenever a method is called on a Proxy object.
protected  boolean respondsTo(IRubyObject obj, java.lang.String methodName)
          Simple helper method for RubyObject.respond_to(RubySymbol).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
The invoke method is called by Java's reflection whenever a method is called on a Proxy object. This handler will forward the method call on to the corresponding RubyObject, converting arguments passed to and returned from the method, and will return the end result.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler

getRuby

protected Ruby getRuby()
Get the Ruby instance that should be used.


getRubyProxyFactory

protected RubyProxyFactory getRubyProxyFactory()
Get the RubyProxyFactory instance that created this handler.


getRubyObject

protected IRubyObject getRubyObject()
Get the RubyObject that we should forward method calls to.


respondsTo

protected boolean respondsTo(IRubyObject obj,
                             java.lang.String methodName)
Simple helper method for RubyObject.respond_to(RubySymbol).



Copyright © 2002 Jan Arne Petersen. All Rights Reserved.