Examples of Advised


Examples of org.springframework.aop.framework.Advised

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated after returning advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
   
    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);
    // Hits joinpoint
    adrian.setAge(25);
   
    for (int i = 0; i < howmany; i++) {
      adrian.setAge(i);
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated mixed invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
   
    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);
   
    for (int i = 0; i < howmany; i++) {
      // Hit all 3 joinpoints
      adrian.getAge();
      adrian.getName();
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    TestBean itb = (TestBean) createProxy(target,
        getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean")),
        TestBean.class);
    assertEquals("Around advice must NOT apply", realAge, itb.getAge());
   
    Advised advised = (Advised) itb;
    SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
    assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
    InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[3];
    LazySingletonAspectInstanceFactoryDecorator maaif =
        (LazySingletonAspectInstanceFactoryDecorator) imapa.getAspectInstanceFactory();
    assertFalse(maaif.isMaterialized());

    // Check that the perclause pointcut is valid
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    TestBean itb = (TestBean) createProxy(target,
        getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerThisAspect(), "someBean")),
        TestBean.class);
    assertEquals("Around advice must NOT apply", realAge, itb.getAge());
   
    Advised advised = (Advised) itb;
    // Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
    assertEquals(4, advised.getAdvisors().length);
    SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
    assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
    InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[2];
    LazySingletonAspectInstanceFactoryDecorator maaif =
        (LazySingletonAspectInstanceFactoryDecorator) imapa.getAspectInstanceFactory();
    assertFalse(maaif.isMaterialized());

    // Check that the perclause pointcut is valid
View Full Code Here

Examples of org.springframework.aop.framework.Advised

        getFixture().getAdvisors(aif),
        TestBean.class);
    assertEquals("No method calls", 0, aif.getInstantiationCount());
    assertEquals("Around advice must now apply", 0, itb.getAge());
   
    Advised advised = (Advised) itb;
    // Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
    assertEquals(4, advised.getAdvisors().length);
    SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
    assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
    InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[2];
    LazySingletonAspectInstanceFactoryDecorator maaif =
        (LazySingletonAspectInstanceFactoryDecorator) imapa.getAspectInstanceFactory();
    assertTrue(maaif.isMaterialized());

    // Check that the perclause pointcut is valid
View Full Code Here

Examples of org.springframework.aop.framework.Advised

     * There is currently no way of testing whether this will happen, ie null will never
     * be returned from this method.
     */
    public static Object getRealBean(Object proxy) throws Exception
    {
        Advised advised = (Advised) proxy;
        TargetSource targetSource = advised.getTargetSource();
        Object real = targetSource.getTarget();
       
        // Possibly we could add a method on the ScopedBeanTargetSource class to test
        // whether the target bean exists. Then here we could cast TargetSource to
        // ScopedBeanTargetSource and return null if the target does not exist. This
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    }
    protected Object getRealObjectInternal(Object o) {
        if (o instanceof Advised) {
            try {

                Advised advised = (Advised)o;
                Object target = advised.getTargetSource().getTarget();
                //could be a proxy of a proxy.....  
                return getRealObjectInternal(target);
            } catch (Exception ex) {
                // ignore
            }
View Full Code Here

Examples of org.springframework.aop.framework.Advised

        return o;
    }

    protected Class getRealClassInternal(Object o) {
        if (AopUtils.isAopProxy(o)) {
            Advised advised = (Advised)o;
            try {
                TargetSource targetSource = advised.getTargetSource();
               
                Object target = null;
               
                try {
                    target = targetSource.getTarget();
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    } else if (AopUtils.isAopProxy(handler)) {
      if (logger.isDebugEnabled()) {
        logger.debug("handler is AOP proxy");
      }
     
      Advised advisedObject = (Advised) handler;
      Class proxiedClass = advisedObject.getTargetClass();
      Object target = advisedObject.getTargetSource().getTarget();
     
      // convert (if possible) the target.
      baseCommandController = retrieveBaseCommandControllerIfPossible(target);
    }
   
View Full Code Here

Examples of org.springframework.aop.framework.Advised

     * There is currently no way of testing whether this will happen, ie null will never
     * be returned from this method.
     */
    public static Object getRealBean(Object proxy) throws Exception
    {
        Advised advised = (Advised) proxy;
        TargetSource targetSource = advised.getTargetSource();
        Object real = targetSource.getTarget();
       
        // Possibly we could add a method on the ScopedBeanTargetSource class to test
        // whether the target bean exists. Then here we could cast TargetSource to
        // ScopedBeanTargetSource and return null if the target does not exist. This
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.