KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > inf > iks > jvmai > jvmdi > CodeJoinPointImpl


1 //
2
// This file is part of the prose package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is prose.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
// $Id: CodeJoinPointImpl.java,v 1.1.1.1 2003/07/02 15:30:50 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.inf.iks.jvmai.jvmdi;
28
29 import java.lang.reflect.Method JavaDoc;
30 import java.util.List JavaDoc;
31 import ch.ethz.jvmai.JoinPointStaticPart;
32 import ch.ethz.jvmai.CodeJoinPoint;
33 import ch.ethz.jvmai.JoinPoint;
34 import ch.ethz.jvmai.Signature;
35 import ch.ethz.jvmai.JoinPointKinds;
36
37
38 public class CodeJoinPointImpl implements CodeJoinPoint, JoinPointStaticPart, JoinPointKinds
39 {
40     protected Signature signature; // set
41
protected JoinPointContext context; //
42
protected Object JavaDoc aopTag;
43     protected ControlFlow cflow;
44     protected Object JavaDoc target;
45
46     protected CodeJoinPointImpl(ControlFlow cflow)
47     {
48 // if (cflow == null) // FIXME!!
49
//throw new IllegalArgumentException("CodeJoinPointImpl.<init>: cflow must be non-null");
50
this.context = new JoinPointContext();
51       this.signature = new CodeSignatureImpl(this);
52       this.target = null;
53       this.cflow = cflow;
54     }
55
56     protected CodeJoinPointImpl(ControlFlow cflow,JoinPointContext ctx)
57     {
58       //if (cflow == null)
59
///throw new IllegalArgumentException("CodeJoinPointImpl.<init>: cflow must be non-null");
60
this.context = ctx;
61     this.signature = new CodeSignatureImpl(this);
62     this.target = null;
63     this.cflow = cflow;
64     }
65
66     public boolean equals(Object JavaDoc other)
67     {
68
69     if (other instanceof CodeJoinPointImpl)
70       return context.location.equals(((CodeJoinPointImpl)other).context.location);
71     else
72         return false;
73     }
74
75     public int hashCode()
76     {
77     return context.location.hashCode();
78     }
79
80     /**
81      * Contains the method beeing executed
82      * when this joinpoint has been reached.
83      */

84   public Method JavaDoc getMethod()
85     {
86       return context.location.executingMethod;
87     }
88
89   /** The byteCodeIndex of this joinPoint.
90    */

91   public int getByteCodeIndex()
92     {
93       return context.location.executingBci;
94     }
95
96   /** Return the arguments at this join-point.
97    * @return the arguments at this join-point
98    */

99     public Object JavaDoc[] getArgs()
100     {
101       return context.getArgs();
102     }
103
104
105   public String JavaDoc getKind()
106     {
107       return CodeJoinPoint.KIND;
108     }
109
110   public int getMask()
111     {
112       return JoinPointKinds.MASK_CODE_JP;
113     }
114
115   /**
116    * Return the object executing this joinpoint.
117    */

118   public Object JavaDoc getThis()
119     {
120       return context.getThis();
121     }
122
123   /** Return the target object of this joinpoint
124    */

125   public Object JavaDoc getTarget()
126     {
127       return target;
128     }
129
130   /** Return the signature of this object
131    */

132   public Signature getSignature()
133     {
134       return signature;
135     }
136
137
138   /** Return the enclosing join-point.
139    */

140   public CodeJoinPoint getEnclosingJoinPoint()
141     {
142       CodeJoinPointImpl result= new CodeJoinPointImpl(cflow,context.callerContext());
143       result.target = getThis();
144       return result;
145     }
146
147   public String JavaDoc toShortString()
148     {
149       return getMethod().toString() + "@" + getByteCodeIndex();
150     }
151
152   public String JavaDoc toLongString()
153     {
154       return getMethod().toString() + "@" + getByteCodeIndex();
155     }
156
157   public String JavaDoc toString()
158     {
159       return toShortString();
160     }
161
162   /**
163    * Contains a user-defined object. This object has been
164    * supplied during registration of this joinpoint.
165    */

166   public Object JavaDoc getAopTag()
167     {
168       return aopTag;
169     }
170
171   /* Return the list of tags beloning to join-points
172    * in this control flow. The first tag is always
173    * the one that can be obtained through <code>getAopTag</code>.
174    *
175    */

176   public java.util.Collection JavaDoc getCflowTags()
177     {
178       return cflow.getAopTags(this);
179     }
180
181   public JoinPointStaticPart getStaticPart()
182     {
183       return this;
184     }
185
186   }
187
188 //======================================================================
189
//
190
// $Log: CodeJoinPointImpl.java,v $
191
// Revision 1.1.1.1 2003/07/02 15:30:50 apopovic
192
// Imported from ETH Zurich
193
//
194
// Revision 1.3 2003/05/05 17:46:22 popovici
195
// Refactorization step (runes->prose) cleanup
196
//
197
// Revision 1.2 2003/04/17 08:47:02 popovici
198
// Important functionality additions
199
// - Cflow specializers
200
// - Restructuring of the MethodCut, SetCut, ExceptionCut, and GetCut (they are much smaller)
201
// - Transactional capabilities
202
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
203
// between static and dynamic specializers.
204
// - Functionality pulled up in abstract classes
205
// - Uniformization of advice methods patterns and names
206
//
207
// Revision 1.1 2003/03/04 11:26:21 popovici
208
// Important refactorization step (march):
209
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
210
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
211
// structures
212
//
213
Popular Tags