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: Crosscut.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.prose.crosscut;
028:
029: import java.io.Serializable;
030:
031: import ch.ethz.prose.Insertable;
032: import ch.ethz.prose.Aspect;
033: import ch.ethz.prose.engine.JoinPointListener;
034:
035: /**
036: * <h3>User perspective</H3>
037: * If you want to use crosscuts, than you have to understand two things:
038: * <ul>
039: * <li> how to write advices
040: * <li> how to use point-cutters.
041: * </ul>
042: * Read the documentation for <code>MethodCut</code>, <code>GetCut</code> etc
043: * to understand these issues.
044: *
045: * <h3>Developer perspective </h3>
046: * Class Crosscut defines an object which can create <code>CrosscutRequests</code>.
047: * A crosscut request defines a crosscut as a set of join point requests together with
048: * actions to be performed when the events corresponding to the crosscut it defines are
049: * triggered.
050: * <p>
051: * A crosscut is also a <code>JointPointListener</code>. According to
052: * the contract provided by <code>JoinPointManager</code>
053: * an crosscut expects to be notified only for those events
054: * which correspond to the requests it has created itself.
055: * Crossscut objects are expected to be used in two modes:
056: * <ul>
057: * <li> when first defining a crosscuting action for the current state
058: * of the VM
059: * <li> when a new class is loaded in the current VM
060: * </ul>
061: *
062: * @version $Revision: 1.1.1.1 $
063: * @author Andrei Popovici
064: */
065: public abstract class Crosscut extends JoinPointListener implements
066: Insertable, Serializable {
067:
068: /** Create a <code>CrosscutRequest</code> for the specified class in the local
069: * virtual machine. This method should be used by first use of this crosscut. It
070: * analyses either all classes of the virtual machine or a definite subset of it,
071: * specific for this <code>Crosscut</code>.
072: * <p>
073: * The <code>JoinPointRequest</code>s in the result of this method are created
074: * using the factory specified with <code>setRequestFactorye</code>.
075: *
076: * @return the CrosscutRequest corresponding to the join-points defined by this
077: * crosscut with respect to the current state of the local VM
078: */
079: public abstract CrosscutRequest createRequest();
080:
081: /** Create a <code>CrosscutRequest</code> for the local virtual machine, but containing
082: * requests for joinpoints only inside the class <code>crtCls</code>. This method
083: * is expected to be used upon loading of new classes.
084: *
085: * <p>
086: * The <code>JoinPointRequests</code> in the result of this method are created
087: * using the factory specified with <code>setRequestFactorye</code>.
088: */
089: public abstract CrosscutRequest createRequest(Class crtCls);
090:
091: /**
092: * Associated this crosscut to the group <code>grp</code>.
093: * By associating a crosscut to a group, the advice of
094: * this crosscut are executed depending on the state of the
095: * group.
096: * (see <code>CrosscutGroup.setExecuteAdvice</code>)
097: *
098: */
099: public abstract void associateToGroup(CrosscutGroup grp);
100:
101: /** Return the Aspect that owns this crosscut.
102: */
103: public abstract Aspect getOwner();
104:
105: /** Set the Aspect that owns this crosscut. This method cannot be
106: * executed twice (crosscut cannot change owners).
107: */
108: public abstract void setOwner(Aspect x);
109:
110: }
111:
112: //======================================================================
113: //
114: // $Log: Crosscut.java,v $
115: // Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
116: // Imported from ETH Zurich
117: //
118: // Revision 1.2 2003/05/26 13:28:51 popovici
119: // Documentation Improvements
120: //
121: // Revision 1.1 2003/05/05 13:58:17 popovici
122: // renaming from runes to prose
123: //
124: // Revision 1.10 2003/04/29 12:41:06 popovici
125: // Feature added:
126: // - the 'setPriority' in class insertable allows now Aspects and Crosscuts to have a priority.
127: // Notitification is done from low int priorities to high int priorities.
128: // - the 'setAspectID' introduced to replace constuctor; used to be cumberstone for subclasses
129: //
130: // Revision 1.9 2003/04/17 15:15:19 popovici
131: // Extension->Aspect renaming
132: //
133: // Revision 1.8 2003/04/17 12:49:24 popovici
134: // Refactoring of the crosscut package
135: // ExceptionCut renamed to ThrowCut
136: // McutSignature is now SignaturePattern
137: //
138: // Revision 1.7 2003/04/17 08:47:17 popovici
139: // Important functionality additions
140: // - Cflow specializers
141: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
142: // - Transactional capabilities
143: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
144: // between static and dynamic specializers.
145: // - Functionality pulled up in abstract classes
146: // - Uniformization of advice methods patterns and names
147: //
148: // Revision 1.6 2003/03/04 18:36:35 popovici
149: // Organization of imprts
150: //
151: // Revision 1.5 2002/03/28 13:48:42 popovici
152: // Mozilla-ified
153: //
154: // Revision 1.4 2002/03/12 09:49:32 popovici
155: // Join Point listener now abstract class (performance reasons)
156: //
157: // Revision 1.3 2002/02/21 12:36:48 popovici
158: // Interface 'Insertable' added. Extensions and crosscuts
159: // are now insertable objects.
160: //
161: // Revision 1.2 2002/02/05 09:46:51 smarkwal
162: // JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
163: //
164: // Revision 1.1.1.1 2001/11/29 18:13:17 popovici
165: // Sources from runes
166: //
167: // Revision 1.1.2.3 2001/11/21 11:56:26 popovici
168: //
169: // -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
170: // replaced with the iks.jvmdi package. References to this old
171: // functionality replaced throughout the code.
172: // -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
173: // part of their functionality moved to the ch.ethz.prose.reflect
174: // abstract classes. New classes and functionality added to the
175: // ch.ethz.prose.reflect package, partially to reflect the
176: // more stable features taken from the iks.runes packages, partially
177: // to reflect the structure of the VM (constant pool, etc). Functionality in
178: // ch.ethz.prose.crosscut and the junit classes adapted to use the
179: // new form of the ch.ethz.prose.reflect package
180: //
181: // Revision 1.1.2.2 2001/02/05 13:26:44 mrmuller
182: // needs to implement Serializable, so that Extensions can be passed by value
183: //
184: // Revision 1.1.2.1 2000/10/23 18:31:27 popovici
185: // Moved from ch.ethz.prose to ch.ethz.prose.crosscut;
186: // It is now an interface usable by Extensions
187: //
|