Java method missing (ala Ruby) for decorating?

Posted by cibercitizen1 on Stack Overflow See other posts from Stack Overflow or by cibercitizen1
Published on 2010-03-29T21:56:40Z Indexed on 2010/03/29 22:03 UTC
Read the original article Hit count: 350

Filed under:
|

Is there any technique available in Java for intercepting messages (method calls) like the method_missing technique in Ruby? This would allow coding decorators and proxies very easily, like in Ruby:

:Client            p:Proxy                    im:Implementation
-------           ----------                  -----------------

p.foo() -------> method_missing()
                    do_something
                    im.foo() ------------------> do_foo


p.bar() --------> method_missing()
                   do_something_more
                    im.bar() -------------------> do_bar

(Note: Proxy only has one method: method_missing())

© Stack Overflow or respective owner

Related posts about java

Related posts about decorator