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.reflect.impl.asm;
05:
06: import com.tc.aspectwerkz.reflect.MemberInfo;
07: import com.tc.aspectwerkz.reflect.ClassInfo;
08:
09: import java.lang.ref.WeakReference;
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 m_loaderRef;
27:
28: /**
29: * The declaring type name.
30: */
31: protected final String 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: * Creates a new member meta data instance.
44: *
45: * @param member
46: * @param declaringType
47: * @param loader
48: */
49: AsmMemberInfo(final MemberStruct member,
50: final String declaringType, final ClassLoader loader) {
51: if (member == null) {
52: throw new IllegalArgumentException("member can not be null");
53: }
54: if (declaringType == null) {
55: throw new IllegalArgumentException(
56: "declaring type can not be null");
57: }
58: m_member = member;
59: m_loaderRef = new WeakReference(loader);
60: m_declaringTypeName = declaringType.replace('/', '.');
61: // m_classInfoRepository = AsmClassInfoRepository.getRepository(loader);
62: }
63:
64: /**
65: * Returns the name.
66: *
67: * @return the name
68: */
69: public String getName() {
70: return m_member.name;
71: }
72:
73: /**
74: * Returns the modifiers.
75: *
76: * @return the modifiers
77: */
78: public int getModifiers() {
79: return m_member.modifiers;
80: }
81:
82: /**
83: * Returns the declaring type.
84: *
85: * @return the declaring type
86: */
87: public ClassInfo getDeclaringType() {
88: if (m_declaringType == null) {
89: // m_declaringType = m_classInfoRepository.getClassInfo(m_declaringTypeName);
90: m_declaringType = AsmClassInfo.getClassInfo(
91: m_declaringTypeName, (ClassLoader) m_loaderRef
92: .get());
93: }
94: return m_declaringType;
95: }
96: }
|