Difference between revisions of "Dynamic Proxy"
From ADempiere
This Wiki is read-only for reference purposes to avoid broken links.
m |
(new category) |
||
Line 1: | Line 1: | ||
− | |||
== Example of Dynamic Proxy == | == Example of Dynamic Proxy == | ||
Line 27: | Line 26: | ||
</pre></code> | </pre></code> | ||
+ | |||
+ | |||
+ | [[Category:Code snippets]] |
Latest revision as of 07:19, 20 August 2010
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