diff -r 29a761eaff0d -r 6cd506508147 src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java --- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Fri Feb 14 10:53:55 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Fri Feb 14 11:13:45 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,14 @@ package com.sun.xml.internal.messaging.saaj.soap; -import java.util.logging.Logger; +import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; +import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource; +import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; +import com.sun.xml.internal.messaging.saaj.util.ParserPool; +import com.sun.xml.internal.messaging.saaj.util.RejectDoctypeSaxFilter; +import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; import javax.xml.parsers.SAXParser; import javax.xml.soap.SOAPException; @@ -34,14 +41,7 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; - -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; -import com.sun.xml.internal.messaging.saaj.util.*; - -import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; +import java.util.logging.Logger; /** * EnvelopeFactory creates SOAP Envelope objects using different @@ -50,14 +50,19 @@ public class EnvelopeFactory { protected static final Logger - log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, - "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); + log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, + "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); - private static ParserPool parserPool = new ParserPool(5); + private static ContextClassloaderLocal parserPool = + new ContextClassloaderLocal() { + @Override + protected ParserPool initialValue() throws Exception { + return new ParserPool(5); + } + }; public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart) - throws SOAPException - { + throws SOAPException { // Insert SAX filter to disallow Document Type Declarations since // they are not legal in SOAP SAXParser saxParser = null; @@ -73,15 +78,15 @@ } } try { - saxParser = parserPool.get(); + saxParser = parserPool.get().get(); } catch (Exception e) { log.severe("SAAJ0601.util.newSAXParser.exception"); throw new SOAPExceptionImpl( - "Couldn't get a SAX parser while constructing a envelope", - e); + "Couldn't get a SAX parser while constructing a envelope", + e); } InputSource is = SAXSource.sourceToInputSource(src); - if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) { + if (is.getEncoding() == null && soapPart.getSourceCharsetEncoding() != null) { is.setEncoding(soapPart.getSourceCharsetEncoding()); } XMLReader rejectFilter; @@ -90,15 +95,15 @@ } catch (Exception ex) { log.severe("SAAJ0510.soap.cannot.create.envelope"); throw new SOAPExceptionImpl( - "Unable to create envelope from given source: ", - ex); + "Unable to create envelope from given source: ", + ex); } src = new SAXSource(rejectFilter, is); } try { Transformer transformer = - EfficientStreamingTransformer.newTransformer(); + EfficientStreamingTransformer.newTransformer(); DOMResult result = new DOMResult(soapPart); transformer.transform(src, result); @@ -110,11 +115,11 @@ } log.severe("SAAJ0511.soap.cannot.create.envelope"); throw new SOAPExceptionImpl( - "Unable to create envelope from given source: ", - ex); + "Unable to create envelope from given source: ", + ex); } finally { if (saxParser != null) { - parserPool.returnParser(saxParser); + parserPool.get().returnParser(saxParser); } } }