Ejemplo n.º 1
0
  public Object readObject(MessageReader mreader, MessageContext context) throws XFireFault {
    StaxBuilder builder = new StaxBuilder();
    try {
      XMLStreamReader reader = ((ElementReader) mreader).getXMLStreamReader();

      if (reader instanceof JDOMStreamReader) {
        return ((JDOMStreamReader) reader).getCurrentElement();
      }

      return builder.build(reader).getRootElement();
    } catch (XMLStreamException e) {
      throw new XFireFault("Could not parse xml.", e, XFireFault.SENDER);
    }
  }
  /**
   * @param service
   * @return
   */
  protected Document loadDocument(ServiceInfo service) {

    Class clazz = service.getServiceClass();
    // get class name w/o .java suffix
    int idx = clazz.getName().lastIndexOf(".");
    String className = clazz.getName().substring(idx + 1);
    String fileName = className + CONFIG_SUFIX;
    log.debug("Searching for " + fileName + " config..");
    InputStream inStr = clazz.getResourceAsStream(fileName);
    if (inStr == null) {
      log.debug("Config " + fileName + " NOT found.");
      return null;
    }

    StaxBuilder builder = new StaxBuilder();
    try {
      log.debug("Config " + fileName + " found.");
      return builder.build(inStr);
    } catch (XMLStreamException e) {
      throw new XFireRuntimeException(e.getMessage());
    }
  }