Create a reflective proxy from one class to an interface with matching
method names (but not necessarily an "instanceof").
For example, this utility method can be used to wrap class:
public class Impl {
public void foo() { .. }
}
as interface:
public interface Service {
void foo();
}
using:
Impl x = new Impl();
Service s = (Service) Reflection.makeProxy(x, Service.class);
even though "x instanceof Service" is false. The only requirement is that
Impl have all the methods defined in Service.
We primarily use this technique to avoid compile and classloader problems
when importing/exporting services from/to an external Node container.
|