KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > MethodInfo


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.aop;
23
24 import org.jboss.aop.joinpoint.Joinpoint;
25 import org.jboss.aop.joinpoint.MethodJoinpoint;
26 import org.jboss.aop.util.MethodHashing;
27
28 import java.lang.reflect.Method JavaDoc;
29 import java.util.Arrays JavaDoc;
30
31 /**
32  * This class is here to eliminate a hash lookup in invokeMethod
33  */

34 public class MethodInfo extends JoinPointInfo
35 {
36    private Method JavaDoc advisedMethod;
37    private Method JavaDoc unadvisedMethod;
38    private long hash;
39    
40    public MethodInfo()
41    {
42    }
43    
44    public MethodInfo(Class JavaDoc clazz, long hash, long unadvisedHash, Advisor advisor)
45    {
46       super(advisor, clazz);
47
48       try
49       {
50          this.hash = hash;
51          advisedMethod = MethodHashing.findMethodByHash(clazz, hash);
52          unadvisedMethod = MethodHashing.findMethodByHash(clazz, unadvisedHash);
53          this.setAdvisor(advisor);
54       }
55       catch (Exception JavaDoc e)
56       {
57          throw new RuntimeException JavaDoc(e);
58       }
59       
60    }
61    
62    /*
63     * For copying
64     */

65    private MethodInfo(MethodInfo other)
66    {
67       super(other);
68       this.advisedMethod = other.advisedMethod;
69       this.unadvisedMethod = other.unadvisedMethod;
70       this.hash = other.hash;
71    }
72    
73    protected Joinpoint internalGetJoinpoint()
74    {
75       return new MethodJoinpoint(advisedMethod);
76    }
77    
78    public JoinPointInfo copy()
79    {
80       return new MethodInfo(this);
81    }
82
83    public Method JavaDoc getAdvisedMethod()
84    {
85       return advisedMethod;
86    }
87
88    public void setAdvisedMethod(Method JavaDoc advisedMethod)
89    {
90       this.advisedMethod = advisedMethod;
91    }
92
93    public long getHash() {
94       return hash;
95    }
96
97    public void setHash(long hash)
98    {
99       this.hash = hash;
100    }
101
102    public Method JavaDoc getUnadvisedMethod()
103    {
104       return unadvisedMethod;
105    }
106
107    public void setUnadvisedMethod(Method JavaDoc unadvisedMethod) {
108       this.unadvisedMethod = unadvisedMethod;
109    }
110    
111    public String JavaDoc toString()
112    {
113       StringBuffer JavaDoc sb = new StringBuffer JavaDoc("Method");
114       sb.append("[");
115       sb.append("method=" + advisedMethod);
116       sb.append("]");
117       return sb.toString();
118    }
119 }
120
Popular Tags