Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut


        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

    private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) {
      if (toSearch instanceof NotPointcut) return null;
      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);
      }
      return null;
    }
View Full Code Here

    throws UnsupportedPointcutPrimitiveException, IllegalArgumentException {
       PointcutExpressionImpl pcExpr = null;
         try {
           PatternParser parser = new PatternParser(expression);
           parser.setPointcutDesignatorHandlers(pointcutDesignators, world);
             Pointcut pc = parser.parsePointcut();
             validateAgainstSupportedPrimitives(pc,expression);
             IScope resolutionScope = buildResolutionScope((inScope == null ? Object.class : inScope),formalParameters);
             pc = pc.resolve(resolutionScope);
             ResolvedType declaringTypeForResolution = null;
             if (inScope != null) {
               declaringTypeForResolution = getWorld().resolve(inScope.getName());
             } else {
               declaringTypeForResolution = ResolvedType.OBJECT.resolve(getWorld());
             }
             IntMap arity = new IntMap(formalParameters.length);
             for (int i = 0; i < formalParameters.length; i++) {
               arity.put(i, i);
             }            
             pc = pc.concretize(declaringTypeForResolution, declaringTypeForResolution, arity);
             validateAgainstSupportedPrimitives(pc,expression); // again, because we have now followed any ref'd pcuts
             pcExpr = new PointcutExpressionImpl(pc,expression,formalParameters,getWorld());
         } catch (ParserException pEx) {
             throw new IllegalArgumentException(buildUserMessageFromParserException(expression,pEx));
         } catch (ReflectionWorld.ReflectionWorldException rwEx) {
View Full Code Here

    super();
    sourceStart = tokens.sourceStart;
    sourceEnd = tokens.sourceEnd;
    this.tokens = tokens;
   
    Pointcut pc = tokens.parsePointcut(parser);
    if (pc.toString().equals("")) { //??? is this a good signal
      isError = true;
    }
    pointcut = pc;
  }
View Full Code Here

  }
 
  public Pointcut parsePointcut(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      Pointcut ret = patternParser.parsePointcut();
      checkEof(parser);
      return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
      return Pointcut.makeMatchesNothing(Pointcut.SYMBOLIC);
View Full Code Here

    AspectDeclaration aspectDecl = new AspectDeclaration(typeDecl.compilationResult);

    try {
      if (perClause != null && !perClause.equals("")) {
        ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLoc[0]);
        Pointcut pc = new PatternParser(perClause,context).maybeParsePerClause();
          FormalBinding[] bindings = new FormalBinding[0];
        if (pc != null) pc.resolve(new EclipseScope(bindings,typeDecl.scope));
      }
    } catch(ParserException pEx) {
      typeDecl.scope.problemReporter().parseError(
          pcLoc[0] + pEx.getLocation().getStart(),
          pcLoc[0] + pEx.getLocation().getEnd() ,
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.