Examples of Advised


Examples of org.springframework.aop.framework.Advised

      "org/springframework/scripting/config/scriptingDefaultsTests.xml";


  public void testDefaultRefreshCheckDelay() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG);
    Advised advised = (Advised) context.getBean("testBean");
    AbstractRefreshableTargetSource targetSource =
        ((AbstractRefreshableTargetSource) advised.getTargetSource());
    Field field = AbstractRefreshableTargetSource.class.getDeclaredField("refreshCheckDelay");
    field.setAccessible(true);
    long delay = ((Long) field.get(targetSource)).longValue();
    assertEquals(5000L, delay);
  }
View Full Code Here

Examples of org.springframework.aop.framework.Advised

      fail("Should not throw UnknownAdviceTypeException");
    }
  }

  private SimpleBeforeAdviceImpl getAdviceImpl(ITestBean tb) {
    Advised advised = (Advised) tb;
    Advisor advisor = advised.getAdvisors()[0];
    return (SimpleBeforeAdviceImpl) advisor.getAdvice();
  }
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    checkWillTranslateExceptions(rwi2);
  }
 
  protected void checkWillTranslateExceptions(Object o) {
    assertTrue(o instanceof Advised);
    Advised a = (Advised) o;
    for (Advisor advisor : a.getAdvisors()) {
      if (advisor instanceof PersistenceExceptionTranslationAdvisor) {
        return;
      }
    }
    fail("No translation");
View Full Code Here

Examples of org.springframework.aop.framework.Advised

  public void testCustomPrototypeTargetSource() throws Exception {
    CountingTestBean.count = 0;
    BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/customTargetSource.xml");
    ITestBean test = (ITestBean) bf.getBean("prototypeTest");
    assertTrue(AopUtils.isAopProxy(test));
    Advised advised = (Advised) test;
    assertTrue(advised.getTargetSource() instanceof PrototypeTargetSource);
    assertEquals("Rod", test.getName());
    // Check that references survived prototype creation
    assertEquals("Kerry", test.getSpouse().getName());
    assertEquals("Only 2 CountingTestBeans instantiated", 2, CountingTestBean.count);
    CountingTestBean.count = 0;
View Full Code Here

Examples of org.springframework.aop.framework.Advised

  public void testLazyInitTargetSource() throws Exception {
    CountingTestBean.count = 0;
    BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/customTargetSource.xml");
    ITestBean test = (ITestBean) bf.getBean("lazyInitTest");
    assertTrue(AopUtils.isAopProxy(test));
    Advised advised = (Advised) test;
    assertTrue(advised.getTargetSource() instanceof LazyInitTargetSource);
    assertEquals("No CountingTestBean instantiated yet", 0, CountingTestBean.count);
    assertEquals("Rod", test.getName());
    assertEquals("Kerry", test.getSpouse().getName());
    assertEquals("Only 1 CountingTestBean instantiated", 1, CountingTestBean.count);
    CountingTestBean.count = 0;
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    assertEquals("Kerry", test.getSpouse().getName());
 
    // Now test the pooled one
    test = (ITestBean) bf.getBean(":test");
    assertTrue(AopUtils.isAopProxy(test));
    Advised advised = (Advised) test;
    assertTrue(advised.getTargetSource() instanceof CommonsPoolTargetSource);
    assertEquals("Rod", test.getName());
    // Check that references survived pooling
    assertEquals("Kerry", test.getSpouse().getName());
   
    // Now test the ThreadLocal one
    test = (ITestBean) bf.getBean("%test");
    assertTrue(AopUtils.isAopProxy(test));
    advised = (Advised) test;
    assertTrue(advised.getTargetSource() instanceof ThreadLocalTargetSource);
    assertEquals("Rod", test.getName());
    // Check that references survived pooling
    assertEquals("Kerry", test.getSpouse().getName());
   
    // Now test the Prototype TargetSource
    test = (ITestBean) bf.getBean("!test");
    assertTrue(AopUtils.isAopProxy(test));
    advised = (Advised) test;
    assertTrue(advised.getTargetSource() instanceof PrototypeTargetSource);
    assertEquals("Rod", test.getName());
    // Check that references survived pooling
    assertEquals("Kerry", test.getSpouse().getName());

View Full Code Here

Examples of org.springframework.aop.framework.Advised

      targetSource.releaseTarget(pooledInstances[i]);
    }
  }

  public void testHitMaxSizeLoadedFromContext() throws Exception {
    Advised person = (Advised) beanFactory.getBean("maxSizePooledPerson");
    CommonsPoolTargetSource targetSource = (CommonsPoolTargetSource) person.getTargetSource();

    int maxSize = targetSource.getMaxSize();
    Object[] pooledInstances = new Object[maxSize];

    for (int x = 0; x < maxSize; x++) {
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();

    ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
    Advised advised = (Advised) serializedProxy;
    ConcurrencyThrottleInterceptor serializedCti =
        (ConcurrencyThrottleInterceptor) advised.getAdvisors()[0].getAdvice();
    assertEquals(cti.getConcurrencyLimit(), serializedCti.getConcurrencyLimit());
    serializedProxy.getAge();
  }
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    ITestBean bean = getTestBean();

    assertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));

    // check the advice details
    Advised advised = (Advised) bean;
    Advisor[] advisors = advised.getAdvisors();

    assertTrue("Advisors should not be empty", advisors.length > 0);
  }
View Full Code Here

Examples of org.springframework.aop.framework.Advised

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated before advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
   
    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);
    assertEquals("adrian", adrian.getName());
   
    for (int i = 0; i < howmany; i++) {
      adrian.getName();
    }
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.