KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > lang > JoinPoint


1 /* *******************************************************************
2  * Copyright (c) 1999-2001 Xerox Corporation,
3  * 2002 Palo Alto Research Center, Incorporated (PARC).
4  * All rights reserved.
5  * This program and the accompanying materials are made available
6  * under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * Xerox/PARC initial implementation
12  * ******************************************************************/

13
14
15 package org.aspectj.lang;
16
17 import org.aspectj.lang.reflect.SourceLocation;
18
19 /**
20  * <p>Provides reflective access to both the state available at a join point and
21  * static information about it. This information is available from the body
22  * of advice using the special form <code>thisJoinPoint</code>. The primary
23  * use of this reflective information is for tracing and logging applications.
24  * </p>
25  *
26  * <pre>
27  * aspect Logging {
28  * before(): within(com.bigboxco..*) && execution(public * *(..)) {
29  * System.err.println("entering: " + thisJoinPoint);
30  * System.err.println(" w/args: " + thisJoinPoint.getArgs());
31  * System.err.println(" at: " + thisJoinPoint.getSourceLocation());
32  * }
33  * }
34  * </pre>
35  */

36 public interface JoinPoint {
37
38     String JavaDoc toString();
39
40     /**
41      * Returns an abbreviated string representation of the join point.
42      */

43     String JavaDoc toShortString();
44
45     /**
46      * Returns an extended string representation of the join point.
47      */

48     String JavaDoc toLongString();
49
50     /**
51      * <p> Returns the currently executing object. This will always be
52      * the same object as that matched by the <code>this</code> pointcut
53      * designator. Unless you specifically need this reflective access,
54      * you should use the <code>this</code> pointcut designator to
55      * get at this object for better static typing and performance.</p>
56      *
57      * <p> Returns null when there is no currently executing object available.
58      * This includes all join points that occur in a static context.</p>
59      */

60     Object JavaDoc getThis();
61
62     /**
63      * <p> Returns the target object. This will always be
64      * the same object as that matched by the <code>target</code> pointcut
65      * designator. Unless you specifically need this reflective access,
66      * you should use the <code>target</code> pointcut designator to
67      * get at this object for better static typing and performance.</p>
68      *
69      * <p> Returns null when there is no target object.</p>
70
71      */

72     Object JavaDoc getTarget();
73
74     /**
75      * <p>Returns the arguments at this join point.</p>
76      */

77     Object JavaDoc[] getArgs();
78
79     /** Returns the signature at the join point.
80      *
81      * <code>getStaticPart().getSignature()</code> returns the same object
82      */

83     Signature getSignature();
84
85     /** <p>Returns the source location corresponding to the join point.</p>
86      *
87      * <p>If there is no source location available, returns null.</p>
88      *
89      * <p>Returns the SourceLocation of the defining class for default constructors.</p>
90      *
91      * <p> <code>getStaticPart().getSourceLocation()</code> returns the same object. </p>
92      */

93     SourceLocation getSourceLocation();
94
95     /** Returns a String representing the kind of join point. This
96      * String is guaranteed to be
97      * interned. <code>getStaticPart().getKind()</code> returns
98      * the same object.
99      */

100     String JavaDoc getKind();
101
102
103     /**
104      * <p>This helper object contains only the static information about a join point.
105      * It is available from the <code>JoinPoint.getStaticPart()</code> method, and
106      * can be accessed separately within advice using the special form
107      * <code>thisJoinPointStaticPart</code>.</p>
108      *
109      * <p>If you are only interested in the static information about a join point,
110      * you should access it through this type for the best performance. This
111      * is particularly useful for library methods that want to do serious
112      * manipulations of this information, i.e.</p>
113      *
114      * <pre>
115      * public class LoggingUtils {
116      * public static void prettyPrint(JoinPoint.StaticPart jp) {
117      * ...
118      * }
119      * }
120      *
121      * aspect Logging {
122      * before(): ... { LoggingUtils.prettyPrint(thisJoinPointStaticPart); }
123      * }
124      * </pre>
125      *
126      * @see JoinPoint#getStaticPart()
127      */

128     public interface StaticPart {
129         /** Returns the signature at the join point. */
130         Signature getSignature();
131
132         /** <p>Returns the source location corresponding to the join point.</p>
133         *
134         * <p>If there is no source location available, returns null.</p>
135         *
136         * <p>Returns the SourceLocation of the defining class for default constructors.</p>
137         */

138         SourceLocation getSourceLocation();
139
140         /** <p> Returns a String representing the kind of join point. This String
141         * is guaranteed to be interned</p>
142         */

143         String JavaDoc getKind();
144
145         String JavaDoc toString();
146
147         /**
148         * Returns an abbreviated string representation of the join point
149         */

150         String JavaDoc toShortString();
151
152         /**
153         * Returns an extended string representation of the join point
154         */

155         String JavaDoc toLongString();
156     }
157
158     public interface EnclosingStaticPart extends StaticPart {}
159
160     /**
161      * Returns an object that encapsulates the static parts of this join point.
162      */

163     StaticPart getStaticPart();
164
165
166     /**
167      * The legal return values from getKind()
168      */

169     static String JavaDoc METHOD_EXECUTION = "method-execution";
170     static String JavaDoc METHOD_CALL = "method-call";
171     static String JavaDoc CONSTRUCTOR_EXECUTION = "constructor-execution";
172     static String JavaDoc CONSTRUCTOR_CALL = "constructor-call";
173     static String JavaDoc FIELD_GET = "field-get";
174     static String JavaDoc FIELD_SET = "field-set";
175     static String JavaDoc STATICINITIALIZATION = "staticinitialization";
176     static String JavaDoc PREINITIALIZATION = "preinitialization";
177     static String JavaDoc INITIALIZATION = "initialization";
178     static String JavaDoc EXCEPTION_HANDLER = "exception-handler";
179     static String JavaDoc SYNCHRONIZATION_LOCK = "lock";
180     static String JavaDoc SYNCHRONIZATION_UNLOCK = "unlock";
181
182     static String JavaDoc ADVICE_EXECUTION = "adviceexecution";
183
184 }
185
Popular Tags