Dynamic Proxy

From ADempiere
Revision as of 10:58, 21 May 2007 by Trifonnt (Talk)

Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Example of Dynamic Proxy

public TestInterface { public void print(String value); } public TestProxy extends InvocationHandler { public Object invoke (Object proxy, Method method, Object[] args) { if (method.getName().equals("print")) { System.out.println(args[0]); return null; } return null; } } TestInterface instance = Proxy.newProxyInstance( TestInterface.class.getClassLoader(), new Class[] {TestInterface.class}, new TestProxy()); Instance.print("Hello World!"); // prints "Hello World!" //to stdout