01: /**************************************************************************************
02: * Copyright (c) Jonas Bon?r, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.transform.inlining.weaver;
08:
09: import org.objectweb.asm.Constants;
10: import org.objectweb.asm.CodeVisitor;
11: import org.objectweb.asm.Attribute;
12: import org.codehaus.aspectwerkz.transform.TransformationConstants;
13: import org.codehaus.aspectwerkz.annotation.instrumentation.asm.AsmAnnotationHelper;
14:
15: import java.util.Set;
16:
17: /**
18: * A read only visitor to gather wrapper methods and proxy methods
19: * Makes use of the NullVisitors
20: *
21: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
22: */
23: public class AlreadyAddedMethodAdapter extends
24: AsmAnnotationHelper.NullClassAdapter implements Constants,
25: TransformationConstants {
26:
27: /**
28: * Set of "<methodName><methodDesc>" strings populated with wrapper methods, prefixed originals
29: * and ctor body wrappers to allow multiweaving support.
30: */
31: private final Set m_addedMethods;
32:
33: /**
34: * Creates a new class adapter.
35: *
36: * @param wrappers
37: */
38: public AlreadyAddedMethodAdapter(final Set wrappers) {
39: m_addedMethods = wrappers;
40: }
41:
42: /**
43: * Visits the methods.
44: *
45: * @param access
46: * @param name
47: * @param desc
48: * @param exceptions
49: * @param attrs
50: * @return
51: */
52: public CodeVisitor visitMethod(final int access, final String name,
53: final String desc, final String[] exceptions,
54: final Attribute attrs) {
55: if (name.startsWith(WRAPPER_METHOD_PREFIX)
56: || name.startsWith(ORIGINAL_METHOD_PREFIX)) {
57: m_addedMethods.add(getMethodKey(name, desc));
58: }
59: return super .visitMethod(access, name, desc, exceptions, attrs);
60: }
61:
62: static String getMethodKey(String name, String desc) {
63: StringBuffer sb = new StringBuffer(name);
64: return sb.append(desc).toString();
65: }
66: }
|