XFire

Home
Bug/Issue Reporting
Download
FAQ
Get Involved
License
News
Stack Comparison
Support
User's Guide
XFire Team

M5

Javadocs
Reports

M6-SNAPSHOT

Javadocs
Reports

Developers

Developer Space
CVS
Building
Architecture
Interesting Projects
Release Process

Using another Service Factory

These examples show the XFireExporter in action, but this can work just as well with the ServiceBean class since XFireExporter extends ServiceBean.

Annotations

If you want to export annotated beans, the only thing you have to is to use a different ServiceFactory. First define the AnnotationServiceFactory:

<bean id="xfire.annotationServiceFactory"
        class="org.codehaus.xfire.annotations.AnnotationServiceFactory">
        <constructor-arg index="0">
            <ref bean="xfire.commonsAnnotations"/>
        </constructor-arg>
        <constructor-arg index="1">
            <ref bean="xfire.transportManager"/>
        </constructor-arg>
        <constructor-arg index="2">
            <ref bean="xfire.aegisBindingProvider"/>
        </constructor-arg>
    </bean>

    <bean id="xfire.commonsAnnotations"
        class="org.codehaus.xfire.annotations.commons.CommonsWebAttributes"/>

Then you'll need to use it when exporting your service:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
  <bean name="/Echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    <property name="service"><ref bean="echo"/></property>
    <property name="serviceInterface"><value>org.codehaus.xfire.spring.Echo</value></property>
    <property name="serviceBuilder"><ref bean="xfire.annotationServiceFactory"/></property>
    <property name="xfire"><ref bean="xfire"/></property>
  </bean>

  <bean id="echo" class="org.codehaus.xfire.spring.EchoImpl"/>
</beans>

XMLBeans

If you want to use XMLBeans and Spring, you'll need to declare a ServiceFactory for XMLBeans:

<bean id="xfire.xmlbeansServiceFactory"
       class="org.codehaus.xfire.xmlbeans.XmlBeansServiceFactory"
       singleton="true">
       <constructor-arg index="0">
           <ref bean="xfire.transportManager"/>
       </constructor-arg>
 </bean>

or, if you wish to use setter-injection, you need to also declare the XMLBeansBindingProvider. Declare it using:

<bean id="xfire.xmlbeansServiceFactory"
        class="org.codehaus.xfire.xmlbeans.XmlBeansServiceFactory"
        singleton="true">
        <property name="transportManager">
            <ref bean="xfire.transportManager"/>
        </property>
    </bean>

Then, you would declare your bean with a reference to this ServiceFactory instead of the default one.

<bean name="/Echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    <property name="service"><ref bean="echo"/></property>
    <property name="serviceInterface"><value>org.codehaus.xfire.spring.Echo</value></property>
    <property name="serviceFactory"><ref bean="xfire.xmlbeansServiceFactory"/></property>
    <property name="xfire"><ref bean="xfire"/></property>
  </bean>