Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory


        final List<String> list = new ArrayList<String>();
        ServiceRegistryEntry ref = new StaticServiceRegistryEntry(list, "mybean", "mymod", ClassUtils.getDefaultClassLoader());
        expect(serviceRegistry.getService("mykey", classes, false)).andReturn(ref);
       
        replay(serviceRegistry);
        final ProxyFactory proxyFactory = creator.createProxyFactory(new BeanRetrievingProxyFactorySource(serviceRegistry, classes, null, "mykey"), null, null);
       
        final List<String> proxy = (List<String>) proxyFactory.getProxy();
        proxy.add("obj");
       
        verify(serviceRegistry);
       
        assertTrue(list.contains("obj"));
View Full Code Here


        final List<String> list = new ArrayList<String>();
        ServiceRegistryEntry ref = new StaticServiceRegistryEntry(list, "mybean", "mymod", ClassUtils.getDefaultClassLoader());
        expect(serviceRegistry.getService("mykey", classes, false)).andReturn(ref);
       
        replay(serviceRegistry);
        final ProxyFactory proxyFactory = creator.createProxyFactory(new BeanRetrievingProxyFactorySource(serviceRegistry, classes, null, "mykey"), null, null);
       
        final List<String> proxy = (List<String>) proxyFactory.getProxy();
        proxy.add("obj");
       
        verify(serviceRegistry);
       
        assertTrue(list.contains("obj"));
View Full Code Here

    public void testStaticProxyFactory() throws Exception {
        final List<String> list = new ArrayList<String>();
        ServiceRegistryEntry ref = new StaticServiceRegistryEntry(list, "mybean", "mymod", ClassUtils.getDefaultClassLoader());
       
        replay(serviceRegistry);
        final ProxyFactory proxyFactory = creator.createProxyFactory(new StaticServiceReferenceProxyFactorySource(new Class<?>[]{List.class}, ref), null, null);
       
        final List<String> proxy = (List<String>) proxyFactory.getProxy();
        proxy.add("obj");
       
        verify(serviceRegistry);
    }
View Full Code Here

    public void testStaticProxyFactoryWithNoInterfaces() throws Exception {
        final List<String> list = new ArrayList<String>();
        ServiceRegistryEntry ref = new StaticServiceRegistryEntry(list, "mybean", "mymod", ClassUtils.getDefaultClassLoader());
       
        replay(serviceRegistry);
        final ProxyFactory proxyFactory = creator.createProxyFactory(new StaticServiceReferenceProxyFactorySource(null, ref), null, null);
       
        final List<String> proxy = (List<String>) proxyFactory.getProxy();
        assertTrue(proxy instanceof ArrayList);
        proxy.add("obj");
       
        verify(serviceRegistry);
    }
View Full Code Here

  @Override
  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(getBeanClassLoader());
  }
View Full Code Here

            beanMap = new BeanMap();
        }
    }

    public ApplicationContext mockContext() {
        ProxyFactory factory = new ProxyFactory();
        factory.setInterfaces(new Class[] { ApplicationContext.class });
        factory.addAdvice(new BeanMapInterceptor(beanMap));
        return (ApplicationContext) factory.getProxy();
    }
View Full Code Here

   * @see RemoteInvocationTraceInterceptor
   */
  protected Object getProxyForService() {
    checkService();
    checkServiceInterface();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addInterface(getServiceInterface());
    if (this.registerTraceInterceptor != null ?
        this.registerTraceInterceptor.booleanValue() : this.interceptors == null) {
      proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
    }
    if (this.interceptors != null) {
      AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
      for (int i = 0; i < this.interceptors.length; i++) {
        proxyFactory.addAdvisor(adapterRegistry.wrap(this.interceptors[i]));
      }
    }
    proxyFactory.setTarget(getService());
    proxyFactory.setOpaque(true);
    return proxyFactory.getProxy(getBeanClassLoader());
  }
View Full Code Here

      (advices != null ? (Advice[]) advices.toArray(new Advice[advices.size()]) : new Advice[0]));
  }

  public static Object createProxy(Class[] classes, Object target, ClassLoader classLoader,
      BundleContext bundleContext, Advice[] advices) {
    ProxyFactory factory = new ProxyFactory();

    ClassUtils.configureFactoryForClass(factory, classes);

    for (int i = 0; i < advices.length; i++) {
      factory.addAdvice(advices[i]);
    }

    if (target != null)
      factory.setTarget(target);

    // no need to add optimize since it means implicit usage of CGLib always
    // which is determined automatically anyway
    // factory.setOptimize(true);
    factory.setFrozen(true);
    factory.setOpaque(true);
    try {
      return factory.getProxy(classLoader);
    }
    catch (NoClassDefFoundError ncdfe) {
      DebugUtils.debugClassLoadingThrowable(ncdfe, bundleContext.getBundle(), classes);
      throw ncdfe;
    }
View Full Code Here

     * @param the bean for which the proxy is being created.
     */
    public final ProxyFactory createProxyFactory(ProxyFactorySource proxyFactorySource, String beanName, Map<String, String> options) {
       
        proxyFactorySource.init();
        ProxyFactory proxyFactory = proxyFactorySource.getProxyFactory();
        ServiceEndpointTargetSource targetSource = proxyFactorySource.getTargetSource();
       
        addInterceptor(beanName, proxyFactory, targetSource, options);
       
        return proxyFactory;
View Full Code Here

        super.init();
    }

    protected Object maybeGetProxy(ServiceRegistryEntry reference) {
        final StaticServiceReferenceProxyFactorySource proxyFactorySource = new StaticServiceReferenceProxyFactorySource(getProxyTypes(), reference);
        final ProxyFactory proxyFactory = this.proxyFactoryCreator.createProxyFactory(proxyFactorySource, beanName, null);
        return proxyFactory.getProxy();
    }
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.