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 Andrei Popovici. Portions
17: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18: // All Rights Reserved.
19: //
20: // Contributor(s):
21: // $Id$
22: // ================================================================
23: //
24: // (history at the end)
25: //
26:
27: package ch.ethz.prose.crosscut;
28:
29: import java.lang.IllegalAccessException;
30: import ch.ethz.jvmai.JoinPoint;
31: import java.lang.Object;
32: import java.lang.reflect.InvocationTargetException;
33:
34: /** An advice execution for an advice action of the form
35: * <code>XXX(Foo thisObj,String a, int b, <em>other non-wildcards..</em>)</code>
36: * <p>
37: * This method redefines the <code>allocStackArgs</code> because it
38: * knows that the number of arguments on the stack is exactly
39: * equal to the number of arguments of the advice method.
40: */
41: class ConcreteConcreteMcutAdvice extends McutAdvice {
42: private static final long serialVersionUID = 3258125847675547953L;
43: private final MethodCut methodCut;
44:
45: protected void allocStackArgs(int expectedLength) {
46: stackArgsLength = advice.getLength();
47: stackArgs = new Object[stackArgsLength];
48: }
49:
50: ConcreteConcreteMcutAdvice(MethodCut methodCut, JoinPoint m,
51: MethodCutSignaturePattern a) {
52: super (methodCut, m, a);
53: this .methodCut = methodCut;
54: }
55:
56: /** Invoke (reflection) the method of the advice object.
57: * Because of the special signature of the advice, one can
58: * pass the (unmodified) stack arguments directly to
59: * <code>Method.invoke</code>. This is btw. efficient.
60: *
61: */
62: protected void execute() throws IllegalAccessException,
63: InvocationTargetException {
64: advice.methodObj.invoke(methodCut, stackArgs);
65: }
66: }
67:
68: //======================================================================
69: //
70: // $Log$
71: //
|