Mercurial > hg > release > icedtea8-forest-3.0 > jaxws
changeset 590:806fa0e68d92 icedtea-3.0.0pre01
Merge jdk8u20-b10
author | andrew |
---|---|
date | Tue, 22 Apr 2014 19:50:42 +0100 |
parents | 596bf4c87d43 (current diff) 84f913145e2a (diff) |
children | 1cd7680df99e |
files | .hgtags |
diffstat | 56 files changed, 1754 insertions(+), 368 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Tue Apr 22 17:15:41 2014 +0100 +++ b/.hgtags Tue Apr 22 19:50:42 2014 +0100 @@ -256,6 +256,22 @@ 8e46fe36e17595c24ccdbde7b34e3cbfb6056b42 jdk8-b127 de172acc095bb1045f40d1c9f532b7350343d19e jdk8-b128 aabc90596123d4eb7e576ecb0e7a843a9415d8eb jdk8-b129 +4195c0956930bf4e161ac6b0def0d6295bfba58f jdk8-b130 +012b935707fa24a1a88b429255f77b386e082643 jdk8-b131 +c2be0dd15dbf0c23ee693a1af32f8f6a012abd1e jdk8-b132 +2fcd3ddb57a6c71e082c7f113f4063de9a967fcd jdk8u5-b01 +384ccf4e14cb90c89570e16a5f4ca440a69d6d93 jdk8u5-b02 +e423a4f2ec72ea0e24bea0fa77dd105095bbee67 jdk8u5-b03 +738b966ee0b00d994445d34eb7eb087bd41a5478 jdk8u5-b04 +3960c6ef7bd1782d6357c510dab393d291164045 jdk8u5-b05 +0543f4dddddc67b142b4706b2d403a654809e605 jdk8u5-b06 +0eb7f9f88e93587ace50614385f85afd221f5cb1 jdk8u5-b07 +3ee93ab2a3739ae5e4e209ac14c36e7374f3f748 jdk8u5-b08 +6cd5065081477be64e4e99ef98ec68464dde2d72 jdk8u5-b09 +22a840b408eb0242e363700843fba3f4988df749 jdk8u5-b10 +75fd3933daaf5826e7c03bfb318026ac8a4c07ef jdk8u5-b11 +e2454d30b525bcb6ebcc711bd2928fbd29c11143 jdk8u5-b12 +d2200a87d5ad6a9d06d9df144376ea5511b3916b jdk8u5-b13 ba061957b8bdb5f04e58154b27405fbf6fe3c71f jdk8u20-b02 337a3a4086235e926e1d684bf4d0b2add70d6f55 jdk8u20-b03 579caba2483ee3c9e32d87b31ab46e86f1aa9cd3 jdk8u20-b04 @@ -265,3 +281,5 @@ c2be0dd15dbf0c23ee693a1af32f8f6a012abd1e jdk8-b132 515ddaddbb6402452f5c6a63594db5d7d71b5aa1 jdk8u20-b06 a61ba2e3e6c85f7067fb7b0c3c02584abdfa96be jdk8u20-b07 +bc6d2f3426f3d04adc8245ad120e2b52fe7dfbde jdk8u20-b08 +2e76ce4ec993c32368ef51b67873aa5ff06e1437 jdk8u20-b09
--- a/THIRD_PARTY_README Tue Apr 22 17:15:41 2014 +0100 +++ b/THIRD_PARTY_README Tue Apr 22 19:50:42 2014 +0100 @@ -1399,13 +1399,13 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Little CMS 2.4, which may be +%% This notice is provided with respect to Little CMS 2.5, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- Little CMS -Copyright (c) 1998-2010 Marti Maria Saguer +Copyright (c) 1998-2011 Marti Maria Saguer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
--- a/src/share/jaf_classes/javax/activation/CommandMap.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaf_classes/javax/activation/CommandMap.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,6 +25,9 @@ package javax.activation; +import java.util.Map; +import java.util.WeakHashMap; + /** * The CommandMap class provides an interface to a registry of @@ -38,6 +41,8 @@ */ public abstract class CommandMap { private static CommandMap defaultCommandMap = null; + private static Map<ClassLoader,CommandMap> map = + new WeakHashMap<ClassLoader,CommandMap>(); /** * Get the default CommandMap. @@ -56,11 +61,18 @@ * * @return the CommandMap */ - public static CommandMap getDefaultCommandMap() { - if (defaultCommandMap == null) - defaultCommandMap = new MailcapCommandMap(); + public static synchronized CommandMap getDefaultCommandMap() { + if (defaultCommandMap != null) + return defaultCommandMap; - return defaultCommandMap; + // fetch per-thread-context-class-loader default + ClassLoader tccl = SecuritySupport.getContextClassLoader(); + CommandMap def = map.get(tccl); + if (def == null) { + def = new MailcapCommandMap(); + map.put(tccl, def); + } + return def; } /** @@ -71,7 +83,7 @@ * @exception SecurityException if the caller doesn't have permission * to change the default */ - public static void setDefaultCommandMap(CommandMap commandMap) { + public static synchronized void setDefaultCommandMap(CommandMap commandMap) { SecurityManager security = System.getSecurityManager(); if (security != null) { try { @@ -79,13 +91,16 @@ security.checkSetFactory(); } catch (SecurityException ex) { // otherwise, we also allow it if this code and the - // factory come from the same class loader (e.g., + // factory come from the same (non-system) class loader (e.g., // the JAF classes were loaded with the applet classes). - if (CommandMap.class.getClassLoader() != + if (CommandMap.class.getClassLoader() == null || + CommandMap.class.getClassLoader() != commandMap.getClass().getClassLoader()) throw ex; } } + // remove any per-thread-context-class-loader CommandMap + map.remove(SecuritySupport.getContextClassLoader()); defaultCommandMap = commandMap; }
--- a/src/share/jaf_classes/javax/activation/DataHandler.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaf_classes/javax/activation/DataHandler.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -368,7 +368,12 @@ // if it's not set, set it... if (transferFlavors == emptyFlavors) transferFlavors = getDataContentHandler().getTransferDataFlavors(); - return transferFlavors; + + if (transferFlavors == emptyFlavors) + return transferFlavors; + else + return transferFlavors.clone(); + } /**
--- a/src/share/jaf_classes/javax/activation/FileTypeMap.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaf_classes/javax/activation/FileTypeMap.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -26,6 +26,8 @@ package javax.activation; import java.io.File; +import java.util.Map; +import java.util.WeakHashMap; /** * The FileTypeMap is an abstract class that provides a data typing @@ -48,6 +50,8 @@ public abstract class FileTypeMap { private static FileTypeMap defaultMap = null; + private static Map<ClassLoader,FileTypeMap> map = + new WeakHashMap<ClassLoader,FileTypeMap>(); /** * The default constructor. @@ -78,11 +82,11 @@ * Sets the default FileTypeMap for the system. This instance * will be returned to callers of getDefaultFileTypeMap. * - * @param map The FileTypeMap. + * @param fileTypeMap The FileTypeMap. * @exception SecurityException if the caller doesn't have permission * to change the default */ - public static void setDefaultFileTypeMap(FileTypeMap map) { + public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) { SecurityManager security = System.getSecurityManager(); if (security != null) { try { @@ -90,14 +94,17 @@ security.checkSetFactory(); } catch (SecurityException ex) { // otherwise, we also allow it if this code and the - // factory come from the same class loader (e.g., + // factory come from the same (non-system) class loader (e.g., // the JAF classes were loaded with the applet classes). - if (FileTypeMap.class.getClassLoader() != - map.getClass().getClassLoader()) + if (FileTypeMap.class.getClassLoader() == null || + FileTypeMap.class.getClassLoader() != + fileTypeMap.getClass().getClassLoader()) throw ex; } } - defaultMap = map; + // remove any per-thread-context-class-loader FileTypeMap + map.remove(SecuritySupport.getContextClassLoader()); + defaultMap = fileTypeMap; } /** @@ -109,10 +116,17 @@ * @return The default FileTypeMap * @see javax.activation.FileTypeMap#setDefaultFileTypeMap */ - public static FileTypeMap getDefaultFileTypeMap() { - // XXX - probably should be synchronized - if (defaultMap == null) - defaultMap = new MimetypesFileTypeMap(); - return defaultMap; + public static synchronized FileTypeMap getDefaultFileTypeMap() { + if (defaultMap != null) + return defaultMap; + + // fetch per-thread-context-class-loader default + ClassLoader tccl = SecuritySupport.getContextClassLoader(); + FileTypeMap def = map.get(tccl); + if (def == null) { + def = new MimetypesFileTypeMap(); + map.put(tccl, def); + } + return def; } }
--- a/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -120,11 +120,7 @@ public class MailcapCommandMap extends CommandMap { /* * We manage a collection of databases, searched in order. - * The default database is shared between all instances - * of this class. - * XXX - Can we safely share more databases between instances? */ - private static MailcapFile defDB = null; private MailcapFile[] DB; private static final int PROG = 0; // programmatically added entries @@ -164,14 +160,10 @@ loadAllResources(dbv, "META-INF/mailcap"); LogSupport.log("MailcapCommandMap: load DEF"); - synchronized (MailcapCommandMap.class) { - // see if another instance has created this yet. - if (defDB == null) - defDB = loadResource("/META-INF/mailcap.default"); - } + mf = loadResource("/META-INF/mailcap.default"); - if (defDB != null) - dbv.add(defDB); + if (mf != null) + dbv.add(mf); DB = new MailcapFile[dbv.size()]; DB = (MailcapFile[])dbv.toArray(DB);
--- a/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -69,11 +69,7 @@ public class MimetypesFileTypeMap extends FileTypeMap { /* * We manage a collection of databases, searched in order. - * The default database is shared between all instances - * of this class. - * XXX - Can we safely share more databases between instances? */ - private static MimeTypeFile defDB = null; private MimeTypeFile[] DB; private static final int PROG = 0; // programmatically added entries @@ -114,14 +110,10 @@ loadAllResources(dbv, "META-INF/mime.types"); LogSupport.log("MimetypesFileTypeMap: load DEF"); - synchronized (MimetypesFileTypeMap.class) { - // see if another instance has created this yet. - if (defDB == null) - defDB = loadResource("/META-INF/mimetypes.default"); - } + mf = loadResource("/META-INF/mimetypes.default"); - if (defDB != null) - dbv.addElement(defDB); + if (mf != null) + dbv.addElement(mf); DB = new MimeTypeFile[dbv.size()]; dbv.copyInto(DB);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ */ 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 @@ } } + private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() { + @Override + protected XPathFactory initialValue() throws Exception { + return XPathFactory.newInstance(); + } + }; /** * Validates attributes of a <JAXWS:bindings> element. */
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ 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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Tue Apr 22 19:50:42 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 @@ -76,8 +76,6 @@ private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/"; - private static XPathFactory xpf = null; - private final XPath xpath; /** @@ -99,12 +97,7 @@ 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(); } /**
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Tue Apr 22 19:50:42 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 @@ -27,9 +27,14 @@ import java.math.BigDecimal; import java.math.BigInteger; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Calendar; +import java.util.Collections; import java.util.GregorianCalendar; +import java.util.Map; import java.util.TimeZone; +import java.util.WeakHashMap; import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverterInterface; @@ -356,7 +361,7 @@ public static GregorianCalendar _parseDateTime(CharSequence s) { String val = WhiteSpaceProcessor.trim(s).toString(); - return datatypeFactory.newXMLGregorianCalendar(val).toGregorianCalendar(); + return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar(); } public static String _printDateTime(Calendar val) { @@ -722,14 +727,30 @@ } return false; } - private static final DatatypeFactory datatypeFactory; + + private static final Map<ClassLoader, DatatypeFactory> DF_CACHE = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DatatypeFactory>()); - static { - try { - datatypeFactory = DatatypeFactory.newInstance(); - } catch (DatatypeConfigurationException e) { - throw new Error(e); + public static DatatypeFactory getDatatypeFactory() { + ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return Thread.currentThread().getContextClassLoader(); + } + }); + DatatypeFactory df = DF_CACHE.get(tccl); + if (df == null) { + synchronized (DatatypeConverterImpl.class) { + df = DF_CACHE.get(tccl); + if (df == null) { // to prevent multiple initialization + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e); + } + DF_CACHE.put(tccl, df); + } + } } + return df; } private static final class CalendarFormatter { @@ -1045,7 +1066,7 @@ @Deprecated public Calendar parseTime(String lexicalXSDTime) { - return datatypeFactory.newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar(); + return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar(); } @Deprecated @@ -1055,7 +1076,7 @@ @Deprecated public Calendar parseDate(String lexicalXSDDate) { - return datatypeFactory.newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar(); + return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar(); } @Deprecated
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.java Tue Apr 22 19:50:42 2014 +0100 @@ -0,0 +1,48 @@ +/* + * 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.bind; + +import java.text.MessageFormat; +import java.util.ResourceBundle; + +/** + * Message resources + */ +enum Messages { + FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args + ; + + private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); + + @Override + public String toString() { + return format(); + } + + public String format( Object... args ) { + return MessageFormat.format( rb.getString(name()), args ); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = \ + Failed to initialize JAXP 1.3 DatatypeFactory class.
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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,7 +60,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY, // 2 args INVALID_XML_ENUM_VALUE, // 2 arg - FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args NO_IMAGE_WRITER, // 1 arg ILLEGAL_MIME_TYPE, // 2 args
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Tue Apr 22 19:50:42 2014 +0100 @@ -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,9 +63,7 @@ import javax.imageio.stream.ImageOutputStream; import javax.xml.bind.ValidationEvent; import javax.xml.bind.helpers.ValidationEventImpl; -import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; @@ -568,7 +566,8 @@ public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { try { - return datatypeFactory.newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) + return DatatypeConverterImpl.getDatatypeFactory() + .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) } catch (Exception e) { UnmarshallingContext.getInstance().handleError(e); return null; @@ -838,7 +837,7 @@ public Duration parse(CharSequence lexical) { TODO.checkSpec("JSR222 Issue #42"); - return datatypeFactory.newDuration(lexical.toString()); + return DatatypeConverterImpl.getDatatypeFactory().newDuration(lexical.toString()); } }); primaryList.add( @@ -879,21 +878,6 @@ } } - - /** - * Cached instance of {@link DatatypeFactory} to create - * {@link XMLGregorianCalendar} and {@link Duration}. - */ - private static final DatatypeFactory datatypeFactory = init(); - - private static DatatypeFactory init() { - try { - return DatatypeFactory.newInstance(); - } catch (DatatypeConfigurationException e) { - throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e); - } - } - private static void checkXmlGregorianCalendarFieldRef(QName type, XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ StringBuilder buf = new StringBuilder();
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Tue Apr 22 19:50:42 2014 +0100 @@ -129,14 +129,6 @@ 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 @@ */ 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 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
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -153,7 +153,6 @@ } } - /** * Reference to FI's XMLStreamWriter class, if FI can be loaded. */ @@ -162,9 +161,8 @@ private static Class initFIStAXWriterClass() { try { - ClassLoader loader = getClassLoader(); - Class llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter", true, loader); - Class sds = loader.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer"); + Class<?> llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter"); + Class<?> sds = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer"); // Check if StAXDocumentSerializer implements LowLevelFastInfosetStreamWriter if (llfisw.isAssignableFrom(sds)) return sds; @@ -179,8 +177,7 @@ try { if (FI_STAX_WRITER_CLASS == null) return null; - ClassLoader loader = getClassLoader(); - Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput", true, loader); + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput"); return c.getConstructor(FI_STAX_WRITER_CLASS, JAXBContextImpl.class); } catch (Throwable e) { return null; @@ -195,8 +192,7 @@ private static Class initStAXExWriterClass() { try { - ClassLoader loader = getClassLoader(); - return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx",true,loader); + return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx"); } catch (Throwable e) { return null; } @@ -204,20 +200,11 @@ private static Constructor<? extends XmlOutput> initStAXExOutputClass() { try { - ClassLoader loader = getClassLoader(); - Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput",true, loader); + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput"); return c.getConstructor(STAXEX_WRITER_CLASS); } catch (Throwable e) { return null; } } - private static ClassLoader getClassLoader() { - ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class); - if (cl == null) { - cl = SecureLoader.getContextClassLoader(); - } - return cl; - } - }
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2011, 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 @@ -38,3 +38,6 @@ NO_GETTER = \ The property has a setter "{0}" but no getter. \ For marshaller, please define getters. + +INVALID_XML_ENUM_VALUE = \ + "{0}" is not a valid value for {1}.
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Tue Apr 22 19:50:42 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -336,9 +336,8 @@ private static Class initFIStAXReaderClass() { try { - ClassLoader cl = getClassLoader(); - Class fisr = cl.loadClass("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader"); - Class sdp = cl.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser"); + Class<?> fisr = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader"); + Class<?> sdp = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser"); // Check if StAXDocumentParser implements FastInfosetStreamReader if (fisr.isAssignableFrom(sdp)) return sdp; @@ -354,7 +353,7 @@ if (FI_STAX_READER_CLASS == null) return null; - Class c = getClassLoader().loadClass( + Class c = Class.forName( "com.sun.xml.internal.bind.v2.runtime.unmarshaller.FastInfosetConnector"); return c.getConstructor(FI_STAX_READER_CLASS,XmlVisitor.class); } catch (Throwable e) { @@ -370,7 +369,7 @@ private static Class initStAXExReader() { try { - return getClassLoader().loadClass("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx"); + return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx"); } catch (Throwable e) { return null; } @@ -378,19 +377,11 @@ private static Constructor<? extends StAXConnector> initStAXExConnector() { try { - Class c = getClassLoader().loadClass("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector"); + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector"); return c.getConstructor(STAX_EX_READER_CLASS,XmlVisitor.class); } catch (Throwable e) { return null; } } - private static ClassLoader getClassLoader() { - ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class); - if (cl == null) { - cl = SecureLoader.getContextClassLoader(); - } - return cl; - } - }
--- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Tue Apr 22 19:50:42 2014 +0100 @@ -62,61 +62,6 @@ Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); - static { - try { - CommandMap map = CommandMap.getDefaultCommandMap(); - if (map instanceof MailcapCommandMap) { - MailcapCommandMap mailMap = (MailcapCommandMap) map; - String hndlrStr = ";;x-java-content-handler="; - mailMap.addMailcap( - "text/xml" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); - mailMap.addMailcap( - "application/xml" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); - mailMap.addMailcap( - "application/fastinfoset" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler"); - /* Image DataContentHandler handles all image types - mailMap.addMailcap( - "image/jpeg" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.JpegDataContentHandler"); - mailMap.addMailcap( - "image/gif" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.GifDataContentHandler"); */ - /*mailMap.addMailcap( - "multipart/*" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");*/ - mailMap.addMailcap( - "image/*" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler"); - mailMap.addMailcap( - "text/plain" - + hndlrStr - + "com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler"); - } else { - throw new SOAPExceptionImpl("Default CommandMap is not a MailcapCommandMap"); - } - } catch (Throwable t) { - log.log( - Level.SEVERE, - "SAAJ0508.soap.cannot.register.handlers", - t); - if (t instanceof RuntimeException) { - throw (RuntimeException) t; - } else { - throw new RuntimeException(t.getLocalizedMessage()); - } - } - }; - private final MimeHeaders headers; private MimeBodyPart rawContent = null; private DataHandler dataHandler = null; @@ -126,6 +71,12 @@ public AttachmentPartImpl() { headers = new MimeHeaders(); + + // initialization from here should cover most of cases; + // if not, it would be necessary to call + // AttachmentPartImpl.initializeJavaActivationHandlers() + // explicitly by programmer + initializeJavaActivationHandlers(); } public AttachmentPartImpl(MIMEPart part) { @@ -404,7 +355,7 @@ throw new SOAPExceptionImpl(e.getLocalizedMessage()); } finally { try { - decoded.close(); + decoded.close(); } catch (IOException ex) { throw new SOAPException(ex); } @@ -613,4 +564,43 @@ return headers; } + public static void initializeJavaActivationHandlers() { + // DataHandler.writeTo() may search for DCH. So adding some default ones. + try { + CommandMap map = CommandMap.getDefaultCommandMap(); + if (map instanceof MailcapCommandMap) { + MailcapCommandMap mailMap = (MailcapCommandMap) map; + + // registering our DCH since javamail's DCH doesn't handle + if (!cmdMapInitialized(mailMap)) { + mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); + mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); + mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler"); + mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler"); + mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler"); + mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler"); + } + } + } catch (Throwable t) { + // ignore the exception. + } + } + + private static boolean cmdMapInitialized(MailcapCommandMap mailMap) { + + // checking fastinfoset handler, since this one is specific to SAAJ + CommandInfo[] commands = mailMap.getAllCommands("application/fastinfoset"); + if (commands == null || commands.length == 0) { + return false; + } + + String saajClassName = "com.sun.xml.internal.ws.binding.FastInfosetDataContentHandler"; + for (CommandInfo command : commands) { + String commandClass = command.getCommandClass(); + if (saajClassName.equals(commandClass)) { + return true; + } + } + return false; + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Tue Apr 22 19:50:42 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> 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 @@ } } 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); } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ 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 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) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ 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 volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader = + new ContextClassloaderLocal<XMLStreamReaderFactory>() { - private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; + @Override + protected XMLStreamReaderFactory initialValue() { - static { - XMLInputFactory xif = getXMLInputFactory(); - XMLStreamReaderFactory f=null; + 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); - } + // 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) { + // is this Woodstox? + if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { + f = new Woodstox(xif); + } + } - if (f==null) { - f = new Default(); - } + if (f==null) { + f = new Default(); + } - theInstance = f; - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance); - } - } + 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 @@ 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) {
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ /** * 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 (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f); + } + return f; } - - 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); - } - } + }; /** * See {@link #create(OutputStream)} for the contract. @@ -170,7 +172,7 @@ * Gets the singleton instance. */ public static @NotNull XMLStreamWriterFactory get() { - return theInstance; + return writerFactory.get(); } /** @@ -183,7 +185,7 @@ @SuppressWarnings({"null", "ConstantConditions"}) public static void set(@NotNull XMLStreamWriterFactory f) { if(f==null) throw new IllegalArgumentException(); - theInstance = f; + writerFactory.set(f); } /**
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Tue Apr 22 19:50:42 2014 +0100 @@ -37,6 +37,9 @@ import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; import com.sun.xml.internal.ws.developer.BindingTypeFeature; +import javax.activation.CommandInfo; +import javax.activation.CommandMap; +import javax.activation.MailcapCommandMap; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebServiceFeature; @@ -151,12 +154,61 @@ return addressingVersion; } - public final @NotNull - Codec createCodec() { + public final Codec createCodec() { + + // initialization from here should cover most of cases; + // if not, it would be necessary to call + // BindingImpl.initializeJavaActivationHandlers() + // explicitly by programmer + initializeJavaActivationHandlers(); + return bindingId.createEncoder(this); } + public static void initializeJavaActivationHandlers() { + // DataHandler.writeTo() may search for DCH. So adding some default ones. + try { + CommandMap map = CommandMap.getDefaultCommandMap(); + if (map instanceof MailcapCommandMap) { + MailcapCommandMap mailMap = (MailcapCommandMap) map; + + // registering our DCH since javamail's DCH doesn't handle + if (!cmdMapInitialized(mailMap)) { + mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); + mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); + mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); + mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); + } + } + } catch (Throwable t) { + // ignore the exception. + } + } + + private static boolean cmdMapInitialized(MailcapCommandMap mailMap) { + CommandInfo[] commands = mailMap.getAllCommands("text/xml"); + if (commands == null || commands.length == 0) { + return false; + } + + // SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too; + // see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers + // so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here + // is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl. + // This is also reason for duplication of Handler's code by JAX-WS + String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"; + String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler"; + for (CommandInfo command : commands) { + String commandClass = command.getCommandClass(); + if (saajClassName.equals(commandClass) || + jaxwsClassName.equals(commandClass)) { + return true; + } + } + return false; + } + public static BindingImpl create(@NotNull BindingID bindingId) { if (bindingId.equals(BindingID.XML_HTTP)) return new HTTPBindingImpl();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Tue Apr 22 19:50:42 2014 +0100 @@ -53,7 +53,12 @@ // 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 @@ 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 @@ try { if (message != null) { - XMLStreamWriter xsw = xmlOutputFactory.createXMLStreamWriter(baos, encoding); + XMLStreamWriter xsw = xmlOutputFactory.get().createXMLStreamWriter(baos, encoding); try { message.writeTo(xsw); } finally {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ @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 @@ } 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 @@ @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) {
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Tue Apr 22 19:50:42 2014 +0100 @@ -34,8 +34,6 @@ import com.sun.xml.internal.ws.api.pipe.Codec; import com.sun.xml.internal.ws.api.pipe.ContentType; import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature; -import javax.activation.CommandMap; -import javax.activation.MailcapCommandMap; import java.io.IOException; import java.io.InputStream; @@ -63,33 +61,6 @@ */ abstract class MimeCodec implements Codec { - static { - // DataHandler.writeTo() may search for DCH. So adding some default ones. - try { - CommandMap map = CommandMap.getDefaultCommandMap(); - if (map instanceof MailcapCommandMap) { - MailcapCommandMap mailMap = (MailcapCommandMap) map; - String hndlrStr = ";;x-java-content-handler="; - // registering our DCH since javamail's DCH doesn't handle - // Source - mailMap.addMailcap( - "text/xml" + hndlrStr + XmlDataContentHandler.class.getName()); - mailMap.addMailcap( - "application/xml" + hndlrStr + XmlDataContentHandler.class.getName()); - if (map.createDataContentHandler("image/*") == null) { - mailMap.addMailcap( - "image/*" + hndlrStr + ImageDataContentHandler.class.getName()); - } - if (map.createDataContentHandler("text/plain") == null) { - mailMap.addMailcap( - "text/plain" + hndlrStr + StringDataContentHandler.class.getName()); - } - } - } catch (Throwable t) { - // ignore the exception. - } - } - public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related"; protected Codec mimeRootCodec;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ 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 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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ */ 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 @@ 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);
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties Tue Apr 22 19:50:42 2014 +0100 @@ -26,4 +26,4 @@ build-id=2.2.9-b130926.1035 build-version=JAX-WS RI 2.2.9-b130926.1035 major-version=2.2.9 -svn-revision=8c29a9a53251ff741fca1664a8221dc876b2eac8 +svn-revision=5f6196f2b90e9460065a4c2f4e30e065b245e51e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ } } - 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 @@ // 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));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java Tue Apr 22 19:50:42 2014 +0100 @@ -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; + } + }); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties Tue Apr 22 19:50:42 2014 +0100 @@ -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} +
--- a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Tue Apr 22 19:50:42 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 @@ -63,10 +63,15 @@ } 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 @@ 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 }
--- a/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Tue Apr 22 17:15:41 2014 +0100 +++ b/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Tue Apr 22 19:50:42 2014 +0100 @@ -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 @@ -69,7 +69,7 @@ @XmlType(name="EndpointReferenceType",namespace=W3CEndpointReference.NS) public final class W3CEndpointReference extends EndpointReference { - private final static JAXBContext w3cjc = getW3CJaxbContext(); + private final JAXBContext w3cjc = getW3CJaxbContext(); // should be changed to package private, keeping original modifier to keep backwards compatibility protected static final String NS = "http://www.w3.org/2005/08/addressing";