KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > transform > inlining > weaver > AlreadyAddedMethodAdapter


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.transform.inlining.weaver;
5
6 import java.util.Set JavaDoc;
7
8 import com.tc.asm.MethodVisitor;
9 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 AsmNullAdapter.NullClassAdapter implements Opcodes, TransformationConstants {
21
22   /**
23    * Set of "<methodName><methodDesc>" strings populated with wrapper methods, prefixed originals
24    * and ctor body wrappers to allow multiweaving support.
25    */

26   private final Set JavaDoc m_addedMethods;
27
28   /**
29    * Creates a new class adapter.
30    *
31    * @param wrappers
32    */

33   public AlreadyAddedMethodAdapter(final Set JavaDoc wrappers) {
34     m_addedMethods = wrappers;
35   }
36
37   /**
38    * Visits the methods.
39    *
40    * @param access
41    * @param name
42    * @param desc
43    * @param signature
44    * @param exceptions
45    * @return
46    */

47   public MethodVisitor visitMethod(final int access,
48                                    final String JavaDoc name,
49                                    final String JavaDoc desc,
50                                    final String JavaDoc signature,
51                                    final String JavaDoc[] 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, exceptions);
57   }
58
59   static String JavaDoc getMethodKey(String JavaDoc name, String JavaDoc desc) {
60     StringBuffer JavaDoc sb = new StringBuffer JavaDoc(name);
61     return sb.append(desc).toString();
62   }
63 }
64
Popular Tags