View Javadoc

    1   package org.codehaus.xfire.spring;
    2
    3   import javax.servlet.ServletConfig;
    4   import javax.servlet.ServletException;
    5
    6   import org.codehaus.xfire.XFire;
    7   import org.codehaus.xfire.transport.http.XFireServlet;
    8   import org.springframework.context.ApplicationContext;
    9   import org.springframework.web.context.support.WebApplicationContextUtils;
    10
    11  /***
    12   * An servlet which exposes XFire services via Spring.
    13   *
    14   * @author Jason Carreira <jcarreira@eplus.com>
    15   */
    16  public class XFireSpringServlet
    17      extends XFireServlet
    18  {
    19      private String xfireBeanName = "xfire";
    20
    21      private XFire xfire;
    22
    23      public void init(ServletConfig servletConfig)
    24          throws ServletException
    25      {
    26          ApplicationContext appContext = WebApplicationContextUtils
    27                  .getRequiredWebApplicationContext(servletConfig.getServletContext());
    28          String configBeanName = servletConfig.getInitParameter("XFireBeanName");
    29
    30          xfireBeanName = ((configBeanName != null) && (!"".equals(configBeanName.trim()))) ? configBeanName
    31                  : xfireBeanName;
    32
    33          xfire = (XFire) appContext.getBean(xfireBeanName, XFire.class);
    34          super.init(servletConfig);
    35      }
    36
    37      public XFire createXFire()
    38      {
    39          return xfire;
    40      }
    41  }