Examples of Pointcut


Examples of org.aspectj.weaver.patterns.Pointcut

        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

Examples of org.aspectj.weaver.patterns.Pointcut

    UnresolvedType[] argumentTypes = new UnresolvedType[struct.method.getArgumentTypes().length];
    for (int i = 0; i < argumentTypes.length; i++) {
      argumentTypes[i] = UnresolvedType.forSignature(struct.method.getArgumentTypes()[i].getSignature());
    }

    Pointcut pc = null;
    if (struct.method.isAbstract()) {
      if ((pointcutExpr != null && isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) || pointcutExpr == null) {
        // abstract pointcut
        // leave pc = null
      } else {
        reportError("Found defined @Pointcut on an abstract method", struct);
        return false;// stop
      }
    } else {
      if (pointcutExpr == null || isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) {
        // the matches nothing pointcut (125475/125480) - perhaps not as
        // cleanly supported as it could be.
      } else {
        // if (pointcutExpr != null) {
        // use a LazyResolvedPointcutDefinition so that the pointcut is
        // resolved lazily
        // since for it to be resolved, we will need other pointcuts to
        // be registered as well
        pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true);
        if (pc == null) {
          return false;// parse error
        }
        pc.setLocation(struct.context, -1, -1);// FIXME AVASM !! bMethod
        // is null here..
        // } else {
        // reportError("Found undefined @Pointcut on a non-abstract method",
        // struct);
        // return false;
View Full Code Here

Examples of org.aspectj.weaver.patterns.Pointcut

      if (declareError != null) {
        if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
          reportError("@DeclareError used on a non String constant field", struct);
          return false;
        }
        Pointcut pc = parsePointcut(declareError.getValue().stringifyValue(), struct, false);
        if (pc == null) {
          hasError = false;// cannot parse pointcut
        } else {
          DeclareErrorOrWarning deow = new DeclareErrorOrWarning(true, pc, struct.field.getConstantValue().toString());
          setDeclareErrorOrWarningLocation(model, deow, struct);
          struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
          hasError = true;
        }
      }
    }
    AnnotationGen warning = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREWARNING_ANNOTATION);
    boolean hasWarning = false;
    if (warning != null) {
      NameValuePair declareWarning = getAnnotationElement(warning, VALUE);
      if (declareWarning != null) {
        if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
          reportError("@DeclareWarning used on a non String constant field", struct);
          return false;
        }
        Pointcut pc = parsePointcut(declareWarning.getValue().stringifyValue(), struct, false);
        if (pc == null) {
          hasWarning = false;// cannot parse pointcut
        } else {
          DeclareErrorOrWarning deow = new DeclareErrorOrWarning(false, pc, struct.field.getConstantValue().toString());
          setDeclareErrorOrWarningLocation(model, deow, struct);
View Full Code Here

Examples of org.aspectj.weaver.patterns.Pointcut

   * @return pointcut, unresolved
   */
  private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct struct, boolean allowIf) {
    try {
      PatternParser parser = new PatternParser(pointcutString, struct.context);
      Pointcut pointcut = parser.parsePointcut();
      parser.checkEof();
      pointcut.check(null, struct.enclosingType.getWorld());
      if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) {
        reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString + "'", struct);
        return null;
      }
      pointcut.setLocation(struct.context, -1, -1);// FIXME -1,-1 is not
      // good enough
      return pointcut;
    } catch (ParserException e) {
      reportError("Invalid pointcut '" + pointcutString + "': " + e.toString()
          + (e.getLocation() == null ? "" : " at position " + e.getLocation().getStart()), struct);
View Full Code Here

Examples of org.aspectj.weaver.patterns.Pointcut

  }
 
  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

Examples of org.aspectj.weaver.patterns.Pointcut

    // 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(), -1, perClause.toCharArray(), perClause,
          new String[] { pEx.getMessage() });
View Full Code Here

Examples of org.aspectj.weaver.patterns.Pointcut

      pointcutExpression = getStringLiteralFor("value", adviceAnn, pcLocation);
    try {
      // +1 to give first char of pointcut string
      ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLocation[0] + 1);
      PatternParser pp = new PatternParser(pointcutExpression, context);
      Pointcut pc = pp.parsePointcut();
      pp.checkEof();
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      pc.resolve(new EclipseScope(bindings, methodDeclaration.scope));
      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(methodDeclaration.scope);
      // now create a ResolvedPointcutDefinition,make an attribute out of
      // it, and add it to the method
      UnresolvedType[] paramTypes = new UnresolvedType[bindings.length];
      for (int i = 0; i < paramTypes.length; i++)
View Full Code Here

Examples of org.aspectj.weaver.patterns.Pointcut

    boolean containsIfPcd = false;
    int[] pcLocation = new int[2];
    String pointcutExpression = getStringLiteralFor("value", ajAnnotations.pointcutAnnotation, pcLocation);
    try {
      ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLocation[0]);
      Pointcut pc = null;// abstract
      if (pointcutExpression == null || pointcutExpression.length() == 0) {
        noValueSupplied = true; // matches nothing pointcut
      } else {
        noValueSupplied = false;
        pc = new PatternParser(pointcutExpression, context).parsePointcut();
      }
      pcDecl.pointcutDesignator = (pc == null) ? null : new PointcutDesignator(pc);
      pcDecl.setGenerateSyntheticPointcutMethod();
      TypeDeclaration onType = (TypeDeclaration) typeStack.peek();
      pcDecl.postParse(onType);
      // EclipseFactory factory =
      // EclipseFactory.fromScopeLookupEnvironment
      // (methodDeclaration.scope);
      // int argsLength = methodDeclaration.arguments == null ? 0 :
      // methodDeclaration.arguments.length;
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      // FormalBinding[] bindings = new FormalBinding[argsLength];
      // for (int i = 0, len = bindings.length; i < len; i++) {
      // Argument arg = methodDeclaration.arguments[i];
      // String name = new String(arg.name);
      // UnresolvedType type =
      // factory.fromBinding(methodDeclaration.binding.parameters[i]);
      // bindings[i] = new FormalBinding(type, name, i, arg.sourceStart,
      // arg.sourceEnd, "unknown");
      // }
      swap(onType, methodDeclaration, pcDecl);
      if (pc != null) {
        // has an expression
        EclipseScope eScope = new EclipseScope(bindings, methodDeclaration.scope);
        char[] packageName = null;
        if (typeDecl.binding != null && typeDecl.binding.getPackage() != null) {
          packageName = typeDecl.binding.getPackage().readableName();
        }
        eScope.setLimitedImports(packageName);
        pc.resolve(eScope);
        HasIfPCDVisitor ifFinder = new HasIfPCDVisitor();
        pc.traverse(ifFinder, null);
        containsIfPcd = ifFinder.containsIfPcd;
      }
    } catch (ParserException pEx) {
      methodDeclaration.scope.problemReporter().parseError(pcLocation[0] + pEx.getLocation().getStart(),
          pcLocation[0] + pEx.getLocation().getEnd(), -1, pointcutExpression.toCharArray(), pointcutExpression,
View Full Code Here

Examples of org.codehaus.aspectwerkz.aspect.management.Pointcut

            PointcutManager pointcutManager = SystemLoader.getSystem(uuid).
                    getAspectManager().getPointcutManager(aspectDef.getName());

            for (Iterator it2 = aspectDef.getAroundAdvices().iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                Pointcut pointcut = pointcutManager.getPointcut(adviceDef.getExpression().getExpression());
                if (pointcut == null) {
                    pointcut = new Pointcut(uuid, adviceDef.getExpression());
                    pointcutManager.addPointcut(pointcut);
                }
                pointcut.addAroundAdvice(adviceDef.getName());
            }

            for (Iterator it2 = aspectDef.getBeforeAdvices().iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                Pointcut pointcut = pointcutManager.getPointcut(adviceDef.getExpression().getExpression());
                if (pointcut == null) {
                    pointcut = new Pointcut(uuid, adviceDef.getExpression());
                    pointcutManager.addPointcut(pointcut);
                }
                pointcut.addBeforeAdvice(adviceDef.getName());
                //TODO - check me: Handler PC supports only beforeAdvice
                //TODO - .. this is not explicit here
            }

            for (Iterator it2 = aspectDef.getAfterAdvices().iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                Pointcut pointcut = pointcutManager.getPointcut(adviceDef.getExpression().getExpression());
                if (pointcut == null) {
                    pointcut = new Pointcut(uuid, adviceDef.getExpression());
                    pointcutManager.addPointcut(pointcut);
                }
                pointcut.addAfterAdvice(adviceDef.getName());
            }
        }

        registerCFlowPointcuts(uuid, definition);
    }
View Full Code Here

Examples of org.jboss.aop.pointcut.Pointcut

         removedBindings = this.bindingCollection.removeBindings(binds);
         for (AdviceBinding removedBinding: removedBindings)
         {
            ArrayList<Advisor> ads = removedBinding.getAdvisors();
            bindingAdvisors.addAll(ads);
            Pointcut pointcut = removedBinding.getPointcut();
            this.removePointcut(pointcut.getName());
         }
      }
      finally
      {
         lock.unlockWrite();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.