cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chen <alex.c...@iona.com>
Subject Re: Injecting the configuration programmatically
Date Fri, 15 Dec 2006 06:20:37 GMT
Hi Willem,

Could I input arguments for CXF bus using a util class directly(i.e. 
setter method) instead of a configuration file?

thanks,
--Alex


Willem Jiang wrote:
> Alex,
> You can inject your configuration by let the SpringBusFactory do not 
> using the default configuration, SpringBusFactory.createBus(String 
> cfgFile, boolean includeDefaults), the spring bus will not try to find 
> other configurations as its default setting.
> If you want the Bus take the effect when you are using the Jaxws-api, 
> you need to call SpringBusFactory.setDefaultBus(Bus bus) which will set 
> the SpringBusFactory's static Bus to the Bus you just create.
> Here is an example of configuration file to show how to write your own 
> minimal size of configuration to support SOAP/HTTP.
> 
> <beans>
>  <import resource="classpath:META-INF/cxf/cxf.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>
>  ...
> </beans>
> 
> Regards,
> Willem.
> Alex Chen wrote:
> 
>> Hi Eoghan,
>>
>> Sorry for not clear in my last email, I only need SOAP/HTTP transport.
>>
>> Cheers,
>> --Alex
>>
>>
>> Glynn, Eoghan wrote:
>>
>>>
>>> Well if you just want to specify a particular configuration file 
>>> programmatically, then the simplest way is to use the 
>>> SpringBusFactory.createBus(String cfgFile) API.
>>>
>>> If you want to *completely* replace the Spring Configurer with your 
>>> own implementation, then use:
>>>
>>>    Bus.setExtension(Configurer.class, myConfigurer);
>>>
>>> If you want to *selectively* inject property values for some 
>>> particular beans (but let the other beans pick up their property 
>>> values from the config file as usual), then I think there's some work 
>>> to do. I'm no Spring expert, and Andrea would be really be person to 
>>> comment definitively on this. However seeing as she's on vacation, 
>>> I'd guess you could try down-casting the Configurer bus extension to 
>>> an org.springframework.beans.factory.wiring.BeanConfigurerSupport, 
>>> then call setBeanFactory() on this to set your own fa├žade 
>>> implementation of 
>>> org.springframework.beans.factory.config.AutowireCapableBeanFactory. 
>>> Then in autowireBeanProperties() and applyBeanPropertyValues(), check 
>>> if the bean being configured is the one you want to selectively 
>>> inject specific property values into. If so, go ahead and do this. If 
>>> not, delegate to the original bean factory.
>>>
>>> There may well be a simpler and better way of doing this. For example 
>>> to avoid getting tangled up in the Spring logic, you could just 
>>> extend the org.apache.cxf.configuartion.spring.ConfigurerImpl to 
>>> allow values for specific beans to be injected into say a local map, 
>>> which is then checked before configureBean() delegates to the 
>>> super-class implementation [i.e. 
>>> org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean()].

>>>
>>>
>>> As always, I'm open to correction by the Spring aficionados.
>>>
>>> Cheers,
>>> Eoghan
>>>
>>>
>>>> -----Original Message-----
>>>> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com] Sent: 14 
>>>> December 2006 09:35
>>>> To: cxf-dev@incubator.apache.org
>>>> Subject: Injecting the configuration programmatically
>>>>
>>>> Hi
>>>>
>>>> Is there any way to inject the configuration into the CXF runtime 
>>>> programmatically ?
>>>> For ex, one way is to tell the runtime where the config is by 
>>>> pointing it to the cxf.xml (default name...). Is there any way to 
>>>> create a required configuration and tell the runtime that the 
>>>> configuration for a given bean name is available ?
>>>>
>>>> Thanks, Sergey
>>>>
>>>
>>
> 
> 

Mime
View raw message