View Javadoc

    1   package org.codehaus.xfire.jaxb;
    2
    3   import org.codehaus.xfire.aegis.AegisBindingProvider;
    4   import org.codehaus.xfire.service.Service;
    5   import org.codehaus.xfire.service.binding.ObjectServiceFactory;
    6   import org.codehaus.xfire.transport.TransportManager;
    7
    8   import javax.xml.bind.JAXBContext;
    9   import javax.xml.namespace.QName;
    10  import java.lang.reflect.Method;
    11
    12  /***
    13   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    14   */
    15  public class JaxbServiceFactory
    16          extends ObjectServiceFactory
    17  {
    18      JaxbIntrospector jaxbIntrospector;
    19
    20      public JaxbServiceFactory(TransportManager transportManager, JAXBContext jaxbContext)
    21      {
    22          super(transportManager);
    23          jaxbIntrospector = new JaxbIntrospector(jaxbContext);
    24          AegisBindingProvider provider = new AegisBindingProvider(new JaxbTypeRegistry(jaxbContext));
    25          setBindingProvider(provider);
    26      }
    27
    28      protected QName getInParameterName(Service service, Method method, int paramNumber, boolean doc)
    29      {
    30          Class[] paramClasses = method.getParameterTypes();
    31          if (JaxbTypeCreator.isJaxbType(paramClasses[paramNumber]))
    32          {
    33              return jaxbIntrospector.introspect(paramClasses[paramNumber]);
    34          } else
    35          {
    36              return super.getInParameterName(service, method, paramNumber, doc);
    37          }
    38      }
    39
    40      protected QName getOutParameterName(Service service, Method method, boolean doc)
    41      {
    42          Class clazz = method.getReturnType();
    43          if (JaxbTypeCreator.isJaxbType(clazz))
    44          {
    45              return jaxbIntrospector.introspect(clazz);
    46          } else
    47          {
    48              return super.getOutParameterName(service, method, doc);
    49          }
    50      }
    51  }