Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory


   
    /**
     * @see AbstractDynamicIntroductor#introduceInterfaces(Object , Class[] )
     */
    public Object introduceInterfaces(Object target, Class[] introducedInterfaces) {
        ProxyFactory proxyFactory = new ProxyFactory();
       
        proxyFactory.setProxyTargetClass(true);
        proxyFactory.addAdvisor(new ImplementorIntroductorAdvisor(introducedInterfaces, this.implementor));
        proxyFactory.setTarget(target);
       
        return proxyFactory.getProxy();
    }
View Full Code Here


   
    /**
     * @see AbstractDynamicIntroductor#introduceInterfaces(Object , Class[] , Class[] )
     */
    public Object introduceInterfaces(Object target, Class[] introducedInterfaces, Class[] targetInterfaces) {
        ProxyFactory proxyFactory = new ProxyFactory();
       
        proxyFactory.addAdvisor(new ImplementorIntroductorAdvisor(introducedInterfaces, this.implementor));
        proxyFactory.setTarget(target);
        proxyFactory.setInterfaces(this.merge(introducedInterfaces, targetInterfaces));
       
        return proxyFactory.getProxy();
    }
View Full Code Here

   
    /**
     * @see AbstractDynamicIntroductor#introduceInterfaces(Object , Class[] )
     */
    public Object introduceInterfaces(Object target, Class[] introducedInterfaces) {
        ProxyFactory proxyFactory = new ProxyFactory();
       
        proxyFactory.setProxyTargetClass(true);
        proxyFactory.addAdvisor(new BeanIntroductorAdvisor(introducedInterfaces));
        proxyFactory.setTarget(target);
       
        return proxyFactory.getProxy();
    }
View Full Code Here

   
    /**
     * @see AbstractDynamicIntroductor#introduceInterfaces(Object , Class[] , Class[] )
     */
    public Object introduceInterfaces(Object target, Class[] introducedInterfaces, Class[] targetInterfaces) {
        ProxyFactory proxyFactory = new ProxyFactory();
       
        proxyFactory.addAdvisor(new BeanIntroductorAdvisor(introducedInterfaces));
        proxyFactory.setTarget(target);
        proxyFactory.setInterfaces(this.merge(introducedInterfaces, targetInterfaces));
       
        return proxyFactory.getProxy();
    }
View Full Code Here

    if (target == null) {
      throw new IllegalStateException("Property 'target' is required");
    }

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(new CachingModelSourceAdvisor(cachingInterceptor));

    if (hasFlushingModels) {
      proxyFactory.addAdvisor(new FlushingModelSourceAdvisor(
          flushingInterceptor));
    }

    proxyFactory.copyFrom(this);

    TargetSource targetSource = createTargetSource(target);
    proxyFactory.setTargetSource(targetSource);

    if (proxyInterfaces != null) {
      proxyFactory.setInterfaces(proxyInterfaces);
    } else if (!isProxyTargetClass()) {
      if (target instanceof TargetSource) {
        throw new AopConfigException(
            "Either 'proxyInterfaces' or 'proxyTargetClass' is required "
                + "when using a TargetSource as 'target'");
      }

      // rely on AOP infrastructure to tell us what interfaces to proxy
      proxyFactory.setInterfaces(ClassUtils.getAllInterfaces(target));
    }

    proxy = proxyFactory.getProxy();
  }
View Full Code Here

  /**
   * Verify that if the {@link #controller} is a proxies <code>BaseCommandController</code>,
   * it still works correctly.
   */
  public void testHappyCaseWithProxiedBaseCommandController() throws Exception {
    ProxyFactory factory = new ProxyFactory(this.controller);
    Object proxiedController = factory.getProxy();
   
    this.interceptor.postHandle(this.request, this.response, proxiedController, this.modelAndView);
   
    Map map = this.modelAndView.getModel();
    assertTrue("expected validation rule to be added", map.containsKey("ValangRules.command"));
View Full Code Here

   * Verify that if the {@link #controller} is a proxy, but isn't a {@link BaseCommandController}
   *  it still works correctly (o.e. no-op).
   */
  public void testHappyCaseWithProxiedPlainController() throws Exception {
    Controller plainController = new PlainController();
    ProxyFactory factory = new ProxyFactory(plainController);
    Object proxiedController = factory.getProxy();
   
    this.interceptor.postHandle(this.request, this.response, proxiedController, this.modelAndView);
   
    Map map = this.modelAndView.getModel();
    assertFalse("non BaseCommandControllers should be ignored", map.containsKey("ValangRules.command"));
View Full Code Here

     *
     * @return
     * @throws NoSuchMethodException
     */
    public static MockMethodInvocation createSec2150MethodInvocation() throws NoSuchMethodException {
        ProxyFactory factory = new ProxyFactory(new Class[] {PersonRepository.class});
        factory.setTargetClass(CrudRepository.class);
        PersonRepository repository = (PersonRepository) factory.getProxy();
        return new MockMethodInvocation(repository, PersonRepository.class , "findAll");
    }
View Full Code Here

        SecurityContextHolder.clearContext();
    }

    private void createTarget(boolean useMock) {
        realTarget = useMock ? mock(ITargetObject.class) : new TargetObject();
        ProxyFactory pf = new ProxyFactory(realTarget);
        pf.addAdvice(interceptor);
        advisedTarget = (ITargetObject) pf.getProxy();
    }
View Full Code Here

      if (bean instanceof Advised) {
        ((Advised) bean).addAdvisor(0, this.advisor);
        return bean;
      }
      else {
        ProxyFactory proxyFactory = new ProxyFactory(bean);
        // Copy our properties (proxyTargetClass etc) inherited from ProxyConfig.
        proxyFactory.copyFrom(this);
        proxyFactory.addAdvisor(this.advisor);
        return proxyFactory.getProxy(this.beanClassLoader);
      }
    }
    else {
      // No async proxy needed.
      return bean;
View Full Code Here

TOP

Related Classes of org.springframework.aop.framework.ProxyFactory

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.