Package org.springframework.aop

Examples of org.springframework.aop.Pointcut


 
  /**
   * Should match all setters and getters on any class
   */
  public void testUnionOfSettersAndGetters() {
    Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut);
    assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
  }
View Full Code Here


    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
  }
 
  public void testUnionOfSpecificGetters() {
    Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut);
    assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
View Full Code Here

  public void testUnionOfAllSettersAndSubclassSetters() {
    assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
    assertTrue(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)}));
    assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
   
    Pointcut union = Pointcuts.union(myTestBeanSetterPointcut, allClassGetterPointcut);
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class, null));
    // Still doesn't match superclass setter
    assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)}));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
View Full Code Here

    assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, MyTestBean.class, null));
    assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, MyTestBean.class, null));
   
    Pointcut intersection = Pointcuts.intersection(allClassGetAgePointcut, myTestBeanGetterPointcut);
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class, null));
    assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class, null));
    // Matches subclass of MyTestBean
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null));
    assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null));
   
    // Now intersection with MyTestBeanSubclass getters should eliminate MyTestBean target
    intersection = Pointcuts.intersection(intersection, myTestBeanSubclassGetterPointcut);
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class, null));
    // Still matches subclass of MyTestBean
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null));
    assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null));
   
    // Now union with all TestBean methods
    Pointcut union = Pointcuts.union(intersection, allTestBeanMethodsPointcut);
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null));
    assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBean.class, null));
    assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class, null));
    // Still matches subclass of MyTestBean
View Full Code Here

 
  /**
   * The intersection of these two pointcuts leaves nothing.
   */
  public void testSimpleIntersection() {
    Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut);
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
    assertFalse(Pointcuts.matches(intersection, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
  }
View Full Code Here

      return m.getName().startsWith("set");
    }
  };
 
  public void testMatchAll() throws NoSuchMethodException {
    Pointcut pc = new ComposablePointcut();
    assertTrue(pc.getClassFilter().matches(Object.class));
    assertTrue(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode", (Class[]) null), Exception.class));
  }
View Full Code Here

  private ITestBean getAdvisedProxy(TestBean target) {
    ProxyFactory pf = new ProxyFactory(new Class[]{ITestBean.class});
    pf.setProxyTargetClass(true);

    MethodInterceptor advice = new NopInterceptor();
    Pointcut pointcut = new Pointcut() {
      public ClassFilter getClassFilter() {
        return ClassFilter.TRUE;
      }

      public MethodMatcher getMethodMatcher() {
View Full Code Here

                Class<? extends Object> clazz = ((Advised) bean).getTargetClass();
                classes.add(clazz);
            }
        }

        final Pointcut pointcut = (Pointcut) applicationContext.getBean(pointcutBeanName);
        final MethodMatcher methodMatcher = pointcut.getMethodMatcher();
        for(final Class clazz : classes){
                for(final Method method: clazz.getDeclaredMethods()){
                    if(Modifier.isPublic(method.getModifiers())){
                        if(methodMatcher.matches(method, clazz,method.getParameterTypes())){
                            if(LOGGER.isDebugEnabled()){
View Full Code Here

   * @return the applicable Pointcut object, or {@code null} if none
   */
  protected Pointcut buildPointcut(Set<Class<? extends Annotation>> retryAnnotationTypes) {
    ComposablePointcut result = null;
    for (Class<? extends Annotation> retryAnnotationType : retryAnnotationTypes) {
      Pointcut filter = new AnnotationClassOrMethodPointcut(retryAnnotationType);
      if (result == null) {
        result = new ComposablePointcut(filter);
      }
      else {
        result.union(filter);
View Full Code Here

  private ITestBean getAdvisedProxy(TestBean target) {
    ProxyFactory pf = new ProxyFactory(new Class<?>[]{ITestBean.class});
    pf.setProxyTargetClass(true);

    MethodInterceptor advice = new NopInterceptor();
    Pointcut pointcut = new Pointcut() {
      @Override
      public ClassFilter getClassFilter() {
        return ClassFilter.TRUE;
      }
      @Override
View Full Code Here

TOP

Related Classes of org.springframework.aop.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.