Package org.aspectj.weaver

Examples of org.aspectj.weaver.Advice


      Pointcut newP = rewriter.rewrite(p);
      // validateBindings now whilst we still have around the pointcut
      // that resembles what the user actually wrote in their program
      // text.
      if (munger instanceof Advice) {
        Advice advice = (Advice) munger;
        if (advice.getSignature() != null) {
          final int numFormals;
          final String names[];
          // If the advice is being concretized in a @AJ aspect *and*
          // the advice was declared in
          // an @AJ aspect (it could have been inherited from a code
          // style aspect) then
          // evaluate the alternative set of formals. pr125699
          if ((advice.getConcreteAspect().isAnnotationStyleAspect() && advice.getDeclaringAspect() != null && advice
              .getDeclaringAspect().resolve(world).isAnnotationStyleAspect())
              || advice.isAnnotationStyle()) {
            numFormals = advice.getBaseParameterCount();
            int numArgs = advice.getSignature().getParameterTypes().length;
            if (numFormals > 0) {
              names = advice.getSignature().getParameterNames(world);
              validateBindings(newP, p, numArgs, names);
            }
          } else {
            numFormals = advice.getBaseParameterCount();
            if (numFormals > 0) {
              names = advice.getBaseParameterNames(world);
              validateBindings(newP, p, numFormals, names);
            }
          }
        }
      }
View Full Code Here


        } else {
          counter = dwCtr++;
        }
        parent.addChild(createDeclareErrorOrWarningChild(asm, aspect, decl, counter));
      } else if (element instanceof Advice) {
        Advice advice = (Advice) element;
        parent.addChild(createAdviceChild(asm, advice));
      } else if (element instanceof DeclareParents) {
        parent.addChild(createDeclareParentsChild(asm, (DeclareParents) element));
      } else if (element instanceof BcelTypeMunger) {
        IProgramElement newChild = createIntertypeDeclaredChild(asm, aspect, (BcelTypeMunger) element);
View Full Code Here

    if (model == null) {
      return;
    }

    if (munger instanceof Advice) {
      Advice advice = (Advice) munger;

      if (advice.getKind().isPerEntry() || advice.getKind().isCflow()) {
        // TODO: might want to show these in the future
        return;
      }

      if (World.createInjarHierarchy) {
        createHierarchyForBinaryAspect(model, advice);
      }

      IRelationshipMap mapper = model.getRelationshipMap();
      IProgramElement targetNode = getNode(model, matchedShadow);
      if (targetNode == null) {
        return;
      }
      boolean runtimeTest = advice.hasDynamicTests();

      IProgramElement.ExtraInformation extra = new IProgramElement.ExtraInformation();

      String adviceHandle = getHandle(model, advice);
      if (adviceHandle == null) {
        return;
      }

      extra.setExtraAdviceInformation(advice.getKind().getName());
      IProgramElement adviceElement = model.getHierarchy().findElementForHandle(adviceHandle);
      if (adviceElement != null) {
        adviceElement.setExtraInfo(extra);
      }
      String targetHandle = targetNode.getHandleIdentifier();
      if (advice.getKind().equals(AdviceKind.Softener)) {
        IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.DECLARE_SOFT, SOFTENS, runtimeTest, true);
        if (foreward != null) {
          foreward.addTarget(targetHandle);
        }
View Full Code Here

  /*
   * Report a message about the advice weave that has occurred. Some messing about to make it pretty ! This code is just asking
   * for an NPE to occur ...
   */
  private void reportWeavingMessage(ShadowMunger munger, Shadow shadow) {
    Advice advice = (Advice) munger;
    AdviceKind aKind = advice.getKind();
    // Only report on interesting advice kinds ...
    if (aKind == null || advice.getConcreteAspect() == null) {
      // We suspect someone is programmatically driving the weaver
      // (e.g. IdWeaveTestCase in the weaver testcases)
      return;
    }
    if (!(aKind.equals(AdviceKind.Before) || aKind.equals(AdviceKind.After) || aKind.equals(AdviceKind.AfterReturning)
        || aKind.equals(AdviceKind.AfterThrowing) || aKind.equals(AdviceKind.Around) || aKind.equals(AdviceKind.Softener))) {
      return;
    }

    // synchronized blocks are implemented with multiple monitor_exit instructions in the bytecode
    // (one for normal exit from the method, one for abnormal exit), we only want to tell the user
    // once we have advised the end of the sync block, even though under the covers we will have
    // woven both exit points
    if (shadow.getKind() == Shadow.SynchronizationUnlock) {
      if (advice.lastReportedMonitorExitJoinpointLocation == null) {
        // this is the first time through, let's continue...
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      } else {
        if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) {
          // Don't report it again!
          advice.lastReportedMonitorExitJoinpointLocation = null;
          return;
        }
        // hmmm, this means some kind of nesting is going on, urgh
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      }
    }

    String description = advice.getKind().toString();
    String advisedType = shadow.getEnclosingType().getName();
    String advisingType = advice.getConcreteAspect().getName();
    Message msg = null;
    if (advice.getKind().equals(AdviceKind.Softener)) {
      msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType,
          beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) },
          advisedType, advisingType);
    } else {
      boolean runtimeTest = advice.hasDynamicTests();
      String joinPointDescription = shadow.toString();
      msg = WeaveMessage
          .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES,
              new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()),
                  description, advisingType, beautifyLocation(munger.getSourceLocation()),
View Full Code Here

  /*
   * Report a message about the advice weave that has occurred. Some messing about to make it pretty ! This code is just asking
   * for an NPE to occur ...
   */
  private void reportWeavingMessage(ShadowMunger munger, Shadow shadow) {
    Advice advice = (Advice) munger;
    AdviceKind aKind = advice.getKind();
    // Only report on interesting advice kinds ...
    if (aKind == null || advice.getConcreteAspect() == null) {
      // We suspect someone is programmatically driving the weaver
      // (e.g. IdWeaveTestCase in the weaver testcases)
      return;
    }
    if (!(aKind.equals(AdviceKind.Before) || aKind.equals(AdviceKind.After) || aKind.equals(AdviceKind.AfterReturning)
        || aKind.equals(AdviceKind.AfterThrowing) || aKind.equals(AdviceKind.Around) || aKind.equals(AdviceKind.Softener))) {
      return;
    }

    // synchronized blocks are implemented with multiple monitor_exit instructions in the bytecode
    // (one for normal exit from the method, one for abnormal exit), we only want to tell the user
    // once we have advised the end of the sync block, even though under the covers we will have
    // woven both exit points
    if (shadow.getKind() == Shadow.SynchronizationUnlock) {
      if (advice.lastReportedMonitorExitJoinpointLocation == null) {
        // this is the first time through, let's continue...
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      } else {
        if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) {
          // Don't report it again!
          advice.lastReportedMonitorExitJoinpointLocation = null;
          return;
        }
        // hmmm, this means some kind of nesting is going on, urgh
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      }
    }

    String description = advice.getKind().toString();
    String advisedType = shadow.getEnclosingType().getName();
    String advisingType = advice.getConcreteAspect().getName();
    Message msg = null;
    if (advice.getKind().equals(AdviceKind.Softener)) {
      msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType,
          beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) },
          advisedType, advisingType);
    } else {
      boolean runtimeTest = advice.hasDynamicTests();
      String joinPointDescription = shadow.toString();
      msg = WeaveMessage
          .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES,
              new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()),
                  description, advisingType, beautifyLocation(munger.getSourceLocation()),
View Full Code Here

      Pointcut newP = rewriter.rewrite(p);
      // validateBindings now whilst we still have around the pointcut
      // that resembles what the user actually wrote in their program
      // text.
      if (munger instanceof Advice) {
        Advice advice = (Advice) munger;
        if (advice.getSignature() != null) {
          final int numFormals;
          final String names[];
          // If the advice is being concretized in a @AJ aspect *and*
          // the advice was declared in
          // an @AJ aspect (it could have been inherited from a code
          // style aspect) then
          // evaluate the alternative set of formals. pr125699
          if ((advice.getConcreteAspect().isAnnotationStyleAspect() && advice.getDeclaringAspect() != null && advice
              .getDeclaringAspect().resolve(world).isAnnotationStyleAspect())
              || advice.isAnnotationStyle()) {
            numFormals = advice.getBaseParameterCount();
            int numArgs = advice.getSignature().getParameterTypes().length;
            if (numFormals > 0) {
              names = advice.getSignature().getParameterNames(world);
              validateBindings(newP, p, numArgs, names);
            }
          } else {
            numFormals = advice.getBaseParameterCount();
            if (numFormals > 0) {
              names = advice.getBaseParameterNames(world);
              validateBindings(newP, p, numFormals, names);
            }
          }
        }
      }
View Full Code Here

        } else {
          counter = dwCtr++;
        }
        parent.addChild(createDeclareErrorOrWarningChild(asm, aspect, decl, counter));
      } else if (element instanceof Advice) {
        Advice advice = (Advice) element;
        parent.addChild(createAdviceChild(asm, advice));
      } else if (element instanceof DeclareParents) {
        parent.addChild(createDeclareParentsChild(asm, (DeclareParents) element));
      } else if (element instanceof BcelTypeMunger) {
        IProgramElement newChild = createIntertypeDeclaredChild(asm, aspect, (BcelTypeMunger) element);
View Full Code Here

    if (model == null) {
      return;
    }

    if (munger instanceof Advice) {
      Advice advice = (Advice) munger;

      if (advice.getKind().isPerEntry() || advice.getKind().isCflow()) {
        // TODO: might want to show these in the future
        return;
      }

      if (World.createInjarHierarchy) {
        createHierarchyForBinaryAspect(model, advice);
      }

      IRelationshipMap mapper = model.getRelationshipMap();
      IProgramElement targetNode = getNode(model, matchedShadow);
      if (targetNode == null) {
        return;
      }
      boolean runtimeTest = advice.hasDynamicTests();

      IProgramElement.ExtraInformation extra = new IProgramElement.ExtraInformation();

      String adviceHandle = getHandle(model, advice);
      if (adviceHandle == null) {
        return;
      }

      extra.setExtraAdviceInformation(advice.getKind().getName());
      IProgramElement adviceElement = model.getHierarchy().findElementForHandle(adviceHandle);
      if (adviceElement != null) {
        adviceElement.setExtraInfo(extra);
      }
      String targetHandle = targetNode.getHandleIdentifier();
      if (advice.getKind().equals(AdviceKind.Softener)) {
        IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.DECLARE_SOFT, SOFTENS, runtimeTest, true);
        if (foreward != null) {
          foreward.addTarget(targetHandle);
        }
View Full Code Here

      Pointcut newP = rewriter.rewrite(p);
      // validateBindings now whilst we still have around the pointcut
      // that resembles what the user actually wrote in their program
      // text.
      if (munger instanceof Advice) {
        Advice advice = (Advice) munger;
        if (advice.getSignature() != null) {
          final int numFormals;
          final String names[];
          // If the advice is being concretized in a @AJ aspect *and*
          // the advice was declared in
          // an @AJ aspect (it could have been inherited from a code
          // style aspect) then
          // evaluate the alternative set of formals. pr125699
          if ((advice.getConcreteAspect().isAnnotationStyleAspect() && advice.getDeclaringAspect() != null && advice
              .getDeclaringAspect().resolve(world).isAnnotationStyleAspect())
              || advice.isAnnotationStyle()) {
            numFormals = advice.getBaseParameterCount();
            int numArgs = advice.getSignature().getParameterTypes().length;
            if (numFormals > 0) {
              names = advice.getSignature().getParameterNames(world);
              validateBindings(newP, p, numArgs, names);
            }
          } else {
            numFormals = advice.getBaseParameterCount();
            if (numFormals > 0) {
              names = advice.getBaseParameterNames(world);
              validateBindings(newP, p, numFormals, names);
            }
          }
        }
      }
View Full Code Here

  /*
   * Report a message about the advice weave that has occurred. Some messing about to make it pretty ! This code is just asking
   * for an NPE to occur ...
   */
  private void reportWeavingMessage(ShadowMunger munger, Shadow shadow) {
    Advice advice = (Advice) munger;
    AdviceKind aKind = advice.getKind();
    // Only report on interesting advice kinds ...
    if (aKind == null || advice.getConcreteAspect() == null) {
      // We suspect someone is programmatically driving the weaver
      // (e.g. IdWeaveTestCase in the weaver testcases)
      return;
    }
    if (!(aKind.equals(AdviceKind.Before) || aKind.equals(AdviceKind.After) || aKind.equals(AdviceKind.AfterReturning)
        || aKind.equals(AdviceKind.AfterThrowing) || aKind.equals(AdviceKind.Around) || aKind.equals(AdviceKind.Softener))) {
      return;
    }

    // synchronized blocks are implemented with multiple monitor_exit instructions in the bytecode
    // (one for normal exit from the method, one for abnormal exit), we only want to tell the user
    // once we have advised the end of the sync block, even though under the covers we will have
    // woven both exit points
    if (shadow.getKind() == Shadow.SynchronizationUnlock) {
      if (advice.lastReportedMonitorExitJoinpointLocation == null) {
        // this is the first time through, let's continue...
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      } else {
        if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) {
          // Don't report it again!
          advice.lastReportedMonitorExitJoinpointLocation = null;
          return;
        }
        // hmmm, this means some kind of nesting is going on, urgh
        advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation();
      }
    }

    String description = advice.getKind().toString();
    String advisedType = shadow.getEnclosingType().getName();
    String advisingType = advice.getConcreteAspect().getName();
    Message msg = null;
    if (advice.getKind().equals(AdviceKind.Softener)) {
      msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType,
          beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) },
          advisedType, advisingType);
    } else {
      boolean runtimeTest = advice.hasDynamicTests();
      String joinPointDescription = shadow.toString();
      msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES, new String[] { joinPointDescription,
          advisedType, beautifyLocation(shadow.getSourceLocation()), description, advisingType,
          beautifyLocation(munger.getSourceLocation()), (runtimeTest ? " [with runtime test]" : "") }, advisedType,
          advisingType);
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.Advice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.