/** Initialize the underlying AspectJ pointcut parser. */
 private PointcutParser initializePointcutParser(ClassLoader cl) {
   PointcutParser parser =
       PointcutParser
           .getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(
               SUPPORTED_PRIMITIVES, cl);
   parser.registerPointcutDesignatorHandler(new BeanNamePointcutDesignatorHandler());
   return parser;
 }
 /** Build the underlying AspectJ pointcut expression. */
 private PointcutExpression buildPointcutExpression(ClassLoader classLoader) {
   PointcutParser parser = initializePointcutParser(classLoader);
   PointcutParameter[] pointcutParameters =
       new PointcutParameter[this.pointcutParameterNames.length];
   for (int i = 0; i < pointcutParameters.length; i++) {
     pointcutParameters[i] =
         parser.createPointcutParameter(
             this.pointcutParameterNames[i], this.pointcutParameterTypes[i]);
   }
   return parser.parsePointcutExpression(
       replaceBooleanOperators(getExpression()),
       this.pointcutDeclarationScope,
       pointcutParameters);
 }
Esempio n. 3
0
  public void loop() throws Throwable {
    URLClassLoader classLoader = new URLClassLoader(new URL[] {new URL("file://" + dir + "/")});
    PointcutParser p =
        PointcutParser
            .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(
                classLoader);

    String[] classFiles = new ClassUtils().getClasses(dir);
    for (String classFile : classFiles) {
      String className = classFile.substring(0, classFile.lastIndexOf('.')).replace('/', '.');
      Class<?> cls = Class.forName(className, false, classLoader);

      for (Matcher m : matchers) {
        if (m.parser(p).matchClass(cls)) {
          // m.match
        }
      }
    }
  }
  static {
    singleValuedAnnotationPcds.add("@this");
    singleValuedAnnotationPcds.add("@target");
    singleValuedAnnotationPcds.add("@within");
    singleValuedAnnotationPcds.add("@withincode");
    singleValuedAnnotationPcds.add("@annotation");

    Set pointcutPrimitives = PointcutParser.getAllSupportedPointcutPrimitives();
    for (Iterator iterator = pointcutPrimitives.iterator(); iterator.hasNext(); ) {
      PointcutPrimitive primitive = (PointcutPrimitive) iterator.next();
      nonReferencePointcutTokens.add(primitive.getName());
    }
    nonReferencePointcutTokens.add("&&");
    nonReferencePointcutTokens.add("!");
    nonReferencePointcutTokens.add("||");
    nonReferencePointcutTokens.add("and");
    nonReferencePointcutTokens.add("or");
    nonReferencePointcutTokens.add("not");
  }