1 /***************************************************************************************
2 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package org.codehaus.aspectwerkz.reflect.impl.javassist;
9
10 import org.codehaus.aspectwerkz.annotation.instrumentation.AttributeExtractor;
11 import org.codehaus.aspectwerkz.reflect.ClassInfo;
12 import org.codehaus.aspectwerkz.reflect.MemberInfo;
13
14 import java.lang.ref.WeakReference;
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import javassist.CtMember;
19
20 /***
21 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
22 */
23 public abstract class JavassistMemberInfo implements MemberInfo {
24 /***
25 * The member.
26 */
27 protected final CtMember m_member;
28
29 /***
30 * The declaring type.
31 */
32 protected final ClassInfo m_declaringType;
33
34 /***
35 * The annotations.
36 */
37 protected List m_annotations = new ArrayList();
38
39 /***
40 * The class info repository.
41 */
42 protected final JavassistClassInfoRepository m_classInfoRepository;
43
44 /***
45 * The class loader that loaded the declaring class.
46 */
47 protected transient final WeakReference m_loaderRef;
48
49 /***
50 * The annotation extractor.
51 */
52 protected AttributeExtractor m_attributeExtractor;
53
54 /***
55 * Creates a new method meta data instance.
56 *
57 * @param member
58 * @param declaringType
59 * @param loader
60 * @param attributeExtractor
61 */
62 JavassistMemberInfo(final CtMember member,
63 final JavassistClassInfo declaringType,
64 final ClassLoader loader,
65 final AttributeExtractor attributeExtractor) {
66 if (member == null) {
67 throw new IllegalArgumentException("member can not be null");
68 }
69 if (declaringType == null) {
70 throw new IllegalArgumentException("declaring type can not be null");
71 }
72 if (loader == null) {
73 throw new IllegalArgumentException("class loader can not be null");
74 }
75 m_member = member;
76 m_declaringType = declaringType;
77 m_loaderRef = new WeakReference(loader);
78 m_classInfoRepository = JavassistClassInfoRepository.getRepository(loader);
79 m_attributeExtractor = attributeExtractor;
80 }
81
82 /***
83 * Returns the name.
84 *
85 * @return the name
86 */
87 public String getName() {
88 return m_member.getName();
89 }
90
91 /***
92 * Returns the modifiers.
93 *
94 * @return the modifiers
95 */
96 public int getModifiers() {
97 return m_member.getModifiers();
98 }
99
100 /***
101 * Returns the declaring type.
102 *
103 * @return the declaring type
104 */
105 public ClassInfo getDeclaringType() {
106 return m_declaringType;
107 }
108 }