Package org.eclipse.xsd.util

Examples of org.eclipse.xsd.util.JAXPPool


    }
  }
 
  private static void doSerialize(OutputStream outputStream, Document document, Map options) throws IOException
  {
    JAXPPool jaxpPool = null;
    JAXPConfiguration config = null;
    String encoding = null;
   
    if (options != null)
    {
      jaxpPool = (JAXPPool)options.get(WSDL_JAXP_POOL);
      config = (JAXPConfiguration)options.get(WSDL_JAXP_CONFIG);
      encoding = (String)options.get(WSDL_ENCODING);
    }
   
    if (jaxpPool == null)
    {
      if (config == null)
      {
        doSerialize(outputStream, document, encoding);
      }
      else
      {
        try
        {
          Transformer transformer = config.createTransformer(encoding);
          // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null.
          encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
          Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding);
          transformer.transform(new DOMSource(document), new StreamResult(writer));
        }
        catch (TransformerException exception)
        {
          WSDLPlugin.getPlugin().log(exception);
        }
      }
    }
    else
    {
      Transformer transformer = null;
      try
      {
        transformer = jaxpPool.getTransformer(encoding);
        Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding);
        transformer.transform(new DOMSource(document), new StreamResult(writer));
      }
      catch (TransformerException exception)
      {
        WSDLPlugin.INSTANCE.log(exception);
      }
      finally
      {
        jaxpPool.releaseTransformer(transformer);
      }
    }
  }
View Full Code Here


   * @return document DOM document
   * @throws IOException
   */
  private static Document getDocument(InputSource inputSource, ErrorHandler errorHandler, Map options) throws IOException
  {
    JAXPPool jaxpPool = null;
    JAXPConfiguration config = null;
    if (options != null)
    {
      jaxpPool = (JAXPPool)options.get(WSDL_JAXP_POOL);
      config = (JAXPConfiguration)options.get(WSDL_JAXP_CONFIG);
    }

    if (jaxpPool == null)
    {
      if (config == null)
      {
        return getDocument(inputSource, errorHandler);
      }
      else
      {
        try
        {
          DocumentBuilder documentBuilder = config.createDocumentBuilder(errorHandler);
          Document document = documentBuilder.parse(inputSource);
          return document;
        }
        catch (ParserConfigurationException exception)
        {
          throw new IOWrappedException(exception);
        }
        catch (SAXException exception)
        {
          throw new IOWrappedException(exception);
        }
      }
    }
    else
    {
      DocumentBuilder documentBuilder = null;
      try
      {
        documentBuilder = jaxpPool.getDocumentBuilder(errorHandler);
        Document document = documentBuilder.parse(inputSource);
        return document;
      }
      catch (ParserConfigurationException exception)
      {
        throw new IOWrappedException(exception);
      }
      catch (SAXException exception)
      {
        throw new IOWrappedException(exception);
      }
      finally
      {
        jaxpPool.releaseDocumentBuilder(documentBuilder);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.util.JAXPPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.