KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > transform > inlining > EmittedJoinPoint


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.transform.inlining;
9
10 import org.codehaus.aspectwerkz.joinpoint.management.JoinPointType;
11 import org.codehaus.aspectwerkz.transform.Context;
12 import org.objectweb.asm.Label;
13
14 /**
15  * A structure that keeps required information needed to regenerate a JIT joinpoint. The weaver emits this
16  * information so that we can add initalization code to the weaved class. Note that EmittedJP are really Emitted -
17  * and can be a subset of actual JP (f.e. call, where information is lost in between each weave phase).
18  *
19  * FIXME equals and hashcode are wrong if 2 JP in same withincode - should depend on line number f.e. but that won't
20  * even be enough. Muts have a static variable and trust that creation of EmittedJP is ok.
21  * Check where those are used in a map for hashcode / equals to be used.
22  *
23  *
24  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur </a>
25  * @author <a HREF="mailto:jboner@codehaus.org">Jonas Bonér </a>
26  */

27 public final class EmittedJoinPoint {
28
29     public final static Label NO_LINE_NUMBER = new Label();
30
31     private final int joinPointType;
32     private final String JavaDoc callerClassName;
33     private final String JavaDoc callerMethodName;
34     private final String JavaDoc callerMethodDesc;
35     private final int callerMethodModifiers;
36     private final String JavaDoc calleeClassName;
37     private final String JavaDoc calleeMemberName;
38     private final String JavaDoc calleeMemberDesc;
39     private final int calleeMemberModifiers;
40     private final int joinPointHash;
41     private final String JavaDoc joinPointClassName;
42     private final Label lineNumberLabel;
43
44     /**
45      * Line number for call / get / set / handler joinpoint
46      * The lineNumber is 0 unless available and resolveLineNumber(Context) has been called.
47      */

48     private int lineNumber = 0;
49
50     /**
51      * Creates a new instance.
52      *
53      * @param joinPointType
54      * @param callerClassName
55      * @param callerMethodName
56      * @param callerMethodDesc
57      * @param callerMethodModifiers
58      * @param calleeClassName
59      * @param calleeMemberName
60      * @param calleeMemberDesc
61      * @param calleeMemberModifiers
62      * @param joinPointHash
63      * @param joinPointClassName
64      * @param lineNumberLabel
65      */

66     public EmittedJoinPoint(final int joinPointType,
67                             final String JavaDoc callerClassName,
68                             final String JavaDoc callerMethodName,
69                             final String JavaDoc callerMethodDesc,
70                             final int callerMethodModifiers,
71                             final String JavaDoc calleeClassName,
72                             final String JavaDoc calleeMemberName,
73                             final String JavaDoc calleeMemberDesc,
74                             final int calleeMemberModifiers,
75                             final int joinPointHash,
76                             final String JavaDoc joinPointClassName,
77                             final Label lineNumberLabel) {
78         this.joinPointType = joinPointType;
79         this.callerClassName = callerClassName;
80         this.callerMethodName = callerMethodName;
81         this.callerMethodDesc = callerMethodDesc;
82         this.callerMethodModifiers = callerMethodModifiers;
83         this.calleeClassName = calleeClassName;
84         this.calleeMemberName = calleeMemberName;
85         this.calleeMemberDesc = calleeMemberDesc;
86         this.calleeMemberModifiers = calleeMemberModifiers;
87         this.joinPointHash = joinPointHash;
88         this.joinPointClassName = joinPointClassName;
89         this.lineNumberLabel = lineNumberLabel;
90     }
91
92     /**
93      * Creates a new instance.
94      *
95      * @param joinPointType
96      * @param callerClassName
97      * @param callerMethodName
98      * @param callerMethodDesc
99      * @param callerMethodModifiers
100      * @param calleeClassName
101      * @param calleeMemberName
102      * @param calleeMemberDesc
103      * @param calleeMemberModifiers
104      * @param joinPointHash
105      * @param joinPointClassName
106      */

107     public EmittedJoinPoint(final int joinPointType,
108                             final String JavaDoc callerClassName,
109                             final String JavaDoc callerMethodName,
110                             final String JavaDoc callerMethodDesc,
111                             final int callerMethodModifiers,
112                             final String JavaDoc calleeClassName,
113                             final String JavaDoc calleeMemberName,
114                             final String JavaDoc calleeMemberDesc,
115                             final int calleeMemberModifiers,
116                             final int joinPointHash,
117                             final String JavaDoc joinPointClassName) {
118         this(joinPointType, callerClassName, callerMethodName, callerMethodDesc, callerMethodModifiers,
119                 calleeClassName, calleeMemberName, calleeMemberDesc, calleeMemberModifiers,
120                 joinPointHash, joinPointClassName, NO_LINE_NUMBER
121         );
122     }
123
124     public int getJoinPointType() {
125         return joinPointType;
126     }
127
128     public String JavaDoc getCallerClassName() {
129         return callerClassName;
130     }
131
132     public String JavaDoc getCallerMethodName() {
133         return callerMethodName;
134     }
135
136     public String JavaDoc getCallerMethodDesc() {
137         return callerMethodDesc;
138     }
139
140     public int getCallerMethodModifiers() {
141         return callerMethodModifiers;
142     }
143
144     public String JavaDoc getCalleeClassName() {
145         return calleeClassName;
146     }
147
148     public String JavaDoc getCalleeMemberName() {
149         return calleeMemberName;
150     }
151
152     public String JavaDoc getCalleeMemberDesc() {
153         return calleeMemberDesc;
154     }
155
156     public int getCalleeMemberModifiers() {
157         return calleeMemberModifiers;
158     }
159
160     public int getJoinPointHash() {
161         return joinPointHash;
162     }
163
164     public String JavaDoc getJoinPointClassName() {
165         return joinPointClassName;
166     }
167
168     public int getLineNumber() {
169         return lineNumber;
170     }
171
172     public void resolveLineNumber(Context context) {
173         lineNumber = context.resolveLineNumberInfo(lineNumberLabel);
174     }
175
176     public boolean equals(Object JavaDoc o) {
177         if (this == o) {
178             return true;
179         }
180         if (!(o instanceof EmittedJoinPoint)) {
181             return false;
182         }
183
184         final EmittedJoinPoint emittedJoinPoint = (EmittedJoinPoint) o;
185
186         if (calleeMemberModifiers != emittedJoinPoint.calleeMemberModifiers) {
187             return false;
188         }
189         if (callerMethodModifiers != emittedJoinPoint.callerMethodModifiers) {
190             return false;
191         }
192         if (joinPointHash != emittedJoinPoint.joinPointHash) {
193             return false;
194         }
195         if (joinPointType != emittedJoinPoint.joinPointType) {
196             return false;
197         }
198         if (!calleeClassName.equals(emittedJoinPoint.calleeClassName)) {
199             return false;
200         }
201         if (!calleeMemberDesc.equals(emittedJoinPoint.calleeMemberDesc)) {
202             return false;
203         }
204         if (!calleeMemberName.equals(emittedJoinPoint.calleeMemberName)) {
205             return false;
206         }
207         if (!callerClassName.equals(emittedJoinPoint.callerClassName)) {
208             return false;
209         }
210         if (!callerMethodDesc.equals(emittedJoinPoint.callerMethodDesc)) {
211             return false;
212         }
213         if (!callerMethodName.equals(emittedJoinPoint.callerMethodName)) {
214             return false;
215         }
216         if (!joinPointClassName.equals(emittedJoinPoint.joinPointClassName)) {
217             return false;
218         }
219
220         return true;
221     }
222
223     public int hashCode() {
224         int result;
225         result = joinPointType;
226         result = 29 * result + callerClassName.hashCode();
227         result = 29 * result + callerMethodName.hashCode();
228         result = 29 * result + callerMethodDesc.hashCode();
229         result = 29 * result + callerMethodModifiers;
230         result = 29 * result + calleeClassName.hashCode();
231         result = 29 * result + calleeMemberName.hashCode();
232         result = 29 * result + calleeMemberDesc.hashCode();
233         result = 29 * result + calleeMemberModifiers;
234         result = 29 * result + joinPointHash;
235         result = 29 * result + joinPointClassName.hashCode();
236         return result;
237     }
238
239     public String JavaDoc toString() {
240         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
241         sb.append(JoinPointType.fromInt(getJoinPointType()).toString());
242         sb.append(" , caller ");
243         sb.append(getCallerClassName());
244         sb.append('.').append(getCallerMethodName());
245         sb.append(getCallerMethodDesc());
246         sb.append(" , callee ");
247         sb.append(getCalleeClassName());
248         sb.append('.').append(getCalleeMemberName());
249         sb.append(' ').append(getCalleeMemberDesc());
250         sb.append(" , line ").append(getLineNumber());
251         return sb.toString();
252     }
253 }
Popular Tags