Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Configuring Spring Beans with CXF

DZone's Guide to

Configuring Spring Beans with CXF

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

The Spring IoC can be used to initialize web service implementation classes in CXF.xml. This also means that Soring beans initialized using beanfactory or applicationcontext are also available in CXF configuration.


Thus a datasource or DAO bean initialized by the regulaar spring configuration can be injected into the CXF implementation classes. By CXF implementation class, I mean the SOAP or REST based web service implementation class.

Here is an example of how to initialize the DAO and then inject that DAO bean to the web service class using the CXF.xml

app-context.xml

<beans>
- - - - - - - - - -
- - - - - - - - -
<bean class="com.company.app.SampleDAO" id="sampleDAO">
<property name="sampleDAO">
<ref bean="sampleDAO" />
</property>
</bean>
</beans>
CXF.xml
<bean class="com.company.app.SampleService" id="sampleWebService">
<property name="sampleDAO">
<ref bean="sampleDAO"/>
</property>
</bean>

From http://extreme-java.blogspot.com/2011/05/configuring-spring-beans-with-cxf.html

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}