01: //
02: // This file is part of the prose package.
03: //
04: // The contents of this file are subject to the Mozilla Public License
05: // Version 1.1 (the "License"); you may not use this file except in
06: // compliance with the License. You may obtain a copy of the License at
07: // http://www.mozilla.org/MPL/
08: //
09: // 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 Angela Nicoara. Portions
17: // created by Angela Nicoara are Copyright (C) 2002 Angela Nicoara.
18: // All Rights Reserved.
19: //
20: // Contributor(s):
21: // $Id$
22: // =====================================================================
23: //
24: // (history at end)
25: //
26:
27: package ch.ethz.prose.jvmai.jikesrvm.advice_weaver;
28:
29: import ch.ethz.jvmai.JVMAspectInterface;
30: import ch.ethz.prose.crosscut.MethodRedefineCut;
31: import ch.ethz.prose.engine.*;
32:
33: /**
34: * A JoinPointManager that uses advice weaving at bytecode level.
35: *
36: * @version $Revision$
37: * @author Johann Gyger
38: * @author Angela Nicoara
39: */
40: public class AdviceJoinPointManager extends JoinPointManager {
41:
42: protected RedefineWeaver weaver = new RedefineWeaver();
43:
44: public AdviceJoinPointManager(boolean isConnected,
45: JVMAspectInterface ai, boolean enableRevMap) {
46: super (isConnected, ai, enableRevMap);
47: }
48:
49: /**
50: * This method doesn't register a listener. Instead, it directly weaves the
51: * advice into the method.
52: *
53: * @param jpl listener to register
54: * @param jpr request
55: */
56: public void registerListener(JoinPointListener jpl,
57: JoinPointRequest jpr) {
58: if (jpr instanceof MethodRedefineRequest) {
59: MethodRedefineCut cut = (MethodRedefineCut) jpl;
60: MethodRedefineRequest request = (MethodRedefineRequest) jpr;
61: weaver.weaveMethodRedefineCut(cut, request);
62: } else {
63: super .registerListener(jpl, jpr);
64: }
65: }
66:
67: /**
68: * This method doesn't unregister a listener. Instead, it unweaves the advice
69: * that was woven with
70: * {@link #registerListener(JoinPointListener, JoinPointRequest)}.
71: *
72: * @param jpl listener to register
73: */
74: public void unregisterListener(JoinPointListener jpl) {
75: if (jpl instanceof MethodRedefineCut) {
76: MethodRedefineCut cut = (MethodRedefineCut) jpl;
77: weaver.unweaveMethodRedefineCut(cut);
78: } else {
79: super .unregisterListener(jpl);
80: }
81: }
82:
83: }
84:
85: //======================================================================
86: //
87: // $Log$
88: //
|