Package org.aspectj.weaver.tools

Examples of org.aspectj.weaver.tools.PointcutExpression


    ShadowMatch shadowMatch = this.shadowMatchCache.get(targetMethod);
    if (shadowMatch == null) {
      synchronized (this.shadowMatchCache) {
        // Not found - now check again with full lock...
        Method methodToMatch = targetMethod;
        PointcutExpression fallbackPointcutExpression = null;
        shadowMatch = this.shadowMatchCache.get(methodToMatch);
        if (shadowMatch == null) {
          try {
            shadowMatch = this.pointcutExpression.matchesMethodExecution(targetMethod);
          }
          catch (ReflectionWorld.ReflectionWorldException ex) {
            // Failed to introspect target method, probably because it has been loaded
            // in a special ClassLoader. Let's try the original method instead...
            try {
              fallbackPointcutExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
              shadowMatch = fallbackPointcutExpression.matchesMethodExecution(methodToMatch);
            } catch (ReflectionWorld.ReflectionWorldException e) {
              if (targetMethod == originalMethod) {
                shadowMatch = new ShadowMatchImpl(org.aspectj.util.FuzzyBoolean.NO, null, null, null);
              }
              else {
                try {
                  shadowMatch = this.pointcutExpression.matchesMethodExecution(originalMethod);
                }
                catch (ReflectionWorld.ReflectionWorldException ex2) {
                  // Could neither introspect the target class nor the proxy class ->
                  // let's simply consider this method as non-matching.
                  methodToMatch = originalMethod;
                  fallbackPointcutExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
                  try {
                    shadowMatch = fallbackPointcutExpression.matchesMethodExecution(methodToMatch);
                  } catch (ReflectionWorld.ReflectionWorldException e2) {
                    shadowMatch = new ShadowMatchImpl(org.aspectj.util.FuzzyBoolean.NO, null, null, null);
                  }
                }
              }
            }
          }
          if (shadowMatch.maybeMatches() && fallbackPointcutExpression!=null) {
            shadowMatch = new DefensiveShadowMatch(shadowMatch,
                fallbackPointcutExpression.matchesMethodExecution(methodToMatch));
          }
          this.shadowMatchCache.put(targetMethod, shadowMatch);
        }
      }
    }
View Full Code Here


  }

  public void testAndSubstitution() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
    PointcutExpression expr =
      ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
  }
View Full Code Here

    assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
  }
 
  public void testMultipleAndSubstitutions() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
    PointcutExpression expr =
      ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());   
  }
View Full Code Here

        // Check to see if any of those methods are compatible with our pointcut expressions
        for (int i = 0; i < methods.length; i++) {
            for (String ex : pointcutMap.keySet()) {
                // Parse the presented AspectJ pointcut expression
                PointcutExpression expression = parser.parsePointcutExpression(ex);

                // Try for the bean class directly
                if (attemptMatch(bean.getClass(), methods[i], expression, beanName)) {
                    // We've found the first expression that matches this method, so move onto the next method now
                    break; // the "while" loop, not the "for" loop
View Full Code Here

        return this.pointcutExpression.couldMatchJoinPointsInType(targetClass);
      }
      catch (ReflectionWorldException ex) {
        logger.debug("PointcutExpression matching rejected target class - trying fallback expression", ex);
        // Actually this is still a "maybe" - treat the pointcut as dynamic if we don't know enough yet
        PointcutExpression fallbackExpression = getFallbackPointcutExpression(targetClass);
        if (fallbackExpression != null) {
          return fallbackExpression.couldMatchJoinPointsInType(targetClass);
        }
      }
    }
    catch (BCException ex) {
      logger.debug("PointcutExpression matching rejected target class", ex);
View Full Code Here

    // Avoid lock contention for known Methods through concurrent access...
    ShadowMatch shadowMatch = this.shadowMatchCache.get(targetMethod);
    if (shadowMatch == null) {
      synchronized (this.shadowMatchCache) {
        // Not found - now check again with full lock...
        PointcutExpression fallbackExpression = null;
        Method methodToMatch = targetMethod;
        shadowMatch = this.shadowMatchCache.get(targetMethod);
        if (shadowMatch == null) {
          try {
            shadowMatch = this.pointcutExpression.matchesMethodExecution(methodToMatch);
          }
          catch (ReflectionWorldException ex) {
            // Failed to introspect target method, probably because it has been loaded
            // in a special ClassLoader. Let's try the declaring ClassLoader instead...
            try {
              fallbackExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
              if (fallbackExpression != null) {
                shadowMatch = fallbackExpression.matchesMethodExecution(methodToMatch);
              }
            }
            catch (ReflectionWorldException ex2) {
              fallbackExpression = null;
            }
          }
          if (shadowMatch == null && targetMethod != originalMethod) {
            methodToMatch = originalMethod;
            try {
              shadowMatch = this.pointcutExpression.matchesMethodExecution(methodToMatch);
            }
            catch (ReflectionWorldException ex3) {
              // Could neither introspect the target class nor the proxy class ->
              // let's try the original method's declaring class before we give up...
              try {
                fallbackExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
                if (fallbackExpression != null) {
                  shadowMatch = fallbackExpression.matchesMethodExecution(methodToMatch);
                }
              }
              catch (ReflectionWorldException ex4) {
                fallbackExpression = null;
              }
            }
          }
          if (shadowMatch == null) {
            shadowMatch = new ShadowMatchImpl(org.aspectj.util.FuzzyBoolean.NO, null, null, null);
          }
          else if (shadowMatch.maybeMatches() && fallbackExpression != null) {
            shadowMatch = new DefensiveShadowMatch(shadowMatch,
                fallbackExpression.matchesMethodExecution(methodToMatch));
          }
          this.shadowMatchCache.put(targetMethod, shadowMatch);
        }
      }
    }
View Full Code Here

  }

  @Test
  public void testAndSubstitution() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
    PointcutExpression expr =
      ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
  }
View Full Code Here

  }

  @Test
  public void testMultipleAndSubstitutions() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
    PointcutExpression expr =
      ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());
  }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.tools.PointcutExpression

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.