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 Developers of the Original Code are Angela Nicoara and Gerald Linhofer.
017: // All Rights Reserved.
018: //
019: // Contributor(s):
020: // $Id$
021: // =====================================================================
022: //
023: // (history at end)
024: //
025:
026: package ch.ethz.jvmai;
027:
028: import java.lang.reflect.Member;
029: import java.lang.reflect.Method;
030: import ch.ethz.inf.iks.jvmai.jvmdi.HotSwapFieldWeaver;
031:
032: /*
033: * Modifies a given method to support advice execution.
034: * There is exactly one <CODE>MethodWeaver</CODE> object for
035: * each woven method.
036: * Use the static methods {@link: ClassWeaver#getWeaver(Class)}
037: * to get an instance of an MethodWeaver.
038: *
039: * @author Angela Nicoara
040: * @author Gerald Linhofer
041: * @version $Revision$
042: */
043: public interface MethodWeaver {
044:
045: // Status codes
046: /// Indicates that the target method has no (aspect-)cuts
047: public static final int MWEAVER_STATUS_UNCHANGED = 0x0;
048: // Extensions
049: /// Advice at method entry
050: public static final int MWEAVER_STATUS_ENTRY_ENABLED = 0x00001;
051: /// Advice at method exit
052: public static final int MWEAVER_STATUS_EXIT_ENABLED = 0x00002;
053: /// Advice before field access
054: public static final int MWEAVER_STATUS_HAS_FIELD_ACCESS_WATCH = 0x00004;
055: /// Advice before field modification
056: public static final int MWEAVER_STATUS_HAS_FIELD_MODIFICATION_WATCH = 0x00008;
057: /// Advice at exception throw
058: public static final int MWEAVER_STATUS_HAS_EXCEPTION_THROW_WATCH = 0x00010;
059: /// Advice at exception catch
060: public static final int MWEAVER_STATUS_HAS_EXCEPTION_CATCH_WATCH = 0x00020;
061: /// Advice before method call
062: public static final int MWEAVER_STATUS_HAS_METHOD_CALL_WATCH = 0x00040;
063: /// Advice after method return
064: public static final int MWEAVER_STATUS_HAS_METHOD_RETURN_WATCH = 0x00080;
065: /// Enclosing Advice (redefines the hole method body)
066: public static final int MWEAVER_STATUS_REDEFINE = 0x00100;
067:
068: /**
069: * Returns the method bound to this weaver.
070: * @return Method bound to this weaver.
071: */
072: public Member getTarget();
073:
074: /**
075: * Return the identifier of the method bound
076: * to this weaver.
077: * @return identifier of the method bound to this weaver.
078: */
079: public int getTargetId();
080:
081: /**
082: * Returns the status of this weaver.
083: * @return int status
084: */
085: public int getStatus();
086:
087: /**
088: * Redefine the method in this weaver.
089: *
090: * @param advice method that will be called instead
091: * or null to reset a redefined method.
092: */
093: public void setRedefineAdvice(Member advice);
094:
095: /**
096: * Enable method entry join point.
097: *
098: * @param flag enable/disable
099: */
100: public void setMethodEntryEnabled(boolean flag);
101:
102: /**
103: * Enable method entry join point.
104: *
105: * @param flag enable/disable
106: */
107: public void setMethodExitEnabled(boolean flag);
108:
109: /**
110: * Add a method for which a callback should be woven (before each call).
111: *
112: * @param m watched method
113: */
114: public void addMethodCall(Method m);
115:
116: /**
117: * Remove a method for which a callback was woven (before each call).
118: *
119: * @param m watched method
120: */
121: public void removeMethodCall(Method m);
122:
123: /**
124: * Add a method for which a callback should be woven (after each call).
125: *
126: * @param m watched method
127: */
128: public void addMethodReturn(Method m);
129:
130: /**
131: * Remove a method for which a callback was woven (after each call).
132: *
133: * @param m watched method
134: */
135: public void removeMethodReturn(Method m);
136:
137: /**
138: * Add a field for which a callback should be woven (for each access).
139: *
140: * @param f watched field
141: */
142: public void addFieldAccessor(HotSwapFieldWeaver f);
143:
144: /**
145: * Remove a field for which a callback was woven (for each access).
146: *
147: * @param f watched field
148: */
149: public void removeFieldAccessor(HotSwapFieldWeaver f);
150:
151: /**
152: * Add a field for which a callback should be woven (for each modification).
153: *
154: * @param f watched field
155: */
156: public void addFieldModifier(HotSwapFieldWeaver f);
157:
158: /**
159: * Remove a field for which a callback was woven (for each modification).
160: *
161: * @param f watched field
162: */
163: public void removeFieldModifier(HotSwapFieldWeaver f);
164: }
165:
166: //======================================================================
167: //
168: // $Log$
169: //
|