KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > proxysample > InvocationHandlerSample


1 /*
2  * Copyright 2003 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.cglib.proxysample;
17
18 import java.lang.reflect.Method JavaDoc;
19
20 import net.sf.cglib.proxy.InvocationHandler;
21
22 /**
23  * @author neeme
24  *
25  */

26 public class InvocationHandlerSample implements InvocationHandler {
27
28     private Object JavaDoc o;
29
30     /**
31      * Constructor for InvocationHandlerSample.
32      */

33     public InvocationHandlerSample(Object JavaDoc o) {
34         this.o = o;
35     }
36
37     public Object JavaDoc invoke(Object JavaDoc proxy, Method JavaDoc method, Object JavaDoc[] args)
38         throws Throwable JavaDoc {
39         System.out.println("invoke() start");
40         System.out.println(" method: " + method.getName());
41         if (args != null) {
42             for (int i = 0; i < args.length; i++) {
43                 System.out.println(" arg: " + args[i]);
44             }
45         }
46         Object JavaDoc r = method.invoke(o, args);
47         System.out.println(" return: " + r);
48         System.out.println("invoke() end");
49         return r;
50     }
51
52 }
53
Popular Tags