001: //
002: // This file is part of the prose package.
003: //
004: // The contents of this file are subject to the Mozilla Public License
005: // Version 1.1 (the "License"); you may not use this file except in
006: // compliance with the License. You may obtain a copy of the License at
007: // http://www.mozilla.org/MPL/
008: //
009: // Software distributed under the License is distributed on an "AS IS" basis,
010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: // for the specific language governing rights and limitations under the
012: // License.
013: //
014: // The Original Code is prose.
015: //
016: // The Initial Developer of the Original Code is Andrei Popovici. Portions
017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018: // All Rights Reserved.
019: //
020: // Contributor(s):
021: // $Id: CodeJoinPointImpl.java,v 1.1.1.1 2003/07/02 15:30:50 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.inf.iks.jvmai.jvmdi;
028:
029: import java.lang.reflect.Method;
030: import ch.ethz.jvmai.JoinPointStaticPart;
031: import ch.ethz.jvmai.CodeJoinPoint;
032: import ch.ethz.jvmai.Signature;
033: import ch.ethz.jvmai.JoinPointKinds;
034:
035: public class CodeJoinPointImpl implements CodeJoinPoint,
036: JoinPointStaticPart, JoinPointKinds {
037: protected Signature signature; // set
038: protected JoinPointContext context; //
039: protected Object aopTag;
040: protected ControlFlow cflow;
041: protected Object target;
042:
043: protected CodeJoinPointImpl(ControlFlow cflow) {
044: // if (cflow == null) // FIXME!!
045: //throw new IllegalArgumentException("CodeJoinPointImpl.<init>: cflow must be non-null");
046: this .context = new JoinPointContext();
047: this .signature = new CodeSignatureImpl(this );
048: this .target = null;
049: this .cflow = cflow;
050: }
051:
052: protected CodeJoinPointImpl(ControlFlow cflow, JoinPointContext ctx) {
053: //if (cflow == null)
054: ///throw new IllegalArgumentException("CodeJoinPointImpl.<init>: cflow must be non-null");
055: this .context = ctx;
056: this .signature = new CodeSignatureImpl(this );
057: this .target = null;
058: this .cflow = cflow;
059: }
060:
061: public boolean equals(Object other) {
062:
063: if (other instanceof CodeJoinPointImpl)
064: return context.location
065: .equals(((CodeJoinPointImpl) other).context.location);
066: else
067: return false;
068: }
069:
070: public int hashCode() {
071: return context.location.hashCode();
072: }
073:
074: /**
075: * Contains the method beeing executed
076: * when this joinpoint has been reached.
077: */
078: public Method getMethod() {
079: return context.location.executingMethod;
080: }
081:
082: /** The byteCodeIndex of this joinPoint.
083: */
084: public int getByteCodeIndex() {
085: return context.location.executingBci;
086: }
087:
088: /** Return the arguments at this join-point.
089: * @return the arguments at this join-point
090: */
091: public Object[] getArgs() {
092: return context.getArgs();
093: }
094:
095: public String getKind() {
096: return CodeJoinPoint.KIND;
097: }
098:
099: public int getMask() {
100: return JoinPointKinds.MASK_CODE_JP;
101: }
102:
103: /**
104: * Return the object executing this joinpoint.
105: */
106: public Object getThis() {
107: return context.getThis();
108: }
109:
110: /** Return the target object of this joinpoint
111: */
112: public Object getTarget() {
113: return target;
114: }
115:
116: /** Return the signature of this object
117: */
118: public Signature getSignature() {
119: return signature;
120: }
121:
122: /** Return the enclosing join-point.
123: */
124: public CodeJoinPoint getEnclosingJoinPoint() {
125: CodeJoinPointImpl result = new CodeJoinPointImpl(cflow, context
126: .callerContext());
127: result.target = getThis();
128: return result;
129: }
130:
131: public String toShortString() {
132: return getMethod().toString() + "@" + getByteCodeIndex();
133: }
134:
135: public String toLongString() {
136: return getMethod().toString() + "@" + getByteCodeIndex();
137: }
138:
139: public String toString() {
140: return toShortString();
141: }
142:
143: /**
144: * Contains a user-defined object. This object has been
145: * supplied during registration of this joinpoint.
146: */
147: public Object getAopTag() {
148: return aopTag;
149: }
150:
151: /* Return the list of tags beloning to join-points
152: * in this control flow. The first tag is always
153: * the one that can be obtained through <code>getAopTag</code>.
154: *
155: */
156: public java.util.Collection getCflowTags() {
157: return cflow.getAopTags(this );
158: }
159:
160: public JoinPointStaticPart getStaticPart() {
161: return this ;
162: }
163:
164: }
165:
166: //======================================================================
167: //
168: // $Log: CodeJoinPointImpl.java,v $
169: // Revision 1.1.1.1 2003/07/02 15:30:50 apopovic
170: // Imported from ETH Zurich
171: //
172: // Revision 1.3 2003/05/05 17:46:22 popovici
173: // Refactorization step (runes->prose) cleanup
174: //
175: // Revision 1.2 2003/04/17 08:47:02 popovici
176: // Important functionality additions
177: // - Cflow specializers
178: // - Restructuring of the MethodCut, SetCut, ExceptionCut, and GetCut (they are much smaller)
179: // - Transactional capabilities
180: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
181: // between static and dynamic specializers.
182: // - Functionality pulled up in abstract classes
183: // - Uniformization of advice methods patterns and names
184: //
185: // Revision 1.1 2003/03/04 11:26:21 popovici
186: // Important refactorization step (march):
187: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
188: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
189: // structures
190: //
|