KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > reflect > impl > asm > AsmMemberInfo


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.reflect.impl.asm;
5
6 import com.tc.aspectwerkz.reflect.MemberInfo;
7 import com.tc.aspectwerkz.reflect.ClassInfo;
8
9 import java.lang.ref.WeakReference JavaDoc;
10
11 /**
12  * ASM implementation of the MemberInfo interface.
13  *
14  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15  */

16 public abstract class AsmMemberInfo implements MemberInfo {
17
18   /**
19    * The member info.
20    */

21   protected final MemberStruct m_member;
22
23   /**
24    * The class loader wrapped in a weak ref.
25    */

26   protected final WeakReference JavaDoc m_loaderRef;
27
28   /**
29    * The declaring type name.
30    */

31   protected final String JavaDoc m_declaringTypeName;
32
33   /**
34    * The declaring type.
35    */

36   protected ClassInfo m_declaringType;
37
38   /**
39    * The class info repository.
40    */

41   // protected final AsmClassInfoRepository m_classInfoRepository;
42

43   /**
44    * Creates a new member meta data instance.
45    *
46    * @param member
47    * @param declaringType
48    * @param loader
49    */

50   AsmMemberInfo(final MemberStruct member, final String JavaDoc declaringType, final ClassLoader JavaDoc loader) {
51     if (member == null) {
52       throw new IllegalArgumentException JavaDoc("member can not be null");
53     }
54     if (declaringType == null) {
55       throw new IllegalArgumentException JavaDoc("declaring type can not be null");
56     }
57     m_member = member;
58     m_loaderRef = new WeakReference JavaDoc(loader);
59     m_declaringTypeName = declaringType.replace('/', '.');
60     // m_classInfoRepository = AsmClassInfoRepository.getRepository(loader);
61
}
62
63   /**
64    * Returns the name.
65    *
66    * @return the name
67    */

68   public String JavaDoc getName() {
69     return m_member.name;
70   }
71
72   /**
73    * Returns the modifiers.
74    *
75    * @return the modifiers
76    */

77   public int getModifiers() {
78     return m_member.modifiers;
79   }
80
81   /**
82    * Returns the declaring type.
83    *
84    * @return the declaring type
85    */

86   public ClassInfo getDeclaringType() {
87     if (m_declaringType == null) {
88       // m_declaringType = m_classInfoRepository.getClassInfo(m_declaringTypeName);
89
m_declaringType = AsmClassInfo.getClassInfo(m_declaringTypeName, (ClassLoader JavaDoc) m_loaderRef.get());
90     }
91     return m_declaringType;
92   }
93 }
Popular Tags