Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut$State


    }
  }

  private void validateOrBranch(OrPointcut pc, Pointcut userPointcut, int numFormals, String[] names, Pointcut[] leftBindings,
      Pointcut[] rightBindings) {
    Pointcut left = pc.getLeft();
    Pointcut right = pc.getRight();
    if (left instanceof OrPointcut) {
      Pointcut[] newRightBindings = new Pointcut[numFormals];
      validateOrBranch((OrPointcut) left, userPointcut, numFormals, names, leftBindings, newRightBindings);
    } else {
      if (left.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS) {
        validateSingleBranch(left, userPointcut, numFormals, names, leftBindings);
      }
    }
    if (right instanceof OrPointcut) {
      Pointcut[] newLeftBindings = new Pointcut[numFormals];
      validateOrBranch((OrPointcut) right, userPointcut, numFormals, names, newLeftBindings, rightBindings);
    } else {
      if (right.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS) {
        validateSingleBranch(right, userPointcut, numFormals, names, rightBindings);
      }
    }
    int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds();
    if (kindsInCommon != Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left, right)) {
      // we know that every branch binds every formal, so there is no
      // ambiguity
      // if each branch binds it in exactly the same way...
      List<String> ambiguousNames = new ArrayList<String>();
View Full Code Here


    if (toLookFor.isInstance(toSearch)) {
      return toSearch;
    }
    if (toSearch instanceof AndPointcut) {
      AndPointcut apc = (AndPointcut) toSearch;
      Pointcut left = findFirstPointcutIn(apc.getLeft(), toLookFor);
      if (left != null) {
        return left;
      }
      return findFirstPointcutIn(apc.getRight(), toLookFor);
    }
View Full Code Here

          ResolvedType declaringAspect = munger.getDeclaringType();
          if (typeWeaverState.isAspectAlreadyApplied(declaringAspect)) {
            continue;
          }
        }
        Pointcut pointcut = munger.getPointcut();
        long starttime = System.nanoTime();
        FuzzyBoolean fb = pointcut.fastMatch(info);
        long endtime = System.nanoTime();
        world.recordFastMatch(pointcut, endtime - starttime);
        if (fb.maybeTrue()) {
          result.add(munger);
        }
      }
    } else {
      for (ShadowMunger munger : list) {
        if (typeWeaverState != null) { // will only be null if overweaving is ON and there is weaverstate
          ResolvedType declaringAspect = munger.getConcreteAspect();// getDeclaringType();
          if (typeWeaverState.isAspectAlreadyApplied(declaringAspect)) {
            continue;
          }
        }
        Pointcut pointcut = munger.getPointcut();
        FuzzyBoolean fb = pointcut.fastMatch(info);
        if (fb.maybeTrue()) {
          result.add(munger);
        }
      }
    }
View Full Code Here

      IProgramElement containingAspect, ResolvedMember[] pointcuts) {
    for (int i = 0; i < pointcuts.length; i++) {
      ResolvedMember pointcut = pointcuts[i];
      if (pointcut instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pointcut;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        ISourceLocation pointcutLocation = (sLoc == null ? null : createSourceLocation(sourcefilename, aspect, sLoc));
        ProgramElement pointcutElement = new ProgramElement(model, pointcut.getName(), IProgramElement.Kind.POINTCUT,
View Full Code Here

  private static void addChildNodes(AsmManager asm, ResolvedType aspect, IProgramElement parent, ResolvedMember[] children) {
    for (int i = 0; i < children.length; i++) {
      ResolvedMember pcd = children[i];
      if (pcd instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pcd;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        parent.addChild(new ProgramElement(asm, pcd.getName(), IProgramElement.Kind.POINTCUT, getBinarySourceLocation(
            aspect, sLoc), pcd.getModifiers(), null, Collections.EMPTY_LIST));
View Full Code Here

        for (Iterator it = attributes.iterator(); it.hasNext();) {
            AjAttribute attr = (AjAttribute) it.next();
            if (attr instanceof AjAttribute.PointcutDeclarationAttribute) {
                AjAttribute.PointcutDeclarationAttribute pcAttr = (AjAttribute.PointcutDeclarationAttribute) attr;
                Pointcut pointcut = pcAttr.reify().getPointcut();
                if (pointcut instanceof KindedPointcut) {
                    try {
                        Field sigField = KindedPointcut.class.getDeclaredField("signature");
                        sigField.setAccessible(true);
                        SignaturePattern signature = (SignaturePattern) sigField.get(pointcut);
                        DefinitionParserHelper.createAndAddPointcutDefToAspectDef(
                                signature.getName().toString(), pointcut.toString(), aspectDef
                        );
                    } catch (Exception e) {
                        throw new WrappedRuntimeException(e);
                    }
                }
View Full Code Here

       
       
        i = str.indexOf(':', i);       
        start = ++i;       
        i = str.indexOf("->", i);
        Pointcut pointcut = Pointcut.fromString(str.substring(start, i).trim());
        Member m = MemberImpl.methodFromString(str.substring(i+2, str.length()).trim());

        // now, we resolve
        UnresolvedType[] types = m.getParameterTypes();
        FormalBinding[] bindings = new FormalBinding[ids.length];
        for (int j = 0, len = ids.length; j < len; j++) {
            bindings[j] = new FormalBinding(types[j], ids[j], j, 0, 0, "fromString");
        }

        Pointcut p =
          pointcut.resolve(new SimpleScope(this, bindings));

        return new BcelAdvice(kind, p, m, extraFlag, 0, 0, null, null);
    }
View Full Code Here

     */
    private void rewritePointcuts(List/*ShadowMunger*/ shadowMungers) {
      PointcutRewriter rewriter = new PointcutRewriter();
      for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      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[];
                    //ATAJ for @AJ aspect, the formal have to be checked according to the argument number
                    // since xxxJoinPoint presence or not have side effects
                    if (advice.getConcreteAspect().isAnnotationStyleAspect()) {
                        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);
                        }
                    }
        }
      }
      munger.setPointcut(newP);
    }
      // now that we have optimized individual pointcuts, optimize
      // across the set of pointcuts....
      // Use a map from key based on pc equality, to value based on
      // pc identity.
      Map/*<Pointcut,Pointcut>*/ pcMap = new HashMap();
      for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      munger.setPointcut(shareEntriesFromMap(p,pcMap));
    }     
    }
View Full Code Here

      if (p instanceof NameBindingPointcut) return p;
      if (p instanceof IfPointcut) return p;
      if (p instanceof ConcreteCflowPointcut) return p;
      if (p instanceof AndPointcut) {
        AndPointcut apc = (AndPointcut) p;
        Pointcut left = shareEntriesFromMap(apc.getLeft(),pcMap);
        Pointcut right = shareEntriesFromMap(apc.getRight(),pcMap);
        return new AndPointcut(left,right);
      } else if (p instanceof OrPointcut) {
        OrPointcut opc = (OrPointcut) p;
        Pointcut left = shareEntriesFromMap(opc.getLeft(),pcMap);
        Pointcut right = shareEntriesFromMap(opc.getRight(),pcMap);
        return new OrPointcut(left,right);
      } else if (p instanceof NotPointcut) {
        NotPointcut npc = (NotPointcut) p;
        Pointcut not = shareEntriesFromMap(npc.getNegatedPointcut(),pcMap);
        return new NotPointcut(not);
      } else {
        // primitive pcd
        if (pcMap.containsKey(p)) { // based on equality
          return (Pointcut) pcMap.get(p)// same instance (identity)
View Full Code Here

      }
    }
   
    private void validateOrBranch(OrPointcut pc, Pointcut userPointcut, int numFormals,
        String[] names, Pointcut[] leftBindings, Pointcut[] rightBindings) {
      Pointcut left = pc.getLeft();
      Pointcut right = pc.getRight();
      if (left instanceof OrPointcut) {
        Pointcut[] newRightBindings = new Pointcut[numFormals];
        validateOrBranch((OrPointcut)left,userPointcut,numFormals,names,leftBindings,newRightBindings);       
      } else {
        if (left.couldMatchKinds().size() > 0)
          validateSingleBranch(left, userPointcut, numFormals, names, leftBindings);
      }
      if (right instanceof OrPointcut) {
        Pointcut[] newLeftBindings = new Pointcut[numFormals];
        validateOrBranch((OrPointcut)right,userPointcut,numFormals,names,newLeftBindings,rightBindings);
      } else {
        if (right.couldMatchKinds().size() > 0)
          validateSingleBranch(right, userPointcut, numFormals, names, rightBindings);       
      }
    Set kindsInCommon = left.couldMatchKinds();
    kindsInCommon.retainAll(right.couldMatchKinds());
    if (!kindsInCommon.isEmpty() && couldEverMatchSameJoinPoints(left,right)) {
      // we know that every branch binds every formal, so there is no ambiguity
      // if each branch binds it in exactly the same way...
      List ambiguousNames = new ArrayList();
      for (int i = 0; i < numFormals; i++) {
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.Pointcut$State

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.