01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.aspectwerkz.transform.inlining.weaver;
05:
06: import java.util.Set;
07:
08: import com.tc.asm.MethodVisitor;
09:
10: import com.tc.aspectwerkz.transform.TransformationConstants;
11: import com.tc.aspectwerkz.transform.inlining.AsmNullAdapter;
12:
13: /**
14: * A read only visitor to gather wrapper methods and proxy methods
15: * Makes use of the NullVisitors
16: *
17: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
18: */
19: public class AlreadyAddedMethodVisitor extends
20: AsmNullAdapter.NullClassAdapter implements
21: TransformationConstants {
22:
23: /**
24: * Set of "<methodName><methodDesc>" strings populated with wrapper methods, prefixed originals
25: * and ctor body wrappers to allow multiweaving support.
26: */
27: private final Set m_addedMethods;
28:
29: /**
30: * Creates a new class adapter.
31: *
32: * @param wrappers
33: */
34: public AlreadyAddedMethodVisitor(final Set wrappers) {
35: m_addedMethods = wrappers;
36: }
37:
38: /**
39: * Visits the methods.
40: *
41: * @param access
42: * @param name
43: * @param desc
44: * @param signature
45: * @param exceptions
46: * @return
47: */
48: public MethodVisitor visitMethod(final int access,
49: final String name, final String desc,
50: final String signature, final String[] exceptions) {
51: if (name.startsWith(WRAPPER_METHOD_PREFIX)
52: || name.startsWith(ORIGINAL_METHOD_PREFIX)) {
53: m_addedMethods.add(getMethodKey(name, desc));
54: }
55: return super .visitMethod(access, name, desc, signature,
56: exceptions);
57: }
58:
59: /**
60: * Returns the key of the method.
61: *
62: * @param name
63: * @param desc
64: * @return
65: */
66: static String getMethodKey(final String name, final String desc) {
67: StringBuffer sb = new StringBuffer(name);
68: return sb.append(desc).toString();
69: }
70: }
|