KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > lifecycle > MethodProcedure


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solution. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 /*
10  * Created on Oct 13, 2005
11  *
12  * Author Michelle Lei
13  * ZBS
14  */

15 package jfun.yan.lifecycle;
16
17 import java.io.Serializable JavaDoc;
18 import java.lang.reflect.Method JavaDoc;
19 import jfun.util.SerializableMethod;
20
21 final class MethodProcedure implements Procedure, Serializable JavaDoc {
22   private final SerializableMethod mtd;
23   public void invoke(Object JavaDoc self, Object JavaDoc[] args) throws Throwable JavaDoc {
24     invokeMethod(self, mtd.getMethod(), args);
25   }
26   MethodProcedure(Method JavaDoc mtd) {
27     this.mtd = new SerializableMethod(mtd);
28   }
29   static void invokeMethod(Object JavaDoc self, Method JavaDoc mtd, Object JavaDoc[] args)
30   throws Throwable JavaDoc{
31       mtd.invoke(self, args);
32   }
33   public boolean equals(Object JavaDoc obj) {
34     if(obj instanceof MethodProcedure){
35       final MethodProcedure other = (MethodProcedure)obj;
36       return mtd.equals(other.mtd);
37     }
38     else return false;
39   }
40   public int hashCode() {
41     return mtd.hashCode();
42   }
43   public String JavaDoc toString() {
44     return mtd.toString();
45   }
46 }
47
Popular Tags