aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormkos <none@none>2014-02-14 11:13:45 +0100
committermkos <none@none>2014-02-14 11:13:45 +0100
commitf9f8752d9a8bd292934111d86025b1b292c582b6 (patch)
treea5c102209bd114100f90d62915262f1045df9409 /src
parent57c1edcfabccb1d7b8eeddd5e3a43f5d3a5ddf74 (diff)
downloadjdk8u_jaxws-f9f8752d9a8bd292934111d86025b1b292c582b6.tar.gz
8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin Reviewed-by: ahgross, mgrebac, skoivu
Diffstat (limited to 'src')
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java12
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java12
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java11
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java24
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java55
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java11
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java68
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java82
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java11
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java13
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java12
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java11
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java28
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java86
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties27
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java16
36 files changed, 1443 insertions, 166 deletions
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java
new file mode 100644
index 00000000..153b6118
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.ws.wsdl.parser;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java
index 449f4dcb..c153cce7 100644
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -60,12 +60,10 @@ import java.util.Set;
*/
public class Internalizer {
- private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
- private final XPath xpath = xpf.newXPath();
+ private final XPath xpath = xpf.get().newXPath();
private final DOMForest forest;
private final ErrorReceiver errorReceiver;
-
public Internalizer(DOMForest forest, WsimportOptions options, ErrorReceiver errorReceiver) {
this.forest = forest;
this.errorReceiver = errorReceiver;
@@ -77,6 +75,12 @@ public class Internalizer {
}
}
+ private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
+ @Override
+ protected XPathFactory initialValue() throws Exception {
+ return XPathFactory.newInstance();
+ }
+ };
/**
* Validates attributes of a &lt;JAXWS:bindings> element.
*/
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java
index 52546947..0f122222 100644
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -54,8 +54,14 @@ import java.util.Map;
public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler {
// xml security enabled always, xpath used for parsing "part" attribute
- private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
- private final XPath xpath = xpf.newXPath();
+ private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
+ @Override
+ protected XPathFactory initialValue() throws Exception {
+ return XPathFactory.newInstance();
+ }
+ };
+
+ private final XPath xpath = xpf.get().newXPath();
public JAXWSBindingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap) {
super(extensionHandlerMap);
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java
new file mode 100644
index 00000000..f1331485
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.xjc.reader.internalizer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java
index fe5becb3..fbd74515 100644
--- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java
+++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java
@@ -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
@@ -76,8 +76,6 @@ class Internalizer {
private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
- private static XPathFactory xpf = null;
-
private final XPath xpath;
/**
@@ -99,12 +97,7 @@ class Internalizer {
this.errorHandler = forest.getErrorHandler();
this.forest = forest;
this.enableSCD = enableSCD;
- synchronized (this) {
- if (xpf == null) {
- xpf = XmlFactory.createXPathFactory(disableSecureProcessing);
- }
- }
- xpath = xpf.newXPath();
+ xpath = XmlFactory.createXPathFactory(disableSecureProcessing).newXPath();
}
/**
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java
index 8454c632..f7b1db6b 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java
@@ -129,14 +129,6 @@ public final class JAXBContextImpl extends JAXBRIContext {
private final Map<TypeReference,Bridge> bridges = new LinkedHashMap<TypeReference,Bridge>();
/**
- * Shared instance of {@link TransformerFactory}.
- * Lock before use, because a {@link TransformerFactory} is not thread-safe
- * whereas {@link JAXBContextImpl} is.
- * Lazily created.
- */
- private volatile static SAXTransformerFactory tf;
-
- /**
* Shared instance of {@link DocumentBuilder}.
* Lock before use. Lazily created.
*/
@@ -705,13 +697,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
*/
static Transformer createTransformer(boolean disableSecureProcessing) {
try {
- if (tf==null) {
- synchronized(JAXBContextImpl.class) {
- if (tf==null) {
- tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
- }
- }
- }
+ SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformer();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
@@ -723,13 +709,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
*/
public static TransformerHandler createTransformerHandler(boolean disableSecureProcessing) {
try {
- if (tf==null) {
- synchronized(JAXBContextImpl.class) {
- if (tf==null) {
- tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
- }
- }
- }
+ SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformerHandler();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java
new file mode 100644
index 00000000..366035ea
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.messaging.saaj.soap;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..a15e12e0
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for StaticCache utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java
index ce674de8..a60fdc79 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java
@@ -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.Transformer;
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 @@ import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTran
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> parserPool =
+ new ContextClassloaderLocal<ParserPool>() {
+ @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 @@ public class EnvelopeFactory {
}
}
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 @@ public class EnvelopeFactory {
} 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 @@ public class EnvelopeFactory {
}
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);
}
}
}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java
new file mode 100644
index 00000000..60c05162
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.stream.buffer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java
index c6c68344..85166778 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -370,7 +370,12 @@ public abstract class XMLStreamBuffer {
writeTo(handler, errorHandler, isFragment());
}
- private static final TransformerFactory trnsformerFactory = TransformerFactory.newInstance();
+ private static final ContextClassloaderLocal<TransformerFactory> trnsformerFactory = new ContextClassloaderLocal<TransformerFactory>() {
+ @Override
+ protected TransformerFactory initialValue() throws Exception {
+ return TransformerFactory.newInstance();
+ }
+ };
/**
* Writes out the contents of this buffer as DOM node and append that to the given node.
@@ -382,7 +387,7 @@ public abstract class XMLStreamBuffer {
*/
public final Node writeTo(Node n) throws XMLStreamBufferException {
try {
- Transformer t = trnsformerFactory.newTransformer();
+ Transformer t = trnsformerFactory.get().newTransformer();
t.transform(new XMLStreamBufferSource(this), new DOMResult(n));
return n.getLastChild();
} catch (TransformerException e) {
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java
new file mode 100644
index 00000000..56831f59
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.api.streaming;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java
index db6cbc62..40a51184 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -63,39 +63,43 @@ public abstract class XMLStreamReaderFactory {
private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName());
+ private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
+
/**
* Singleton instance.
*/
- private static volatile @NotNull XMLStreamReaderFactory theInstance;
-
- private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
-
- static {
- XMLInputFactory xif = getXMLInputFactory();
- XMLStreamReaderFactory f=null;
+ private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader =
+ new ContextClassloaderLocal<XMLStreamReaderFactory>() {
- // this system property can be used to disable the pooling altogether,
- // in case someone hits an issue with pooling in the production system.
- if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
- f = Zephyr.newInstance(xif);
- }
-
- if(f==null) {
- // is this Woodstox?
- if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
- f = new Woodstox(xif);
- }
- }
-
- if (f==null) {
- f = new Default();
- }
-
- theInstance = f;
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance);
- }
- }
+ @Override
+ protected XMLStreamReaderFactory initialValue() {
+
+ XMLInputFactory xif = getXMLInputFactory();
+ XMLStreamReaderFactory f=null;
+
+ // this system property can be used to disable the pooling altogether,
+ // in case someone hits an issue with pooling in the production system.
+ if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
+ f = Zephyr.newInstance(xif);
+ }
+
+ if(f==null) {
+ // is this Woodstox?
+ if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
+ f = new Woodstox(xif);
+ }
+ }
+
+ if (f==null) {
+ f = new Default();
+ }
+
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f);
+ }
+ return f;
+ }
+ };
private static XMLInputFactory getXMLInputFactory() {
XMLInputFactory xif = null;
@@ -126,11 +130,11 @@ public abstract class XMLStreamReaderFactory {
if(f==null) {
throw new IllegalArgumentException();
}
- theInstance = f;
+ streamReader.set(f);
}
public static XMLStreamReaderFactory get() {
- return theInstance;
+ return streamReader.get();
}
public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
index 51f5da94..6cff489b 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -62,52 +62,54 @@ public abstract class XMLStreamWriterFactory {
/**
* Singleton instance.
*/
- private static volatile @NotNull XMLStreamWriterFactory theInstance;
+ private static volatile ContextClassloaderLocal<XMLStreamWriterFactory> writerFactory =
+ new ContextClassloaderLocal<XMLStreamWriterFactory>() {
-
- static {
- XMLOutputFactory xof = null;
- if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
- try {
- xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
- } catch (Exception e) {
- // Ignore and fallback to default XMLOutputFactory
+ @Override
+ protected XMLStreamWriterFactory initialValue() {
+ XMLOutputFactory xof = null;
+ if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
+ try {
+ xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
+ } catch (Exception e) {
+ // Ignore and fallback to default XMLOutputFactory
+ }
+ }
+ if (xof == null) {
+ xof = XMLOutputFactory.newInstance();
}
- }
- if (xof == null) {
- xof = XMLOutputFactory.newInstance();
- }
- XMLStreamWriterFactory f=null;
+ XMLStreamWriterFactory f=null;
- // this system property can be used to disable the pooling altogether,
- // in case someone hits an issue with pooling in the production system.
- if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) {
- try {
- Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
- if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
- f = new Zephyr(xof,clazz);
+ // this system property can be used to disable the pooling altogether,
+ // in case someone hits an issue with pooling in the production system.
+ if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) {
+ try {
+ Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
+ if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
+ f = new Zephyr(xof,clazz);
+ }
+ } catch (XMLStreamException ex) {
+ Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
+ } catch (NoSuchMethodException ex) {
+ Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
}
- } catch (XMLStreamException ex) {
- Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
- } catch (NoSuchMethodException ex) {
- Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
}
- }
- if(f==null) {
- // is this Woodstox?
- if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
- f = new NoLock(xof);
- }
- if (f == null)
- f = new Default(xof);
+ if(f==null) {
+ // is this Woodstox?
+ if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
+ f = new NoLock(xof);
+ }
+ if (f == null)
+ f = new Default(xof);
- theInstance = f;
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);
+ }
+ return f;
}
- }
+ };
/**
* See {@link #create(OutputStream)} for the contract.
@@ -170,7 +172,7 @@ public abstract class XMLStreamWriterFactory {
* Gets the singleton instance.
*/
public static @NotNull XMLStreamWriterFactory get() {
- return theInstance;
+ return writerFactory.get();
}
/**
@@ -183,7 +185,7 @@ public abstract class XMLStreamWriterFactory {
@SuppressWarnings({"null", "ConstantConditions"})
public static void set(@NotNull XMLStreamWriterFactory f) {
if(f==null) throw new IllegalArgumentException();
- theInstance = f;
+ writerFactory.set(f);
}
/**
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java
new file mode 100644
index 00000000..492e2441
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.commons.xmlutil;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java
index 31d1d713..0cad920e 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java
@@ -53,7 +53,12 @@ public final class Converter {
// prevents instantiation
}
private static final Logger LOGGER = Logger.getLogger(Converter.class);
- private static final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
+ private static final ContextClassloaderLocal<XMLOutputFactory> xmlOutputFactory = new ContextClassloaderLocal<XMLOutputFactory>() {
+ @Override
+ protected XMLOutputFactory initialValue() throws Exception {
+ return XMLOutputFactory.newInstance();
+ }
+ };
private static final AtomicBoolean logMissingStaxUtilsWarning = new AtomicBoolean(false);
/**
@@ -110,7 +115,7 @@ public final class Converter {
stringOut = new StringWriter();
XMLStreamWriter writer = null;
try {
- writer = xmlOutputFactory.createXMLStreamWriter(stringOut);
+ writer = xmlOutputFactory.get().createXMLStreamWriter(stringOut);
if (createIndenter) {
writer = createIndenter(writer);
}
@@ -143,7 +148,7 @@ public final class Converter {
try {
if (message != null) {
- XMLStreamWriter xsw = xmlOutputFactory.createXMLStreamWriter(baos, encoding);
+ XMLStreamWriter xsw = xmlOutputFactory.get().createXMLStreamWriter(baos, encoding);
try {
message.writeTo(xsw);
} finally {
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java
new file mode 100644
index 00000000..51da5ed8
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.developer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java
index e5a96231..ee70a409 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -64,7 +64,12 @@ import java.util.Map;
@XmlType(name = "EndpointReferenceType", namespace = MemberSubmissionEndpointReference.MSNS)
public final class MemberSubmissionEndpointReference extends EndpointReference implements MemberSubmissionAddressingConstants {
- private final static JAXBContext msjc = MemberSubmissionEndpointReference.getMSJaxbContext();
+ private final static ContextClassloaderLocal<JAXBContext> msjc = new ContextClassloaderLocal<JAXBContext>() {
+ @Override
+ protected JAXBContext initialValue() throws Exception {
+ return MemberSubmissionEndpointReference.getMSJaxbContext();
+ }
+ };
public MemberSubmissionEndpointReference() {
}
@@ -86,7 +91,7 @@ public final class MemberSubmissionEndpointReference extends EndpointReference i
}
try {
- Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.createUnmarshaller();
+ Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.get().createUnmarshaller();
MemberSubmissionEndpointReference epr = unmarshaller.unmarshal(source,MemberSubmissionEndpointReference.class).getValue();
this.addr = epr.addr;
@@ -106,7 +111,7 @@ public final class MemberSubmissionEndpointReference extends EndpointReference i
@Override
public void writeTo(Result result) {
try {
- Marshaller marshaller = MemberSubmissionEndpointReference.msjc.createMarshaller();
+ Marshaller marshaller = MemberSubmissionEndpointReference.msjc.get().createMarshaller();
//marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.marshal(this, result);
} catch (JAXBException e) {
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java
new file mode 100644
index 00000000..a9a73812
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.policy.sourcemodel.attach;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java
index c91683fe..aaed1d8f 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, 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
@@ -83,7 +83,13 @@ public class ExternalAttachmentsUnmarshaller {
private static final QName POLICY = new QName("http://www.w3.org/ns/ws-policy", "Policy");
private static final QName URI = new QName("http://www.w3.org/ns/ws-policy", "URI");
private static final QName POLICIES = new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "Policies");
- private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
+ private static final ContextClassloaderLocal<XMLInputFactory> XML_INPUT_FACTORY = new ContextClassloaderLocal<XMLInputFactory>() {
+ @Override
+ protected XMLInputFactory initialValue() throws Exception {
+ return XMLInputFactory.newInstance();
+ }
+ };
+
private static final PolicyModelUnmarshaller POLICY_UNMARSHALLER = PolicyModelUnmarshaller.getXmlUnmarshaller();
private final Map<URI, Policy> map = new HashMap<URI, Policy>();
@@ -93,7 +99,7 @@ public class ExternalAttachmentsUnmarshaller {
public static Map<URI, Policy> unmarshal(final Reader source) throws PolicyException {
LOGGER.entering(source);
try {
- XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(source);
+ XMLEventReader reader = XML_INPUT_FACTORY.get().createXMLEventReader(source);
ExternalAttachmentsUnmarshaller instance = new ExternalAttachmentsUnmarshaller();
final Map<URI, Policy> map = instance.unmarshal(reader, null);
LOGGER.exiting(map);
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java
new file mode 100644
index 00000000..ac0883a8
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.spi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..a15e12e0
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for StaticCache utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java
index 05b7a2f0..30f5a7d8 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -80,7 +80,12 @@ import java.util.Map;
*/
public class ProviderImpl extends Provider {
- private final static JAXBContext eprjc = getEPRJaxbContext();
+ private final static ContextClassloaderLocal<JAXBContext> eprjc = new ContextClassloaderLocal<JAXBContext>() {
+ @Override
+ protected JAXBContext initialValue() throws Exception {
+ return getEPRJaxbContext();
+ }
+ };
/**
* Convenient singleton instance.
@@ -148,7 +153,7 @@ public class ProviderImpl extends Provider {
return AccessController.doPrivileged(new PrivilegedAction<EndpointReference>() {
public EndpointReference run() {
try {
- Unmarshaller unmarshaller = eprjc.createUnmarshaller();
+ Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
} catch (JAXBException e) {
throw new WebServiceException("Error creating Marshaller or marshalling.", e);
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java
new file mode 100644
index 00000000..38f246b2
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.util.xml;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..a15e12e0
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for StaticCache utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
index f6b63d48..cd87c3b0 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -215,20 +215,28 @@ public class XmlUtil {
}
}
- static final TransformerFactory transformerFactory = newTransformerFactory();
-
- static final SAXParserFactory saxParserFactory = newSAXParserFactory(true);
+ static final ContextClassloaderLocal<TransformerFactory> transformerFactory = new ContextClassloaderLocal<TransformerFactory>() {
+ @Override
+ protected TransformerFactory initialValue() throws Exception {
+ return TransformerFactory.newInstance();
+ }
+ };
- static {
- saxParserFactory.setNamespaceAware(true);
- }
+ static final ContextClassloaderLocal<SAXParserFactory> saxParserFactory = new ContextClassloaderLocal<SAXParserFactory>() {
+ @Override
+ protected SAXParserFactory initialValue() throws Exception {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ return factory;
+ }
+ };
/**
* Creates a new identity transformer.
*/
public static Transformer newTransformer() {
try {
- return transformerFactory.newTransformer();
+ return transformerFactory.get().newTransformer();
} catch (TransformerConfigurationException tex) {
throw new IllegalStateException("Unable to create a JAXP transformer");
}
@@ -243,9 +251,9 @@ public class XmlUtil {
// work around a bug in JAXP in JDK6u4 and earlier where the namespace processing
// is not turned on by default
StreamSource ssrc = (StreamSource) src;
- TransformerHandler th = ((SAXTransformerFactory) transformerFactory).newTransformerHandler();
+ TransformerHandler th = ((SAXTransformerFactory) transformerFactory.get()).newTransformerHandler();
th.setResult(result);
- XMLReader reader = saxParserFactory.newSAXParser().getXMLReader();
+ XMLReader reader = saxParserFactory.get().newSAXParser().getXMLReader();
reader.setContentHandler(th);
reader.setProperty(LEXICAL_HANDLER_PROPERTY, th);
reader.parse(toInputSource(ssrc));
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java
new file mode 100644
index 00000000..9bfd0b05
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.xsom.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties
new file mode 100644
index 00000000..1a8fc17a
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java
index 93fbd0fc..ed2a0522 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java
@@ -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
@@ -63,10 +63,15 @@ public class DomAnnotationParserFactory implements AnnotationParserFactory {
}
public AnnotationParser create(boolean disableSecureProcessing) {
- return new AnnotationParserImpl();
+ return new AnnotationParserImpl(disableSecureProcessing);
}
- private static final SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ private static final ContextClassloaderLocal<SAXTransformerFactory> stf = new ContextClassloaderLocal<SAXTransformerFactory>() {
+ @Override
+ protected SAXTransformerFactory initialValue() throws Exception {
+ return (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ }
+ };
private static class AnnotationParserImpl extends AnnotationParser {
@@ -82,8 +87,9 @@ public class DomAnnotationParserFactory implements AnnotationParserFactory {
AnnotationParserImpl(boolean disableSecureProcessing) {
try {
- transformer = stf.newTransformerHandler();
- stf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing);
+ SAXTransformerFactory factory = stf.get();
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing);
+ transformer = factory.newTransformerHandler();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
}