KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > transform > inlining > AdviceMethodInfo


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;
5
6 import com.tc.aspectwerkz.aspect.AdviceInfo;
7
8 /**
9  * Container for the advice method info.
10  *
11  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
12  * @author <a HREF="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
13  */

14 public class AdviceMethodInfo {
15   private final AspectInfo m_aspectInfo;
16   private final AdviceInfo m_adviceInfo;
17   private int m_specialArgumentIndex = -1;
18   private String JavaDoc m_calleeClassSignature;
19   private String JavaDoc m_callerClassSignature;
20   private String JavaDoc m_joinPointClassName;
21   private String JavaDoc m_calleeMemberDesc;
22
23   public AdviceMethodInfo(final AspectInfo aspectInfo,
24                           final AdviceInfo adviceInfo,
25                           final String JavaDoc callerClassSignature,
26                           final String JavaDoc calleeClassSignature,
27                           final String JavaDoc joinPointClassName,
28                           final String JavaDoc calleeMemberDesc) {
29     m_aspectInfo = aspectInfo;
30     m_adviceInfo = adviceInfo;
31     m_callerClassSignature = callerClassSignature;
32     m_calleeClassSignature = calleeClassSignature;
33     m_joinPointClassName = joinPointClassName;
34     m_calleeMemberDesc = calleeMemberDesc;
35   }
36
37   public AdviceInfo getAdviceInfo() {
38     return m_adviceInfo;
39   }
40
41   public AspectInfo getAspectInfo() {
42     return m_aspectInfo;
43   }
44
45   public int[] getAdviceMethodArgIndexes() {
46     return m_adviceInfo.getMethodToArgIndexes();
47   }
48
49   public String JavaDoc getSpecialArgumentTypeDesc() {
50     return m_adviceInfo.getSpecialArgumentTypeDesc();
51   }
52
53   public String JavaDoc getSpecialArgumentTypeName() {
54     return m_adviceInfo.getSpecialArgumentTypeName();
55   }
56
57   public int getSpecialArgumentIndex() {
58     return m_specialArgumentIndex;
59   }
60
61   public void setSpecialArgumentIndex(final int index) {
62     m_specialArgumentIndex = index;
63   }
64
65   public String JavaDoc getCalleeClassSignature() {
66     return m_calleeClassSignature;
67   }
68
69   public String JavaDoc getCallerClassSignature() {
70     return m_callerClassSignature;
71   }
72
73   public String JavaDoc getJoinPointClassName() {
74     return m_joinPointClassName;
75   }
76
77   public String JavaDoc getCalleeMemberDesc() {
78     return m_calleeMemberDesc;
79   }
80
81   /**
82    * @return true if the advice uses this or target (bounded or runtime check)
83    */

84   public boolean requiresThisOrTarget() {
85     if (m_adviceInfo.hasTargetWithRuntimeCheck()) {
86       return true;
87     } else {
88       // look for TARGET or THIS bindings
89
for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
90         int index = m_adviceInfo.getMethodToArgIndexes()[i];
91         if (index == AdviceInfo.TARGET_ARG ||
92                 index == AdviceInfo.THIS_ARG) {
93           return true;
94         }
95       }
96     }
97     return false;
98   }
99
100   /**
101    * @return true if the advice uses non static JoinPoint explicitly
102    */

103   public boolean requiresJoinPoint() {
104     // look for JoinPoint
105
for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
106       int index = m_adviceInfo.getMethodToArgIndexes()[i];
107       if (index == AdviceInfo.JOINPOINT_ARG) {
108         return true;
109       }
110     }
111     return false;
112   }
113
114 }
115
Popular Tags