Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory.addInterface()


  protected RepositoryInterface createProxy(RepositoryInterfaceImpl target) {
    MapPersistenceExceptionTranslator mpet = new MapPersistenceExceptionTranslator();
    mpet.addTranslation(persistenceException1, new InvalidDataAccessApiUsageException("", persistenceException1));
    ProxyFactory pf = new ProxyFactory(target);
    pf.addInterface(RepositoryInterface.class);
    addPersistenceExceptionTranslation(pf, mpet);
    return (RepositoryInterface) pf.getProxy();
  }

  protected void addPersistenceExceptionTranslation(ProxyFactory pf, PersistenceExceptionTranslator pet) {
View Full Code Here


  }

  public void testWithInterface() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithInterfaceImpl());
    proxyFactory.addInterface(TestWithInterface.class);
    proxyFactory.addAdvice(this.ti);

    TestWithInterface proxy = (TestWithInterface) proxyFactory.getProxy();

    proxy.doSomething();
View Full Code Here

  }

  public void testCrossClassInterfaceMethodLevelOnJdkProxy() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new SomeServiceImpl());
    proxyFactory.addInterface(SomeService.class);
    proxyFactory.addAdvice(this.ti);

    SomeService someService = (SomeService) proxyFactory.getProxy();

    someService.bar();
View Full Code Here

  }

  public void testCrossClassInterfaceOnJdkProxy() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new OtherServiceImpl());
    proxyFactory.addInterface(OtherService.class);
    proxyFactory.addAdvice(this.ti);

    OtherService otherService = (OtherService) proxyFactory.getProxy();

    otherService.foo();
View Full Code Here

    ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
    pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

    // Add the AopInfrastructureBean marker to indicate that the scoped proxy
    // itself is not subject to auto-proxying! Only its target bean is.
    pf.addInterface(AopInfrastructureBean.class);

    this.proxy = pf.getProxy(cbf.getBeanClassLoader());
  }

View Full Code Here

    SerializablePerson serializableTarget = new SerializablePerson();
    String name = "Tony";
    serializableTarget.setName("Tony");

    ProxyFactory factory = new ProxyFactory(serializableTarget);
    factory.addInterface(Person.class);
    long time = 1000;
    TimeStamped ts = new SerializableTimeStamped(time);

    factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
    factory.addAdvice(new SerializableNopInterceptor());
View Full Code Here

    SerializablePerson sp2 = new SerializablePerson();
    sp1.setName("Gordon");

    HotSwappableTargetSource hts = new HotSwappableTargetSource(sp1);
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(Person.class);
    pf.setTargetSource(hts);
    pf.addAdvisor(new DefaultPointcutAdvisor(new SerializableNopInterceptor()));
    Person p = (Person) pf.getProxy();

    assertEquals(sp1.getName(), p.getName());
View Full Code Here

              "Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'");
        }
        Class[] ifcs = ClassUtils.getAllInterfacesForClass(targetClass, jof.beanClassLoader);
        for (Class ifc : ifcs) {
          if (Modifier.isPublic(ifc.getModifiers())) {
            proxyFactory.addInterface(ifc);
          }
        }
      }
      if (jof.exposeAccessContext) {
        proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
View Full Code Here

  public void afterPropertiesSet() {
    super.afterPropertiesSet();

    // Build a proxy that also exposes the JAX-WS BindingProvider interface.
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(getServiceInterface());
    pf.addInterface(BindingProvider.class);
    pf.addAdvice(this);
    this.serviceProxy = pf.getProxy(this.beanClassLoader);
  }
View Full Code Here

    super.afterPropertiesSet();

    // Build a proxy that also exposes the JAX-WS BindingProvider interface.
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(getServiceInterface());
    pf.addInterface(BindingProvider.class);
    pf.addAdvice(this);
    this.serviceProxy = pf.getProxy(this.beanClassLoader);
  }

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.