Codehaus XFire

Documentation

Quicklinks

Developers

Sponsors

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 you'll need to define an AnnotationServiceFactory. Here is one that works on Java 1.5:

<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.jsr181.Jsr181WebAnnotations"/>

And here is one that works on Java 1.4 via Commons Attributes:

<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="serviceBean" ref="echo"/>
    <property name="serviceClass"><value>org.codehaus.xfire.spring.Echo</value></property>
    <property name="serviceFactory"><ref bean="xfire.annotationServiceFactory"/>
  </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="serviceBean"><ref bean="echo"/></property>
    <property name="serviceClass"><value>org.codehaus.xfire.spring.Echo</value></property>
    <property name="serviceFactory"><ref bean="xfire.xmlbeansServiceFactory"/></property>
  </bean>