Package org.springframework.aop.support

Examples of org.springframework.aop.support.DefaultIntroductionAdvisor


   * Return an introduction advisor mixin that allows the AOP proxy to be
   * cast to ThreadLocalInvokerStats.
   */
  public IntroductionAdvisor getStatsMixin() {
    DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this);
    return new DefaultIntroductionAdvisor(dii, ThreadLocalTargetSourceStats.class);
  }
View Full Code Here


    long t = 555555L;
    TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);
   
    Class[] oldProxiedInterfaces = factory.getProxiedInterfaces();
   
    factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
   
    Class[] newProxiedInterfaces = factory.getProxiedInterfaces();
    assertEquals("Advisor proxies one more interface after introduction", oldProxiedInterfaces.length + 1, newProxiedInterfaces.length);

    TimeStamped ts = (TimeStamped) factory.getProxy();
View Full Code Here

    TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
    ti.setTime(time);

    // Add to front of interceptor chain
    int oldCount = config.getAdvisors().length;
    config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));

    assertTrue(config.getAdvisors().length == oldCount + 1);

    TimeStamped ts = (TimeStamped) config.getProxy();
    assertTrue(ts.getTimeStamp() == time);
View Full Code Here

  public void testRejectsBogusDynamicIntroductionAdviceWithNoAdapter() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    pc.addAdvisor(new DefaultIntroductionAdvisor(new DummyIntroductionAdviceImpl(), Comparable.class));
    try {
      // TODO May fail on either call: may want to tighten up definition
      ITestBean proxied = (ITestBean) createProxy(pc);
      proxied.getName();
      fail("Bogus introduction");
View Full Code Here

  public void testCannotAddIntroductionAdviceWithUnimplementedInterface() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    try {
      pc.addAdvisor(0, new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor(), ITestBean.class));
      fail("Shouldn't be able to add introduction advice introducing an unimplemented interface");
    }
    catch (IllegalArgumentException ex) {
      //assertTrue(ex.getMessage().indexOf("ntroduction") > -1);
    }
View Full Code Here

       */
      public long getTimeStamp() {
        throw new UnsupportedOperationException();
      }
    }
    pc.addAdvisor(new DefaultIntroductionAdvisor(new MyDi()));

    TimeStamped ts = (TimeStamped) createProxy(pc);
    try {
      ts.getTimeStamp();
      fail("Should throw UnsupportedOperationException");
View Full Code Here

  public void testCannotAddIntroductionAdviceToIntroduceClass() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    try {
      pc.addAdvisor(0, new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor(), TestBean.class));
      fail("Shouldn't be able to add introduction advice that introduces a class, rather than an interface");
    }
    catch (IllegalArgumentException ex) {
      assertTrue(ex.getMessage().indexOf("interface") > -1);
    }
View Full Code Here

    pf1.addAdvice(new NopInterceptor());
    ITestBean proxy1 = (ITestBean) createProxy(pf1);

    TestBean target2 = new TestBean();
    ProxyFactory pf2 = new ProxyFactory(target2);
    pf2.addAdvisor(new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor()));
    ITestBean proxy2 = (ITestBean) createProxy(pf2);

    HashMap h = new HashMap();
    Object value1 = "foo";
    Object value2 = "bar";
View Full Code Here

    long time = 666L;
    TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
    ti.setTime(time);
    // Add to head of interceptor chain
    int oldCount = config.getAdvisors().length;
    config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
    assertTrue(config.getAdvisors().length == oldCount + 1);
   
    TimeStamped ts = (TimeStamped) factory.getBean("test2");
    assertEquals(time, ts.getTimeStamp());
   
View Full Code Here

  @Test
  public void testRejectsBogusDynamicIntroductionAdviceWithNoAdapter() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    pc.addAdvisor(new DefaultIntroductionAdvisor(new DummyIntroductionAdviceImpl(), Comparable.class));
    try {
      // TODO May fail on either call: may want to tighten up definition
      ITestBean proxied = (ITestBean) createProxy(pc);
      proxied.getName();
      fail("Bogus introduction");
View Full Code Here

TOP

Related Classes of org.springframework.aop.support.DefaultIntroductionAdvisor

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.