View Javadoc

    1   package org.codehaus.xfire.transport.http;
    2
    3   import java.net.URL;
    4   import java.util.Enumeration;
    5
    6   import javax.servlet.ServletException;
    7
    8   import org.apache.commons.logging.Log;
    9   import org.apache.commons.logging.LogFactory;
    10  import org.codehaus.xfire.util.XMLServiceBuilder;
    11
    12  /***
    13   * XFire Servlet as Dispatcher including a configuration<br>
    14   * of XFire from services.xml in classpath<br>
    15   * <p>
    16   */
    17  public class XFireConfigurableServlet
    18      extends XFireServlet
    19  {
    20
    21      private final static String CONFIG_FILE = "META-INF/xfire/services.xml";
    22
    23      private final static String ENCODING_STYLE_URI = "http://schemas.xmlsoap.org/soap/encoding/";
    24
    25      private final static String SOAP_12 = "1.2";
    26
    27      private Log log = LogFactory.getLog(XFireConfigurableServlet.class);
    28
    29      /***
    30       * @see javax.servlet.Servlet#init()
    31       */
    32      public void init()
    33          throws ServletException
    34      {
    35          super.init();
    36          try
    37          {
    38              configureXFire();
    39          }
    40          catch (Exception e)
    41          {
    42              log.error("Couldn't configure XFire", e);
    43          }
    44      }
    45
    46      protected void configureXFire()
    47          throws Exception
    48      {
    49          XMLServiceBuilder builder = new XMLServiceBuilder(getXFire());
    50          log.info("Searching for META-INF/xfire/services.xml");
    51
    52          // get services.xml
    53          Enumeration en = getClass().getClassLoader().getResources(CONFIG_FILE);
    54          while (en.hasMoreElements())
    55          {
    56              URL resource = (URL) en.nextElement();
    57
    58              builder.buildServices( resource.openStream() );
    59          }
    60      }
    61
    62  }