From 768b593abddd55217d5ed4259bc1c23c486482b2 Mon Sep 17 00:00:00 2001 From: chiba Date: Tue, 7 Nov 2006 08:44:07 +0000 Subject: [PATCH] updated a javadoc comment git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@331 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- .../javassist/util/proxy/ProxyFactory.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index 252dda3d..73c1060b 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -58,7 +58,6 @@ import javassist.bytecode.*; * return proceed.invoke(self, args); // execute the original method. * } * }; - * f.setHandler(mi); * f.setFilter(new MethodFilter() { * public boolean isHandled(Method m) { * // ignore finalize() @@ -67,6 +66,7 @@ import javassist.bytecode.*; * }); * Class c = f.createClass(); * Foo foo = (Foo)c.newInstance(); + * ((ProxyObject)foo).setHandler(mi); * * *

Then, the following method call will be forwarded to MethodHandler @@ -77,6 +77,15 @@ import javassist.bytecode.*; * foo.bar(); * * + *

The last three lines of the code shown above can be replaced with a call to + * the helper method create, which generates a proxy class, instantiates + * it, and sets the method handler of the instance: + * + *

+ * *

To change the method handler during runtime, * execute the following code: * @@ -85,7 +94,20 @@ import javassist.bytecode.*; * ((ProxyObject)foo).setHandler(mi2); * * - *

Here is an example of method handler. It does not execute + *

You can also specify the default method handler: + * + *

+ * + *

The default handler is implicitly attached to an instance of the generated class + * c2. Calling setHandler on the instance is not necessary + * unless another method handler must be attached to the instance. + * + *

The following code is an example of method handler. It does not execute * anything except invoking the original method: * *