View Javadoc

    1   package org.codehaus.xfire.spring;
    2
    3   import org.codehaus.xfire.annotations.AnnotationServiceFactory;
    4   import org.codehaus.xfire.annotations.WebAnnotations;
    5   import org.codehaus.xfire.service.Service;
    6   import org.codehaus.xfire.service.ServiceRegistry;
    7   import org.codehaus.xfire.service.binding.BeanInvoker;
    8   import org.springframework.beans.BeansException;
    9   import org.springframework.beans.factory.config.BeanPostProcessor;
    10
    11  /***
    12   * This BeanPostProcessor will create an XFire service from a service class if and only if
    13   * it is marked with the JSR 181 @WebService attribute. This replaces the need for using the
    14   * ServiceComponent class.
    15   *
    16   * @see org.codehaus.xfire.spring.ServiceBean
    17   * @author Jason Carreira <jcarreira@eplus.com>
    18   */
    19  public class Jsr181BeanPostProcessor
    20      implements BeanPostProcessor
    21  {
    22      private WebAnnotations annotations;
    23
    24      private AnnotationServiceFactory serviceFactory;
    25
    26      private ServiceRegistry registry;
    27
    28      public Jsr181BeanPostProcessor(WebAnnotations annotations,
    29              AnnotationServiceFactory serviceFactory, ServiceRegistry registry)
    30      {
    31          this.annotations = annotations;
    32          this.serviceFactory = serviceFactory;
    33          this.registry = registry;
    34      }
    35
    36      public Object postProcessBeforeInitialization(Object bean, String beanName)
    37          throws BeansException
    38      {
    39          return bean;
    40      }
    41
    42      public Object postProcessAfterInitialization(Object bean, String beanName)
    43          throws BeansException
    44      {
    45          Class clazz = bean.getClass();
    46          if (annotations.hasWebServiceAnnotation(clazz))
    47          {
    48              Service service = serviceFactory.create(clazz);
    49              service.getBinding().setInvoker(new BeanInvoker(bean));
    50              registry.register(service);
    51          }
    52          return bean;
    53      }
    54  }