001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package org.codehaus.aspectwerkz.transform.inlining;
008:
009: import org.codehaus.aspectwerkz.aspect.AdviceInfo;
010:
011: /**
012: * Container for the advice method info.
013: *
014: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
015: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
016: */
017: public class AdviceMethodInfo {
018: private final AspectInfo m_aspectInfo;
019: private final AdviceInfo m_adviceInfo;
020: private int m_specialArgumentIndex = -1;//FIXME remove - should not be here
021: private int m_joinPointIndex;//FIXME remove - should not be here
022: private String m_calleeClassSignature;
023: private String m_callerClassSignature;
024: private String m_joinPointClassName;
025: private String m_calleeMemberDesc;
026:
027: public AdviceMethodInfo(final AdviceInfo adviceInfo,
028: final String aspectFieldName, final String aspectClassName,
029: final String aspectClassSignature,
030: final String callerClassSignature,
031: final String calleeClassSignature,
032: final String joinPointClassName,
033: final String calleeMemberDesc) {
034: m_adviceInfo = adviceInfo;
035: m_aspectInfo = new AspectInfo(adviceInfo.getAdviceDefinition()
036: .getAspectDefinition(), aspectFieldName,
037: aspectClassName, aspectClassSignature);
038: m_callerClassSignature = callerClassSignature;
039: m_calleeClassSignature = calleeClassSignature;
040: m_joinPointClassName = joinPointClassName;
041: m_calleeMemberDesc = calleeMemberDesc;
042: }
043:
044: public AdviceInfo getAdviceInfo() {
045: return m_adviceInfo;
046: }
047:
048: public AspectInfo getAspectInfo() {
049: return m_aspectInfo;
050: }
051:
052: public int[] getAdviceMethodArgIndexes() {
053: return m_adviceInfo.getMethodToArgIndexes();
054: }
055:
056: public String getSpecialArgumentTypeDesc() {
057: return m_adviceInfo.getSpecialArgumentTypeDesc();
058: }
059:
060: public String getSpecialArgumentTypeName() {
061: return m_adviceInfo.getSpecialArgumentTypeName();
062: }
063:
064: public int getJoinPointIndex() {
065: return m_joinPointIndex;
066: }
067:
068: public void setJoinPointIndex(final int joinPointIndex) {
069: m_joinPointIndex = joinPointIndex;
070: }
071:
072: public int getSpecialArgumentIndex() {
073: return m_specialArgumentIndex;
074: }
075:
076: public void setSpecialArgumentIndex(final int index) {
077: m_specialArgumentIndex = index;
078: }
079:
080: public String getCalleeClassSignature() {
081: return m_calleeClassSignature;
082: }
083:
084: public String getCallerClassSignature() {
085: return m_callerClassSignature;
086: }
087:
088: public String getJoinPointClassName() {
089: return m_joinPointClassName;
090: }
091:
092: public String getCalleeMemberDesc() {
093: return m_calleeMemberDesc;
094: }
095:
096: /**
097: * @return true if the advice uses this or target (bounded or runtime check)
098: */
099: public boolean requiresThisOrTarget() {
100: if (m_adviceInfo.hasTargetWithRuntimeCheck()) {
101: return true;
102: } else {
103: // look for TARGET or THIS bindings
104: for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
105: int index = m_adviceInfo.getMethodToArgIndexes()[i];
106: if (index == AdviceInfo.TARGET_ARG
107: || index == AdviceInfo.THIS_ARG) {
108: return true;
109: }
110: }
111: }
112: return false;
113: }
114:
115: /**
116: * @return true if the advice uses non static JoinPoint explicitly
117: */
118: public boolean requiresJoinPoint() {
119: // look for JoinPoint
120: for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
121: int index = m_adviceInfo.getMethodToArgIndexes()[i];
122: if (index == AdviceInfo.JOINPOINT_ARG) {
123: return true;
124: }
125: }
126: return false;
127: }
128:
129: }
|