title: Dynamic implementation for interface/abstract class in Java
body: <p>What's the de-facto solution for building dynamic implementation of interfaces and/or abstract classes? What I basically want is:</p>
  
  <pre><code>interface IMyEntity {
    int getValue1();
    void setValue1(int x);
  }
  ...
  class MyEntityDispatcher implements WhateverDispatcher {
    public Object handleCall(String methodName, Object[] args) {
       if(methodName.equals("getValue1")) {
         return new Integer(123);
       } else if(methodName.equals("setValue")) {
         ...
       }
       ...
    }
  }
  ...
  IMyEntity entity = Whatever.Implement&lt;IMyEntity&gt;(new MyEntityDispatcher());
  entity.getValue1(); // returns 123
  </code></pre>