コード例 #1
0
 /** Initialize the underlying AspectJ pointcut parser. */
 private PointcutParser initializePointcutParser(ClassLoader cl) {
   PointcutParser parser =
       PointcutParser
           .getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(
               SUPPORTED_PRIMITIVES, cl);
   parser.registerPointcutDesignatorHandler(new BeanNamePointcutDesignatorHandler());
   return parser;
 }
コード例 #2
0
 /** 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);
 }
コード例 #3
0
ファイル: Looper.java プロジェクト: chanwit/groovy-typesheet
  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");
  }