Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut


   * @param struct for which we are parsing the per clause
   * @return a PerClause instance
   */
  private static PerClause parsePerClausePointcut(String perClauseString, AjAttributeStruct struct) {
    final String pointcutString;
    Pointcut pointcut = null;
    TypePattern typePattern = null;
    final PerClause perClause;
    if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
View Full Code Here


        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
          // pc.resolve(binding);
        } else {
          pc = parsePointcut(beforeAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc = pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here

        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
        } else {
          pc = parsePointcut(afterAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here

      // return binding
      if (returned != null) {
        extraArgument |= Advice.ExtraArgument;
      }

      Pointcut pc = null;
      if (preResolvedPointcut != null) {
        pc = preResolvedPointcut.getPointcut();
      } else {
        pc = parsePointcut(pointcut, struct, false);
        if (pc == null) {
          return false;// parse error
        }
        pc.resolve(binding);
      }
      setIgnoreUnboundBindingNames(pc, bindings);

      ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
          struct.bMethod.getDeclarationOffset());
View Full Code Here

      // return binding
      if (thrownFormal != null) {
        extraArgument |= Advice.ExtraArgument;
      }

      Pointcut pc = null;
      if (preResolvedPointcut != null) {
        pc = preResolvedPointcut.getPointcut();
      } else {
        pc = parsePointcut(pointcut, struct, false);
        if (pc == null) {
          return false;// parse error
        }
        pc.resolve(binding);
      }
      setIgnoreUnboundBindingNames(pc, bindings);

      ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
          struct.bMethod.getDeclarationOffset());
View Full Code Here

        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
        } else {
          pc = parsePointcut(aroundAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here

    return ret;
  }

  @Override
  public ShadowMunger parameterizeWith(ResolvedType declaringType, Map<String, UnresolvedType> typeVariableMap) {
    Pointcut pc = getPointcut().parameterizeWith(typeVariableMap, declaringType.getWorld());

    BcelAdvice ret = null;
    Member adviceSignature = signature;
    // allows for around advice where the return value is a type variable (see pr115250)
    if (signature instanceof ResolvedMember && signature.getDeclaringType().isGenericType()) {
View Full Code Here

   * even when one single pointcut has one common element (which can be a side-effect of DNF rewriting).
   */
  private void rewritePointcuts(List<ShadowMunger> shadowMungers) {
    PointcutRewriter rewriter = new PointcutRewriter();
    for (ShadowMunger munger : shadowMungers) {
      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[];
          // 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);
            }
          }
        }
      }
      newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
      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> */<Pointcut, Pointcut> pcMap = new HashMap<Pointcut, Pointcut>();
    for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      Pointcut newP = shareEntriesFromMap(p, pcMap);
      newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
      munger.setPointcut(newP);
    }
  }
View Full Code Here

    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 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() != 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

TOP

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

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.