cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Roberts <i.robe...@dcs.shef.ac.uk>
Subject Re: Lazy instantiation of Web Service Client
Date Tue, 12 Feb 2008 23:30:16 GMT
Ian Roberts wrote:
> http://johnheintz.blogspot.com/2007/11/using-lazy-proxy-to-avoid-spring.html 
> 
> 
> The LazyProxyFactoryBean shown in this post basically allows you to wrap 
> up another Spring bean with a proxy that shows the same interface, but 
> delays asking for the "real" bean until the first method call.  Using 
> this in combination with the lazy-init=true trick above should do what 
> you're after.

In fact, it turns out Spring has built-in support for exactly this using 
the AOP ProxyFactoryBean:

<bean id="accountProxyFactory"
       class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"
       lazy-init="true">
   <property name="serviceClass" value="my.web.service.AccountService"/>
   <property name="address" value="${account.service}"/>
</bean>

<bean id="realAccountService" class="my.web.service.AccountService"
       factory-bean="accountProxyFactory" factory-method="create"
       lazy-init="true"/>

<bean id="accountService"
       class="org.springframework.aop.framework.ProxyFactoryBean">
   <property name="targetSource">
     <bean class="org.springframework.aop.target.LazyInitTargetSource">
       <property name="targetBeanName">
         <idref local="realAccountService"/>
       </property>
     </bean>
   </property>
   <property name="proxyInterfaces"
             value="my.web.service.AccountService" />
</bean>

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK

Mime
View raw message