KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > cglib > MyProxy


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.cglib;
7
8
9 import org.logicalcobwebs.cglib.proxy.MethodInterceptor;
10 import org.logicalcobwebs.cglib.proxy.MethodProxy;
11
12 import java.lang.reflect.Method JavaDoc;
13
14 /**
15  * See {@link EnhancerTest}
16  * @version $Revision: 1.1 $, $Date: 2004/06/02 20:54:57 $
17  * @author billhorsman
18  * @author $Author: billhorsman $ (current maintainer)
19  */

20 public class MyProxy implements MethodInterceptor {
21
22     private MyConcreteClass myConcreteClass;
23
24     public MyProxy(MyConcreteClass myConcreteClass) {
25         this.myConcreteClass = myConcreteClass;
26     }
27
28     public Object JavaDoc intercept(Object JavaDoc obj, Method JavaDoc method, Object JavaDoc[] args, MethodProxy proxy) throws Throwable JavaDoc {
29         if (method.getName().equals("foo")) {
30             return "proxiedFoo";
31         } else {
32             return method.invoke(myConcreteClass, args);
33         }
34     }
35
36 }
37 /*
38  Revision history:
39  $Log: MyProxy.java,v $
40  Revision 1.1 2004/06/02 20:54:57 billhorsman
41  Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge.
42
43 */
Popular Tags