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: import com.tc.asm.Opcodes;
10:
11: import com.tc.aspectwerkz.transform.TransformationConstants;
12: import com.tc.aspectwerkz.transform.inlining.AsmNullAdapter;
13:
14: /**
15: * A read only visitor to gather wrapper methods and proxy methods
16: * Makes use of the NullVisitors
17: *
18: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
19: */
20: public class AlreadyAddedMethodAdapter extends
21: AsmNullAdapter.NullClassAdapter implements Opcodes,
22: TransformationConstants {
23:
24: /**
25: * Set of "<methodName><methodDesc>" strings populated with wrapper methods, prefixed originals
26: * and ctor body wrappers to allow multiweaving support.
27: */
28: private final Set m_addedMethods;
29:
30: /**
31: * Creates a new class adapter.
32: *
33: * @param wrappers
34: */
35: public AlreadyAddedMethodAdapter(final Set wrappers) {
36: m_addedMethods = wrappers;
37: }
38:
39: /**
40: * Visits the methods.
41: *
42: * @param access
43: * @param name
44: * @param desc
45: * @param signature
46: * @param exceptions
47: * @return
48: */
49: public MethodVisitor visitMethod(final int access,
50: final String name, final String desc,
51: final String signature, final String[] exceptions) {
52: if (name.startsWith(WRAPPER_METHOD_PREFIX)
53: || name.startsWith(ORIGINAL_METHOD_PREFIX)) {
54: m_addedMethods.add(getMethodKey(name, desc));
55: }
56: return super .visitMethod(access, name, desc, signature,
57: exceptions);
58: }
59:
60: static String getMethodKey(String name, String desc) {
61: StringBuffer sb = new StringBuffer(name);
62: return sb.append(desc).toString();
63: }
64: }
|