View Javadoc

    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.transform.inlining;
    9
    10  import org.codehaus.aspectwerkz.aspect.AdviceInfo;
    11
    12  /***
    13   * Container for the advice method info.
    14   *
    15   * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
    16   * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
    17   */
    18  public class AdviceMethodInfo {
    19      private final AspectInfo m_aspectInfo;
    20      private final AdviceInfo m_adviceInfo;
    21      private int m_specialArgumentIndex = -1;//FIXME remove - should not be here
    22      private int m_joinPointIndex;//FIXME remove - should not be here
    23      private String m_calleeClassSignature;
    24      private String m_callerClassSignature;
    25      private String m_joinPointClassName;
    26      private String m_calleeMemberDesc;
    27
    28      public AdviceMethodInfo(final AdviceInfo adviceInfo,
    29                              final String aspectFieldName,
    30                              final String aspectClassName,
    31                              final String aspectClassSignature,
    32                              final String callerClassSignature,
    33                              final String calleeClassSignature,
    34                              final String joinPointClassName,
    35                              final String calleeMemberDesc) {
    36          m_adviceInfo = adviceInfo;
    37          m_aspectInfo = new AspectInfo(
    38                  adviceInfo.getAdviceDefinition().getAspectDefinition(),
    39                  aspectFieldName, aspectClassName, aspectClassSignature
    40          );
    41          m_callerClassSignature = callerClassSignature;
    42          m_calleeClassSignature = calleeClassSignature;
    43          m_joinPointClassName = joinPointClassName;
    44          m_calleeMemberDesc = calleeMemberDesc;
    45      }
    46
    47      public AdviceInfo getAdviceInfo() {
    48          return m_adviceInfo;
    49      }
    50
    51      public AspectInfo getAspectInfo() {
    52          return m_aspectInfo;
    53      }
    54
    55      public int[] getAdviceMethodArgIndexes() {
    56          return m_adviceInfo.getMethodToArgIndexes();
    57      }
    58
    59      public String getSpecialArgumentTypeDesc() {
    60          return m_adviceInfo.getSpecialArgumentTypeDesc();
    61      }
    62
    63      public String getSpecialArgumentTypeName() {
    64          return m_adviceInfo.getSpecialArgumentTypeName();
    65      }
    66
    67      public int getJoinPointIndex() {
    68          return m_joinPointIndex;
    69      }
    70
    71      public void setJoinPointIndex(final int joinPointIndex) {
    72          m_joinPointIndex = joinPointIndex;
    73      }
    74
    75      public int getSpecialArgumentIndex() {
    76          return m_specialArgumentIndex;
    77      }
    78
    79      public void setSpecialArgumentIndex(final int index) {
    80          m_specialArgumentIndex = index;
    81      }
    82
    83      public String getCalleeClassSignature() {
    84          return m_calleeClassSignature;
    85      }
    86
    87      public String getCallerClassSignature() {
    88          return m_callerClassSignature;
    89      }
    90
    91      public String getJoinPointClassName() {
    92          return m_joinPointClassName;
    93      }
    94
    95      public String getCalleeMemberDesc() {
    96          return m_calleeMemberDesc;
    97      }
    98
    99      /***
    100      * @return true if the advice uses this or target (bounded or runtime check)
    101      */
    102     public boolean requiresThisOrTarget() {
    103         if (m_adviceInfo.hasTargetWithRuntimeCheck()) {
    104             return true;
    105         } else {
    106             // look for TARGET or THIS bindings
    107             for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
    108                 int index = m_adviceInfo.getMethodToArgIndexes()[i];
    109                 if (index == AdviceInfo.TARGET_ARG ||
    110                     index == AdviceInfo.THIS_ARG) {
    111                     return true;
    112                 }
    113             }
    114         }
    115         return false;
    116     }
    117
    118     /***
    119      * @return true if the advice uses non static JoinPoint explicitly
    120      */
    121     public boolean requiresJoinPoint() {
    122         // look for JoinPoint
    123         for (int i = 0; i < m_adviceInfo.getMethodToArgIndexes().length; i++) {
    124             int index = m_adviceInfo.getMethodToArgIndexes()[i];
    125             if (index == AdviceInfo.JOINPOINT_ARG) {
    126                 return true;
    127             }
    128         }
    129         return false;
    130     }
    131
    132 }