001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.aspectwerkz.transform.inlining;
005:
006: import com.tc.aspectwerkz.aspect.AdviceInfo;
007:
008: /**
009: * Container for the advice method info.
010: *
011: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
012: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
013: */
014: public class AdviceMethodInfo {
015: private final AspectInfo m_aspectInfo;
016: private final AdviceInfo m_adviceInfo;
017: private int m_specialArgumentIndex = -1;
018: private String m_calleeClassSignature;
019: private String m_callerClassSignature;
020: private String m_joinPointClassName;
021: private String m_calleeMemberDesc;
022:
023: public AdviceMethodInfo(final AspectInfo aspectInfo,
024: final AdviceInfo adviceInfo,
025: final String callerClassSignature,
026: final String calleeClassSignature,
027: final String joinPointClassName,
028: final String calleeMemberDesc) {
029: m_aspectInfo = aspectInfo;
030: m_adviceInfo = adviceInfo;
031: m_callerClassSignature = callerClassSignature;
032: m_calleeClassSignature = calleeClassSignature;
033: m_joinPointClassName = joinPointClassName;
034: m_calleeMemberDesc = calleeMemberDesc;
035: }
036:
037: public AdviceInfo getAdviceInfo() {
038: return m_adviceInfo;
039: }
040:
041: public AspectInfo getAspectInfo() {
042: return m_aspectInfo;
043: }
044:
045: public int[] getAdviceMethodArgIndexes() {
046: return m_adviceInfo.getMethodToArgIndexes();
047: }
048:
049: public String getSpecialArgumentTypeDesc() {
050: return m_adviceInfo.getSpecialArgumentTypeDesc();
051: }
052:
053: public String getSpecialArgumentTypeName() {
054: return m_adviceInfo.getSpecialArgumentTypeName();
055: }
056:
057: public int getSpecialArgumentIndex() {
058: return m_specialArgumentIndex;
059: }
060:
061: public void setSpecialArgumentIndex(final int index) {
062: m_specialArgumentIndex = index;
063: }
064:
065: public String getCalleeClassSignature() {
066: return m_calleeClassSignature;
067: }
068:
069: public String getCallerClassSignature() {
070: return m_callerClassSignature;
071: }
072:
073: public String getJoinPointClassName() {
074: return m_joinPointClassName;
075: }
076:
077: public String getCalleeMemberDesc() {
078: return m_calleeMemberDesc;
079: }
080:
081: /**
082: * @return true if the advice uses this or target (bounded or runtime check)
083: */
084: public boolean requiresThisOrTarget() {
085: if (m_adviceInfo.hasTargetWithRuntimeCheck()) {
086: return true;
087: } else {
088: // look for TARGET or THIS bindings
089: for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
090: int index = m_adviceInfo.getMethodToArgIndexes()[i];
091: if (index == AdviceInfo.TARGET_ARG
092: || index == AdviceInfo.THIS_ARG) {
093: return true;
094: }
095: }
096: }
097: return false;
098: }
099:
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: }
|