Fri, 14 Mar 2014 23:01:25 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Wed Mar 12 14:11:06 2014 -0700 1.2 +++ b/.hgtags Fri Mar 14 23:01:25 2014 -0700 1.3 @@ -253,6 +253,21 @@ 1.4 8e46fe36e17595c24ccdbde7b34e3cbfb6056b42 jdk8-b127 1.5 de172acc095bb1045f40d1c9f532b7350343d19e jdk8-b128 1.6 aabc90596123d4eb7e576ecb0e7a843a9415d8eb jdk8-b129 1.7 +4195c0956930bf4e161ac6b0def0d6295bfba58f jdk8-b130 1.8 +012b935707fa24a1a88b429255f77b386e082643 jdk8-b131 1.9 +c2be0dd15dbf0c23ee693a1af32f8f6a012abd1e jdk8-b132 1.10 +2fcd3ddb57a6c71e082c7f113f4063de9a967fcd jdk8u5-b01 1.11 +384ccf4e14cb90c89570e16a5f4ca440a69d6d93 jdk8u5-b02 1.12 +e423a4f2ec72ea0e24bea0fa77dd105095bbee67 jdk8u5-b03 1.13 +738b966ee0b00d994445d34eb7eb087bd41a5478 jdk8u5-b04 1.14 +3960c6ef7bd1782d6357c510dab393d291164045 jdk8u5-b05 1.15 +0543f4dddddc67b142b4706b2d403a654809e605 jdk8u5-b06 1.16 +0eb7f9f88e93587ace50614385f85afd221f5cb1 jdk8u5-b07 1.17 +3ee93ab2a3739ae5e4e209ac14c36e7374f3f748 jdk8u5-b08 1.18 +6cd5065081477be64e4e99ef98ec68464dde2d72 jdk8u5-b09 1.19 +22a840b408eb0242e363700843fba3f4988df749 jdk8u5-b10 1.20 +75fd3933daaf5826e7c03bfb318026ac8a4c07ef jdk8u5-b11 1.21 +e2454d30b525bcb6ebcc711bd2928fbd29c11143 jdk8u5-b12 1.22 ba061957b8bdb5f04e58154b27405fbf6fe3c71f jdk8u20-b02 1.23 337a3a4086235e926e1d684bf4d0b2add70d6f55 jdk8u20-b03 1.24 579caba2483ee3c9e32d87b31ab46e86f1aa9cd3 jdk8u20-b04
2.1 --- a/THIRD_PARTY_README Wed Mar 12 14:11:06 2014 -0700 2.2 +++ b/THIRD_PARTY_README Fri Mar 14 23:01:25 2014 -0700 2.3 @@ -1399,13 +1399,13 @@ 2.4 2.5 ------------------------------------------------------------------------------- 2.6 2.7 -%% This notice is provided with respect to Little CMS 2.4, which may be 2.8 +%% This notice is provided with respect to Little CMS 2.5, which may be 2.9 included with JRE 8, JDK 8, and OpenJDK 8. 2.10 2.11 --- begin of LICENSE --- 2.12 2.13 Little CMS 2.14 -Copyright (c) 1998-2010 Marti Maria Saguer 2.15 +Copyright (c) 1998-2011 Marti Maria Saguer 2.16 2.17 Permission is hereby granted, free of charge, to any person obtaining a copy 2.18 of this software and associated documentation files (the "Software"), to deal
3.1 --- a/src/share/jaf_classes/javax/activation/CommandMap.java Wed Mar 12 14:11:06 2014 -0700 3.2 +++ b/src/share/jaf_classes/javax/activation/CommandMap.java Fri Mar 14 23:01:25 2014 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -25,6 +25,9 @@ 3.11 3.12 package javax.activation; 3.13 3.14 +import java.util.Map; 3.15 +import java.util.WeakHashMap; 3.16 + 3.17 3.18 /** 3.19 * The CommandMap class provides an interface to a registry of 3.20 @@ -38,6 +41,8 @@ 3.21 */ 3.22 public abstract class CommandMap { 3.23 private static CommandMap defaultCommandMap = null; 3.24 + private static Map<ClassLoader,CommandMap> map = 3.25 + new WeakHashMap<ClassLoader,CommandMap>(); 3.26 3.27 /** 3.28 * Get the default CommandMap. 3.29 @@ -56,11 +61,18 @@ 3.30 * 3.31 * @return the CommandMap 3.32 */ 3.33 - public static CommandMap getDefaultCommandMap() { 3.34 - if (defaultCommandMap == null) 3.35 - defaultCommandMap = new MailcapCommandMap(); 3.36 + public static synchronized CommandMap getDefaultCommandMap() { 3.37 + if (defaultCommandMap != null) 3.38 + return defaultCommandMap; 3.39 3.40 - return defaultCommandMap; 3.41 + // fetch per-thread-context-class-loader default 3.42 + ClassLoader tccl = SecuritySupport.getContextClassLoader(); 3.43 + CommandMap def = map.get(tccl); 3.44 + if (def == null) { 3.45 + def = new MailcapCommandMap(); 3.46 + map.put(tccl, def); 3.47 + } 3.48 + return def; 3.49 } 3.50 3.51 /** 3.52 @@ -71,7 +83,7 @@ 3.53 * @exception SecurityException if the caller doesn't have permission 3.54 * to change the default 3.55 */ 3.56 - public static void setDefaultCommandMap(CommandMap commandMap) { 3.57 + public static synchronized void setDefaultCommandMap(CommandMap commandMap) { 3.58 SecurityManager security = System.getSecurityManager(); 3.59 if (security != null) { 3.60 try { 3.61 @@ -79,13 +91,16 @@ 3.62 security.checkSetFactory(); 3.63 } catch (SecurityException ex) { 3.64 // otherwise, we also allow it if this code and the 3.65 - // factory come from the same class loader (e.g., 3.66 + // factory come from the same (non-system) class loader (e.g., 3.67 // the JAF classes were loaded with the applet classes). 3.68 - if (CommandMap.class.getClassLoader() != 3.69 + if (CommandMap.class.getClassLoader() == null || 3.70 + CommandMap.class.getClassLoader() != 3.71 commandMap.getClass().getClassLoader()) 3.72 throw ex; 3.73 } 3.74 } 3.75 + // remove any per-thread-context-class-loader CommandMap 3.76 + map.remove(SecuritySupport.getContextClassLoader()); 3.77 defaultCommandMap = commandMap; 3.78 } 3.79
4.1 --- a/src/share/jaf_classes/javax/activation/DataHandler.java Wed Mar 12 14:11:06 2014 -0700 4.2 +++ b/src/share/jaf_classes/javax/activation/DataHandler.java Fri Mar 14 23:01:25 2014 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -368,7 +368,12 @@ 4.11 // if it's not set, set it... 4.12 if (transferFlavors == emptyFlavors) 4.13 transferFlavors = getDataContentHandler().getTransferDataFlavors(); 4.14 - return transferFlavors; 4.15 + 4.16 + if (transferFlavors == emptyFlavors) 4.17 + return transferFlavors; 4.18 + else 4.19 + return transferFlavors.clone(); 4.20 + 4.21 } 4.22 4.23 /**
5.1 --- a/src/share/jaf_classes/javax/activation/FileTypeMap.java Wed Mar 12 14:11:06 2014 -0700 5.2 +++ b/src/share/jaf_classes/javax/activation/FileTypeMap.java Fri Mar 14 23:01:25 2014 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -26,6 +26,8 @@ 5.11 package javax.activation; 5.12 5.13 import java.io.File; 5.14 +import java.util.Map; 5.15 +import java.util.WeakHashMap; 5.16 5.17 /** 5.18 * The FileTypeMap is an abstract class that provides a data typing 5.19 @@ -48,6 +50,8 @@ 5.20 public abstract class FileTypeMap { 5.21 5.22 private static FileTypeMap defaultMap = null; 5.23 + private static Map<ClassLoader,FileTypeMap> map = 5.24 + new WeakHashMap<ClassLoader,FileTypeMap>(); 5.25 5.26 /** 5.27 * The default constructor. 5.28 @@ -78,11 +82,11 @@ 5.29 * Sets the default FileTypeMap for the system. This instance 5.30 * will be returned to callers of getDefaultFileTypeMap. 5.31 * 5.32 - * @param map The FileTypeMap. 5.33 + * @param fileTypeMap The FileTypeMap. 5.34 * @exception SecurityException if the caller doesn't have permission 5.35 * to change the default 5.36 */ 5.37 - public static void setDefaultFileTypeMap(FileTypeMap map) { 5.38 + public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) { 5.39 SecurityManager security = System.getSecurityManager(); 5.40 if (security != null) { 5.41 try { 5.42 @@ -90,14 +94,17 @@ 5.43 security.checkSetFactory(); 5.44 } catch (SecurityException ex) { 5.45 // otherwise, we also allow it if this code and the 5.46 - // factory come from the same class loader (e.g., 5.47 + // factory come from the same (non-system) class loader (e.g., 5.48 // the JAF classes were loaded with the applet classes). 5.49 - if (FileTypeMap.class.getClassLoader() != 5.50 - map.getClass().getClassLoader()) 5.51 + if (FileTypeMap.class.getClassLoader() == null || 5.52 + FileTypeMap.class.getClassLoader() != 5.53 + fileTypeMap.getClass().getClassLoader()) 5.54 throw ex; 5.55 } 5.56 } 5.57 - defaultMap = map; 5.58 + // remove any per-thread-context-class-loader FileTypeMap 5.59 + map.remove(SecuritySupport.getContextClassLoader()); 5.60 + defaultMap = fileTypeMap; 5.61 } 5.62 5.63 /** 5.64 @@ -109,10 +116,17 @@ 5.65 * @return The default FileTypeMap 5.66 * @see javax.activation.FileTypeMap#setDefaultFileTypeMap 5.67 */ 5.68 - public static FileTypeMap getDefaultFileTypeMap() { 5.69 - // XXX - probably should be synchronized 5.70 - if (defaultMap == null) 5.71 - defaultMap = new MimetypesFileTypeMap(); 5.72 - return defaultMap; 5.73 + public static synchronized FileTypeMap getDefaultFileTypeMap() { 5.74 + if (defaultMap != null) 5.75 + return defaultMap; 5.76 + 5.77 + // fetch per-thread-context-class-loader default 5.78 + ClassLoader tccl = SecuritySupport.getContextClassLoader(); 5.79 + FileTypeMap def = map.get(tccl); 5.80 + if (def == null) { 5.81 + def = new MimetypesFileTypeMap(); 5.82 + map.put(tccl, def); 5.83 + } 5.84 + return def; 5.85 } 5.86 }
6.1 --- a/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Wed Mar 12 14:11:06 2014 -0700 6.2 +++ b/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Fri Mar 14 23:01:25 2014 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -120,11 +120,7 @@ 6.11 public class MailcapCommandMap extends CommandMap { 6.12 /* 6.13 * We manage a collection of databases, searched in order. 6.14 - * The default database is shared between all instances 6.15 - * of this class. 6.16 - * XXX - Can we safely share more databases between instances? 6.17 */ 6.18 - private static MailcapFile defDB = null; 6.19 private MailcapFile[] DB; 6.20 private static final int PROG = 0; // programmatically added entries 6.21 6.22 @@ -164,14 +160,10 @@ 6.23 loadAllResources(dbv, "META-INF/mailcap"); 6.24 6.25 LogSupport.log("MailcapCommandMap: load DEF"); 6.26 - synchronized (MailcapCommandMap.class) { 6.27 - // see if another instance has created this yet. 6.28 - if (defDB == null) 6.29 - defDB = loadResource("/META-INF/mailcap.default"); 6.30 - } 6.31 + mf = loadResource("/META-INF/mailcap.default"); 6.32 6.33 - if (defDB != null) 6.34 - dbv.add(defDB); 6.35 + if (mf != null) 6.36 + dbv.add(mf); 6.37 6.38 DB = new MailcapFile[dbv.size()]; 6.39 DB = (MailcapFile[])dbv.toArray(DB);
7.1 --- a/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Wed Mar 12 14:11:06 2014 -0700 7.2 +++ b/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Fri Mar 14 23:01:25 2014 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -69,11 +69,7 @@ 7.11 public class MimetypesFileTypeMap extends FileTypeMap { 7.12 /* 7.13 * We manage a collection of databases, searched in order. 7.14 - * The default database is shared between all instances 7.15 - * of this class. 7.16 - * XXX - Can we safely share more databases between instances? 7.17 */ 7.18 - private static MimeTypeFile defDB = null; 7.19 private MimeTypeFile[] DB; 7.20 private static final int PROG = 0; // programmatically added entries 7.21 7.22 @@ -114,14 +110,10 @@ 7.23 loadAllResources(dbv, "META-INF/mime.types"); 7.24 7.25 LogSupport.log("MimetypesFileTypeMap: load DEF"); 7.26 - synchronized (MimetypesFileTypeMap.class) { 7.27 - // see if another instance has created this yet. 7.28 - if (defDB == null) 7.29 - defDB = loadResource("/META-INF/mimetypes.default"); 7.30 - } 7.31 + mf = loadResource("/META-INF/mimetypes.default"); 7.32 7.33 - if (defDB != null) 7.34 - dbv.addElement(defDB); 7.35 + if (mf != null) 7.36 + dbv.addElement(mf); 7.37 7.38 DB = new MimeTypeFile[dbv.size()]; 7.39 dbv.copyInto(DB);
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 8.3 @@ -0,0 +1,86 @@ 8.4 +/* 8.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. Oracle designates this 8.11 + * particular file as subject to the "Classpath" exception as provided 8.12 + * by Oracle in the LICENSE file that accompanied this code. 8.13 + * 8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.17 + * version 2 for more details (a copy is included in the LICENSE file that 8.18 + * accompanied this code). 8.19 + * 8.20 + * You should have received a copy of the GNU General Public License version 8.21 + * 2 along with this work; if not, write to the Free Software Foundation, 8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.23 + * 8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.25 + * or visit www.oracle.com if you need additional information or have any 8.26 + * questions. 8.27 + */ 8.28 + 8.29 +package com.sun.tools.internal.ws.wsdl.parser; 8.30 + 8.31 +import java.security.AccessController; 8.32 +import java.security.PrivilegedAction; 8.33 +import java.text.MessageFormat; 8.34 +import java.util.ResourceBundle; 8.35 +import java.util.WeakHashMap; 8.36 + 8.37 +/** 8.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 8.39 + */ 8.40 +abstract class ContextClassloaderLocal<V> { 8.41 + 8.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 8.43 + 8.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 8.45 + 8.46 + public V get() throws Error { 8.47 + ClassLoader tccl = getContextClassLoader(); 8.48 + V instance = CACHE.get(tccl); 8.49 + if (instance == null) { 8.50 + instance = createNewInstance(); 8.51 + CACHE.put(tccl, instance); 8.52 + } 8.53 + return instance; 8.54 + } 8.55 + 8.56 + public void set(V instance) { 8.57 + CACHE.put(getContextClassLoader(), instance); 8.58 + } 8.59 + 8.60 + protected abstract V initialValue() throws Exception; 8.61 + 8.62 + private V createNewInstance() { 8.63 + try { 8.64 + return initialValue(); 8.65 + } catch (Exception e) { 8.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 8.67 + } 8.68 + } 8.69 + 8.70 + private static String format(String property, Object... args) { 8.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 8.72 + return MessageFormat.format(text, args); 8.73 + } 8.74 + 8.75 + private static ClassLoader getContextClassLoader() { 8.76 + return (ClassLoader) 8.77 + AccessController.doPrivileged(new PrivilegedAction() { 8.78 + public Object run() { 8.79 + ClassLoader cl = null; 8.80 + try { 8.81 + cl = Thread.currentThread().getContextClassLoader(); 8.82 + } catch (SecurityException ex) { 8.83 + } 8.84 + return cl; 8.85 + } 8.86 + }); 8.87 + } 8.88 +} 8.89 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 9.3 @@ -0,0 +1,27 @@ 9.4 +# 9.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 9.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 +# 9.8 +# This code is free software; you can redistribute it and/or modify it 9.9 +# under the terms of the GNU General Public License version 2 only, as 9.10 +# published by the Free Software Foundation. Oracle designates this 9.11 +# particular file as subject to the "Classpath" exception as provided 9.12 +# by Oracle in the LICENSE file that accompanied this code. 9.13 +# 9.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 9.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.17 +# version 2 for more details (a copy is included in the LICENSE file that 9.18 +# accompanied this code). 9.19 +# 9.20 +# You should have received a copy of the GNU General Public License version 9.21 +# 2 along with this work; if not, write to the Free Software Foundation, 9.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.23 +# 9.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.25 +# or visit www.oracle.com if you need additional information or have any 9.26 +# questions. 9.27 +# 9.28 +# Error messages for ContextClassloaderLocal utility class 9.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 9.30 +
10.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Wed Mar 12 14:11:06 2014 -0700 10.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Fri Mar 14 23:01:25 2014 -0700 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -60,12 +60,10 @@ 10.11 */ 10.12 public class Internalizer { 10.13 10.14 - private static final XPathFactory xpf = XmlUtil.newXPathFactory(true); 10.15 - private final XPath xpath = xpf.newXPath(); 10.16 + private final XPath xpath = xpf.get().newXPath(); 10.17 private final DOMForest forest; 10.18 private final ErrorReceiver errorReceiver; 10.19 10.20 - 10.21 public Internalizer(DOMForest forest, WsimportOptions options, ErrorReceiver errorReceiver) { 10.22 this.forest = forest; 10.23 this.errorReceiver = errorReceiver; 10.24 @@ -77,6 +75,12 @@ 10.25 } 10.26 } 10.27 10.28 + private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() { 10.29 + @Override 10.30 + protected XPathFactory initialValue() throws Exception { 10.31 + return XPathFactory.newInstance(); 10.32 + } 10.33 + }; 10.34 /** 10.35 * Validates attributes of a <JAXWS:bindings> element. 10.36 */
11.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Wed Mar 12 14:11:06 2014 -0700 11.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Fri Mar 14 23:01:25 2014 -0700 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -54,8 +54,14 @@ 11.11 public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler { 11.12 11.13 // xml security enabled always, xpath used for parsing "part" attribute 11.14 - private static final XPathFactory xpf = XmlUtil.newXPathFactory(true); 11.15 - private final XPath xpath = xpf.newXPath(); 11.16 + private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() { 11.17 + @Override 11.18 + protected XPathFactory initialValue() throws Exception { 11.19 + return XPathFactory.newInstance(); 11.20 + } 11.21 + }; 11.22 + 11.23 + private final XPath xpath = xpf.get().newXPath(); 11.24 11.25 public JAXWSBindingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap) { 11.26 super(extensionHandlerMap);
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 12.3 @@ -0,0 +1,86 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. Oracle designates this 12.11 + * particular file as subject to the "Classpath" exception as provided 12.12 + * by Oracle in the LICENSE file that accompanied this code. 12.13 + * 12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 + * version 2 for more details (a copy is included in the LICENSE file that 12.18 + * accompanied this code). 12.19 + * 12.20 + * You should have received a copy of the GNU General Public License version 12.21 + * 2 along with this work; if not, write to the Free Software Foundation, 12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 + * 12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.25 + * or visit www.oracle.com if you need additional information or have any 12.26 + * questions. 12.27 + */ 12.28 + 12.29 +package com.sun.tools.internal.xjc.reader.internalizer; 12.30 + 12.31 +import java.security.AccessController; 12.32 +import java.security.PrivilegedAction; 12.33 +import java.text.MessageFormat; 12.34 +import java.util.ResourceBundle; 12.35 +import java.util.WeakHashMap; 12.36 + 12.37 +/** 12.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 12.39 + */ 12.40 +abstract class ContextClassloaderLocal<V> { 12.41 + 12.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 12.43 + 12.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 12.45 + 12.46 + public V get() throws Error { 12.47 + ClassLoader tccl = getContextClassLoader(); 12.48 + V instance = CACHE.get(tccl); 12.49 + if (instance == null) { 12.50 + instance = createNewInstance(); 12.51 + CACHE.put(tccl, instance); 12.52 + } 12.53 + return instance; 12.54 + } 12.55 + 12.56 + public void set(V instance) { 12.57 + CACHE.put(getContextClassLoader(), instance); 12.58 + } 12.59 + 12.60 + protected abstract V initialValue() throws Exception; 12.61 + 12.62 + private V createNewInstance() { 12.63 + try { 12.64 + return initialValue(); 12.65 + } catch (Exception e) { 12.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 12.67 + } 12.68 + } 12.69 + 12.70 + private static String format(String property, Object... args) { 12.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 12.72 + return MessageFormat.format(text, args); 12.73 + } 12.74 + 12.75 + private static ClassLoader getContextClassLoader() { 12.76 + return (ClassLoader) 12.77 + AccessController.doPrivileged(new PrivilegedAction() { 12.78 + public Object run() { 12.79 + ClassLoader cl = null; 12.80 + try { 12.81 + cl = Thread.currentThread().getContextClassLoader(); 12.82 + } catch (SecurityException ex) { 12.83 + } 12.84 + return cl; 12.85 + } 12.86 + }); 12.87 + } 12.88 +} 12.89 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 13.3 @@ -0,0 +1,27 @@ 13.4 +# 13.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 +# 13.8 +# This code is free software; you can redistribute it and/or modify it 13.9 +# under the terms of the GNU General Public License version 2 only, as 13.10 +# published by the Free Software Foundation. Oracle designates this 13.11 +# particular file as subject to the "Classpath" exception as provided 13.12 +# by Oracle in the LICENSE file that accompanied this code. 13.13 +# 13.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 13.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.17 +# version 2 for more details (a copy is included in the LICENSE file that 13.18 +# accompanied this code). 13.19 +# 13.20 +# You should have received a copy of the GNU General Public License version 13.21 +# 2 along with this work; if not, write to the Free Software Foundation, 13.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.23 +# 13.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.25 +# or visit www.oracle.com if you need additional information or have any 13.26 +# questions. 13.27 +# 13.28 +# Error messages for ContextClassloaderLocal utility class 13.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 13.30 +
14.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Wed Mar 12 14:11:06 2014 -0700 14.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Fri Mar 14 23:01:25 2014 -0700 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -76,8 +76,6 @@ 14.11 14.12 private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/"; 14.13 14.14 - private static XPathFactory xpf = null; 14.15 - 14.16 private final XPath xpath; 14.17 14.18 /** 14.19 @@ -99,12 +97,7 @@ 14.20 this.errorHandler = forest.getErrorHandler(); 14.21 this.forest = forest; 14.22 this.enableSCD = enableSCD; 14.23 - synchronized (this) { 14.24 - if (xpf == null) { 14.25 - xpf = XmlFactory.createXPathFactory(disableSecureProcessing); 14.26 - } 14.27 - } 14.28 - xpath = xpf.newXPath(); 14.29 + xpath = XmlFactory.createXPathFactory(disableSecureProcessing).newXPath(); 14.30 } 14.31 14.32 /**
15.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Wed Mar 12 14:11:06 2014 -0700 15.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Fri Mar 14 23:01:25 2014 -0700 15.3 @@ -1,5 +1,5 @@ 15.4 /* 15.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 15.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 15.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.8 * 15.9 * This code is free software; you can redistribute it and/or modify it 15.10 @@ -27,9 +27,14 @@ 15.11 15.12 import java.math.BigDecimal; 15.13 import java.math.BigInteger; 15.14 +import java.security.AccessController; 15.15 +import java.security.PrivilegedAction; 15.16 import java.util.Calendar; 15.17 +import java.util.Collections; 15.18 import java.util.GregorianCalendar; 15.19 +import java.util.Map; 15.20 import java.util.TimeZone; 15.21 +import java.util.WeakHashMap; 15.22 15.23 import javax.xml.bind.DatatypeConverter; 15.24 import javax.xml.bind.DatatypeConverterInterface; 15.25 @@ -356,7 +361,7 @@ 15.26 15.27 public static GregorianCalendar _parseDateTime(CharSequence s) { 15.28 String val = WhiteSpaceProcessor.trim(s).toString(); 15.29 - return datatypeFactory.newXMLGregorianCalendar(val).toGregorianCalendar(); 15.30 + return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar(); 15.31 } 15.32 15.33 public static String _printDateTime(Calendar val) { 15.34 @@ -722,14 +727,30 @@ 15.35 } 15.36 return false; 15.37 } 15.38 - private static final DatatypeFactory datatypeFactory; 15.39 15.40 - static { 15.41 - try { 15.42 - datatypeFactory = DatatypeFactory.newInstance(); 15.43 - } catch (DatatypeConfigurationException e) { 15.44 - throw new Error(e); 15.45 + private static final Map<ClassLoader, DatatypeFactory> DF_CACHE = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DatatypeFactory>()); 15.46 + 15.47 + public static DatatypeFactory getDatatypeFactory() { 15.48 + ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { 15.49 + public ClassLoader run() { 15.50 + return Thread.currentThread().getContextClassLoader(); 15.51 + } 15.52 + }); 15.53 + DatatypeFactory df = DF_CACHE.get(tccl); 15.54 + if (df == null) { 15.55 + synchronized (DatatypeConverterImpl.class) { 15.56 + df = DF_CACHE.get(tccl); 15.57 + if (df == null) { // to prevent multiple initialization 15.58 + try { 15.59 + df = DatatypeFactory.newInstance(); 15.60 + } catch (DatatypeConfigurationException e) { 15.61 + throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e); 15.62 + } 15.63 + DF_CACHE.put(tccl, df); 15.64 + } 15.65 + } 15.66 } 15.67 + return df; 15.68 } 15.69 15.70 private static final class CalendarFormatter { 15.71 @@ -1045,7 +1066,7 @@ 15.72 15.73 @Deprecated 15.74 public Calendar parseTime(String lexicalXSDTime) { 15.75 - return datatypeFactory.newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar(); 15.76 + return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar(); 15.77 } 15.78 15.79 @Deprecated 15.80 @@ -1055,7 +1076,7 @@ 15.81 15.82 @Deprecated 15.83 public Calendar parseDate(String lexicalXSDDate) { 15.84 - return datatypeFactory.newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar(); 15.85 + return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar(); 15.86 } 15.87 15.88 @Deprecated
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.java Fri Mar 14 23:01:25 2014 -0700 16.3 @@ -0,0 +1,48 @@ 16.4 +/* 16.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. Oracle designates this 16.11 + * particular file as subject to the "Classpath" exception as provided 16.12 + * by Oracle in the LICENSE file that accompanied this code. 16.13 + * 16.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.17 + * version 2 for more details (a copy is included in the LICENSE file that 16.18 + * accompanied this code). 16.19 + * 16.20 + * You should have received a copy of the GNU General Public License version 16.21 + * 2 along with this work; if not, write to the Free Software Foundation, 16.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.23 + * 16.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 16.25 + * or visit www.oracle.com if you need additional information or have any 16.26 + * questions. 16.27 + */ 16.28 + 16.29 +package com.sun.xml.internal.bind; 16.30 + 16.31 +import java.text.MessageFormat; 16.32 +import java.util.ResourceBundle; 16.33 + 16.34 +/** 16.35 + * Message resources 16.36 + */ 16.37 +enum Messages { 16.38 + FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args 16.39 + ; 16.40 + 16.41 + private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); 16.42 + 16.43 + @Override 16.44 + public String toString() { 16.45 + return format(); 16.46 + } 16.47 + 16.48 + public String format( Object... args ) { 16.49 + return MessageFormat.format( rb.getString(name()), args ); 16.50 + } 16.51 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.properties Fri Mar 14 23:01:25 2014 -0700 17.3 @@ -0,0 +1,27 @@ 17.4 +# 17.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 17.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 +# 17.8 +# This code is free software; you can redistribute it and/or modify it 17.9 +# under the terms of the GNU General Public License version 2 only, as 17.10 +# published by the Free Software Foundation. Oracle designates this 17.11 +# particular file as subject to the "Classpath" exception as provided 17.12 +# by Oracle in the LICENSE file that accompanied this code. 17.13 +# 17.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 17.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.17 +# version 2 for more details (a copy is included in the LICENSE file that 17.18 +# accompanied this code). 17.19 +# 17.20 +# You should have received a copy of the GNU General Public License version 17.21 +# 2 along with this work; if not, write to the Free Software Foundation, 17.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.23 +# 17.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 17.25 +# or visit www.oracle.com if you need additional information or have any 17.26 +# questions. 17.27 +# 17.28 + 17.29 +FAILED_TO_INITIALE_DATATYPE_FACTORY = \ 17.30 + Failed to initialize JAXP 1.3 DatatypeFactory class.
18.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Wed Mar 12 14:11:06 2014 -0700 18.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Fri Mar 14 23:01:25 2014 -0700 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -60,7 +60,6 @@ 18.11 PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY, // 2 args 18.12 18.13 INVALID_XML_ENUM_VALUE, // 2 arg 18.14 - FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args 18.15 NO_IMAGE_WRITER, // 1 arg 18.16 18.17 ILLEGAL_MIME_TYPE, // 2 args
19.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Wed Mar 12 14:11:06 2014 -0700 19.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Fri Mar 14 23:01:25 2014 -0700 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -63,9 +63,7 @@ 19.11 import javax.imageio.stream.ImageOutputStream; 19.12 import javax.xml.bind.ValidationEvent; 19.13 import javax.xml.bind.helpers.ValidationEventImpl; 19.14 -import javax.xml.datatype.DatatypeConfigurationException; 19.15 import javax.xml.datatype.DatatypeConstants; 19.16 -import javax.xml.datatype.DatatypeFactory; 19.17 import javax.xml.datatype.Duration; 19.18 import javax.xml.datatype.XMLGregorianCalendar; 19.19 import javax.xml.namespace.QName; 19.20 @@ -568,7 +566,8 @@ 19.21 19.22 public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { 19.23 try { 19.24 - return datatypeFactory.newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) 19.25 + return DatatypeConverterImpl.getDatatypeFactory() 19.26 + .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) 19.27 } catch (Exception e) { 19.28 UnmarshallingContext.getInstance().handleError(e); 19.29 return null; 19.30 @@ -838,7 +837,7 @@ 19.31 19.32 public Duration parse(CharSequence lexical) { 19.33 TODO.checkSpec("JSR222 Issue #42"); 19.34 - return datatypeFactory.newDuration(lexical.toString()); 19.35 + return DatatypeConverterImpl.getDatatypeFactory().newDuration(lexical.toString()); 19.36 } 19.37 }); 19.38 primaryList.add( 19.39 @@ -879,21 +878,6 @@ 19.40 } 19.41 } 19.42 19.43 - 19.44 - /** 19.45 - * Cached instance of {@link DatatypeFactory} to create 19.46 - * {@link XMLGregorianCalendar} and {@link Duration}. 19.47 - */ 19.48 - private static final DatatypeFactory datatypeFactory = init(); 19.49 - 19.50 - private static DatatypeFactory init() { 19.51 - try { 19.52 - return DatatypeFactory.newInstance(); 19.53 - } catch (DatatypeConfigurationException e) { 19.54 - throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e); 19.55 - } 19.56 - } 19.57 - 19.58 private static void checkXmlGregorianCalendarFieldRef(QName type, 19.59 XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ 19.60 StringBuilder buf = new StringBuilder();
20.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Wed Mar 12 14:11:06 2014 -0700 20.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Fri Mar 14 23:01:25 2014 -0700 20.3 @@ -129,14 +129,6 @@ 20.4 private final Map<TypeReference,Bridge> bridges = new LinkedHashMap<TypeReference,Bridge>(); 20.5 20.6 /** 20.7 - * Shared instance of {@link TransformerFactory}. 20.8 - * Lock before use, because a {@link TransformerFactory} is not thread-safe 20.9 - * whereas {@link JAXBContextImpl} is. 20.10 - * Lazily created. 20.11 - */ 20.12 - private volatile static SAXTransformerFactory tf; 20.13 - 20.14 - /** 20.15 * Shared instance of {@link DocumentBuilder}. 20.16 * Lock before use. Lazily created. 20.17 */ 20.18 @@ -705,13 +697,7 @@ 20.19 */ 20.20 static Transformer createTransformer(boolean disableSecureProcessing) { 20.21 try { 20.22 - if (tf==null) { 20.23 - synchronized(JAXBContextImpl.class) { 20.24 - if (tf==null) { 20.25 - tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing); 20.26 - } 20.27 - } 20.28 - } 20.29 + SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing); 20.30 return tf.newTransformer(); 20.31 } catch (TransformerConfigurationException e) { 20.32 throw new Error(e); // impossible 20.33 @@ -723,13 +709,7 @@ 20.34 */ 20.35 public static TransformerHandler createTransformerHandler(boolean disableSecureProcessing) { 20.36 try { 20.37 - if (tf==null) { 20.38 - synchronized(JAXBContextImpl.class) { 20.39 - if (tf==null) { 20.40 - tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing); 20.41 - } 20.42 - } 20.43 - } 20.44 + SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing); 20.45 return tf.newTransformerHandler(); 20.46 } catch (TransformerConfigurationException e) { 20.47 throw new Error(e); // impossible
21.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Wed Mar 12 14:11:06 2014 -0700 21.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Fri Mar 14 23:01:25 2014 -0700 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -153,7 +153,6 @@ 21.11 } 21.12 } 21.13 21.14 - 21.15 /** 21.16 * Reference to FI's XMLStreamWriter class, if FI can be loaded. 21.17 */ 21.18 @@ -162,9 +161,8 @@ 21.19 21.20 private static Class initFIStAXWriterClass() { 21.21 try { 21.22 - ClassLoader loader = getClassLoader(); 21.23 - Class llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter", true, loader); 21.24 - Class sds = loader.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer"); 21.25 + Class<?> llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter"); 21.26 + Class<?> sds = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer"); 21.27 // Check if StAXDocumentSerializer implements LowLevelFastInfosetStreamWriter 21.28 if (llfisw.isAssignableFrom(sds)) 21.29 return sds; 21.30 @@ -179,8 +177,7 @@ 21.31 try { 21.32 if (FI_STAX_WRITER_CLASS == null) 21.33 return null; 21.34 - ClassLoader loader = getClassLoader(); 21.35 - Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput", true, loader); 21.36 + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput"); 21.37 return c.getConstructor(FI_STAX_WRITER_CLASS, JAXBContextImpl.class); 21.38 } catch (Throwable e) { 21.39 return null; 21.40 @@ -195,8 +192,7 @@ 21.41 21.42 private static Class initStAXExWriterClass() { 21.43 try { 21.44 - ClassLoader loader = getClassLoader(); 21.45 - return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx",true,loader); 21.46 + return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx"); 21.47 } catch (Throwable e) { 21.48 return null; 21.49 } 21.50 @@ -204,20 +200,11 @@ 21.51 21.52 private static Constructor<? extends XmlOutput> initStAXExOutputClass() { 21.53 try { 21.54 - ClassLoader loader = getClassLoader(); 21.55 - Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput",true, loader); 21.56 + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput"); 21.57 return c.getConstructor(STAXEX_WRITER_CLASS); 21.58 } catch (Throwable e) { 21.59 return null; 21.60 } 21.61 } 21.62 21.63 - private static ClassLoader getClassLoader() { 21.64 - ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class); 21.65 - if (cl == null) { 21.66 - cl = SecureLoader.getContextClassLoader(); 21.67 - } 21.68 - return cl; 21.69 - } 21.70 - 21.71 }
22.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Wed Mar 12 14:11:06 2014 -0700 22.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Fri Mar 14 23:01:25 2014 -0700 22.3 @@ -1,5 +1,5 @@ 22.4 # 22.5 -# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 22.6 +# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 22.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 # 22.9 # This code is free software; you can redistribute it and/or modify it 22.10 @@ -38,3 +38,6 @@ 22.11 NO_GETTER = \ 22.12 The property has a setter "{0}" but no getter. \ 22.13 For marshaller, please define getters. 22.14 + 22.15 +INVALID_XML_ENUM_VALUE = \ 22.16 + "{0}" is not a valid value for {1}.
23.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Wed Mar 12 14:11:06 2014 -0700 23.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Fri Mar 14 23:01:25 2014 -0700 23.3 @@ -1,5 +1,5 @@ 23.4 /* 23.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 23.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 23.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.8 * 23.9 * This code is free software; you can redistribute it and/or modify it 23.10 @@ -336,9 +336,8 @@ 23.11 23.12 private static Class initFIStAXReaderClass() { 23.13 try { 23.14 - ClassLoader cl = getClassLoader(); 23.15 - Class fisr = cl.loadClass("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader"); 23.16 - Class sdp = cl.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser"); 23.17 + Class<?> fisr = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader"); 23.18 + Class<?> sdp = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser"); 23.19 // Check if StAXDocumentParser implements FastInfosetStreamReader 23.20 if (fisr.isAssignableFrom(sdp)) 23.21 return sdp; 23.22 @@ -354,7 +353,7 @@ 23.23 if (FI_STAX_READER_CLASS == null) 23.24 return null; 23.25 23.26 - Class c = getClassLoader().loadClass( 23.27 + Class c = Class.forName( 23.28 "com.sun.xml.internal.bind.v2.runtime.unmarshaller.FastInfosetConnector"); 23.29 return c.getConstructor(FI_STAX_READER_CLASS,XmlVisitor.class); 23.30 } catch (Throwable e) { 23.31 @@ -370,7 +369,7 @@ 23.32 23.33 private static Class initStAXExReader() { 23.34 try { 23.35 - return getClassLoader().loadClass("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx"); 23.36 + return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx"); 23.37 } catch (Throwable e) { 23.38 return null; 23.39 } 23.40 @@ -378,19 +377,11 @@ 23.41 23.42 private static Constructor<? extends StAXConnector> initStAXExConnector() { 23.43 try { 23.44 - Class c = getClassLoader().loadClass("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector"); 23.45 + Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector"); 23.46 return c.getConstructor(STAX_EX_READER_CLASS,XmlVisitor.class); 23.47 } catch (Throwable e) { 23.48 return null; 23.49 } 23.50 } 23.51 23.52 - private static ClassLoader getClassLoader() { 23.53 - ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class); 23.54 - if (cl == null) { 23.55 - cl = SecureLoader.getContextClassLoader(); 23.56 - } 23.57 - return cl; 23.58 - } 23.59 - 23.60 }
24.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Wed Mar 12 14:11:06 2014 -0700 24.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Fri Mar 14 23:01:25 2014 -0700 24.3 @@ -62,61 +62,6 @@ 24.4 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, 24.5 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); 24.6 24.7 - static { 24.8 - try { 24.9 - CommandMap map = CommandMap.getDefaultCommandMap(); 24.10 - if (map instanceof MailcapCommandMap) { 24.11 - MailcapCommandMap mailMap = (MailcapCommandMap) map; 24.12 - String hndlrStr = ";;x-java-content-handler="; 24.13 - mailMap.addMailcap( 24.14 - "text/xml" 24.15 - + hndlrStr 24.16 - + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); 24.17 - mailMap.addMailcap( 24.18 - "application/xml" 24.19 - + hndlrStr 24.20 - + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); 24.21 - mailMap.addMailcap( 24.22 - "application/fastinfoset" 24.23 - + hndlrStr 24.24 - + "com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler"); 24.25 - /* Image DataContentHandler handles all image types 24.26 - mailMap.addMailcap( 24.27 - "image/jpeg" 24.28 - + hndlrStr 24.29 - + "com.sun.xml.internal.messaging.saaj.soap.JpegDataContentHandler"); 24.30 - mailMap.addMailcap( 24.31 - "image/gif" 24.32 - + hndlrStr 24.33 - + "com.sun.xml.internal.messaging.saaj.soap.GifDataContentHandler"); */ 24.34 - /*mailMap.addMailcap( 24.35 - "multipart/*" 24.36 - + hndlrStr 24.37 - + "com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");*/ 24.38 - mailMap.addMailcap( 24.39 - "image/*" 24.40 - + hndlrStr 24.41 - + "com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler"); 24.42 - mailMap.addMailcap( 24.43 - "text/plain" 24.44 - + hndlrStr 24.45 - + "com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler"); 24.46 - } else { 24.47 - throw new SOAPExceptionImpl("Default CommandMap is not a MailcapCommandMap"); 24.48 - } 24.49 - } catch (Throwable t) { 24.50 - log.log( 24.51 - Level.SEVERE, 24.52 - "SAAJ0508.soap.cannot.register.handlers", 24.53 - t); 24.54 - if (t instanceof RuntimeException) { 24.55 - throw (RuntimeException) t; 24.56 - } else { 24.57 - throw new RuntimeException(t.getLocalizedMessage()); 24.58 - } 24.59 - } 24.60 - }; 24.61 - 24.62 private final MimeHeaders headers; 24.63 private MimeBodyPart rawContent = null; 24.64 private DataHandler dataHandler = null; 24.65 @@ -126,6 +71,12 @@ 24.66 24.67 public AttachmentPartImpl() { 24.68 headers = new MimeHeaders(); 24.69 + 24.70 + // initialization from here should cover most of cases; 24.71 + // if not, it would be necessary to call 24.72 + // AttachmentPartImpl.initializeJavaActivationHandlers() 24.73 + // explicitly by programmer 24.74 + initializeJavaActivationHandlers(); 24.75 } 24.76 24.77 public AttachmentPartImpl(MIMEPart part) { 24.78 @@ -404,7 +355,7 @@ 24.79 throw new SOAPExceptionImpl(e.getLocalizedMessage()); 24.80 } finally { 24.81 try { 24.82 - decoded.close(); 24.83 + decoded.close(); 24.84 } catch (IOException ex) { 24.85 throw new SOAPException(ex); 24.86 } 24.87 @@ -613,4 +564,43 @@ 24.88 return headers; 24.89 } 24.90 24.91 + public static void initializeJavaActivationHandlers() { 24.92 + // DataHandler.writeTo() may search for DCH. So adding some default ones. 24.93 + try { 24.94 + CommandMap map = CommandMap.getDefaultCommandMap(); 24.95 + if (map instanceof MailcapCommandMap) { 24.96 + MailcapCommandMap mailMap = (MailcapCommandMap) map; 24.97 + 24.98 + // registering our DCH since javamail's DCH doesn't handle 24.99 + if (!cmdMapInitialized(mailMap)) { 24.100 + mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); 24.101 + mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); 24.102 + mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler"); 24.103 + mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler"); 24.104 + mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler"); 24.105 + mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler"); 24.106 + } 24.107 + } 24.108 + } catch (Throwable t) { 24.109 + // ignore the exception. 24.110 + } 24.111 + } 24.112 + 24.113 + private static boolean cmdMapInitialized(MailcapCommandMap mailMap) { 24.114 + 24.115 + // checking fastinfoset handler, since this one is specific to SAAJ 24.116 + CommandInfo[] commands = mailMap.getAllCommands("application/fastinfoset"); 24.117 + if (commands == null || commands.length == 0) { 24.118 + return false; 24.119 + } 24.120 + 24.121 + String saajClassName = "com.sun.xml.internal.ws.binding.FastInfosetDataContentHandler"; 24.122 + for (CommandInfo command : commands) { 24.123 + String commandClass = command.getCommandClass(); 24.124 + if (saajClassName.equals(commandClass)) { 24.125 + return true; 24.126 + } 24.127 + } 24.128 + return false; 24.129 + } 24.130 }
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 25.3 @@ -0,0 +1,86 @@ 25.4 +/* 25.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.7 + * 25.8 + * This code is free software; you can redistribute it and/or modify it 25.9 + * under the terms of the GNU General Public License version 2 only, as 25.10 + * published by the Free Software Foundation. Oracle designates this 25.11 + * particular file as subject to the "Classpath" exception as provided 25.12 + * by Oracle in the LICENSE file that accompanied this code. 25.13 + * 25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25.17 + * version 2 for more details (a copy is included in the LICENSE file that 25.18 + * accompanied this code). 25.19 + * 25.20 + * You should have received a copy of the GNU General Public License version 25.21 + * 2 along with this work; if not, write to the Free Software Foundation, 25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25.23 + * 25.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 25.25 + * or visit www.oracle.com if you need additional information or have any 25.26 + * questions. 25.27 + */ 25.28 + 25.29 +package com.sun.xml.internal.messaging.saaj.soap; 25.30 + 25.31 +import java.security.AccessController; 25.32 +import java.security.PrivilegedAction; 25.33 +import java.text.MessageFormat; 25.34 +import java.util.ResourceBundle; 25.35 +import java.util.WeakHashMap; 25.36 + 25.37 +/** 25.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 25.39 + */ 25.40 +abstract class ContextClassloaderLocal<V> { 25.41 + 25.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 25.43 + 25.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 25.45 + 25.46 + public V get() throws Error { 25.47 + ClassLoader tccl = getContextClassLoader(); 25.48 + V instance = CACHE.get(tccl); 25.49 + if (instance == null) { 25.50 + instance = createNewInstance(); 25.51 + CACHE.put(tccl, instance); 25.52 + } 25.53 + return instance; 25.54 + } 25.55 + 25.56 + public void set(V instance) { 25.57 + CACHE.put(getContextClassLoader(), instance); 25.58 + } 25.59 + 25.60 + protected abstract V initialValue() throws Exception; 25.61 + 25.62 + private V createNewInstance() { 25.63 + try { 25.64 + return initialValue(); 25.65 + } catch (Exception e) { 25.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 25.67 + } 25.68 + } 25.69 + 25.70 + private static String format(String property, Object... args) { 25.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 25.72 + return MessageFormat.format(text, args); 25.73 + } 25.74 + 25.75 + private static ClassLoader getContextClassLoader() { 25.76 + return (ClassLoader) 25.77 + AccessController.doPrivileged(new PrivilegedAction() { 25.78 + public Object run() { 25.79 + ClassLoader cl = null; 25.80 + try { 25.81 + cl = Thread.currentThread().getContextClassLoader(); 25.82 + } catch (SecurityException ex) { 25.83 + } 25.84 + return cl; 25.85 + } 25.86 + }); 25.87 + } 25.88 +} 25.89 +
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 26.3 @@ -0,0 +1,27 @@ 26.4 +# 26.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 26.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.7 +# 26.8 +# This code is free software; you can redistribute it and/or modify it 26.9 +# under the terms of the GNU General Public License version 2 only, as 26.10 +# published by the Free Software Foundation. Oracle designates this 26.11 +# particular file as subject to the "Classpath" exception as provided 26.12 +# by Oracle in the LICENSE file that accompanied this code. 26.13 +# 26.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 26.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26.17 +# version 2 for more details (a copy is included in the LICENSE file that 26.18 +# accompanied this code). 26.19 +# 26.20 +# You should have received a copy of the GNU General Public License version 26.21 +# 2 along with this work; if not, write to the Free Software Foundation, 26.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26.23 +# 26.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 26.25 +# or visit www.oracle.com if you need additional information or have any 26.26 +# questions. 26.27 +# 26.28 +# Error messages for StaticCache utility class 26.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 26.30 +
27.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Wed Mar 12 14:11:06 2014 -0700 27.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Fri Mar 14 23:01:25 2014 -0700 27.3 @@ -1,5 +1,5 @@ 27.4 /* 27.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 27.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 27.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.8 * 27.9 * This code is free software; you can redistribute it and/or modify it 27.10 @@ -25,7 +25,14 @@ 27.11 27.12 package com.sun.xml.internal.messaging.saaj.soap; 27.13 27.14 -import java.util.logging.Logger; 27.15 +import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; 27.16 +import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource; 27.17 +import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; 27.18 +import com.sun.xml.internal.messaging.saaj.util.ParserPool; 27.19 +import com.sun.xml.internal.messaging.saaj.util.RejectDoctypeSaxFilter; 27.20 +import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; 27.21 +import org.xml.sax.InputSource; 27.22 +import org.xml.sax.XMLReader; 27.23 27.24 import javax.xml.parsers.SAXParser; 27.25 import javax.xml.soap.SOAPException; 27.26 @@ -34,14 +41,7 @@ 27.27 import javax.xml.transform.dom.DOMResult; 27.28 import javax.xml.transform.sax.SAXSource; 27.29 import javax.xml.transform.stream.StreamSource; 27.30 - 27.31 -import org.xml.sax.InputSource; 27.32 -import org.xml.sax.XMLReader; 27.33 - 27.34 -import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; 27.35 -import com.sun.xml.internal.messaging.saaj.util.*; 27.36 - 27.37 -import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; 27.38 +import java.util.logging.Logger; 27.39 27.40 /** 27.41 * EnvelopeFactory creates SOAP Envelope objects using different 27.42 @@ -50,14 +50,19 @@ 27.43 public class EnvelopeFactory { 27.44 27.45 protected static final Logger 27.46 - log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, 27.47 - "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); 27.48 + log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, 27.49 + "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); 27.50 27.51 - private static ParserPool parserPool = new ParserPool(5); 27.52 + private static ContextClassloaderLocal<ParserPool> parserPool = 27.53 + new ContextClassloaderLocal<ParserPool>() { 27.54 + @Override 27.55 + protected ParserPool initialValue() throws Exception { 27.56 + return new ParserPool(5); 27.57 + } 27.58 + }; 27.59 27.60 public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart) 27.61 - throws SOAPException 27.62 - { 27.63 + throws SOAPException { 27.64 // Insert SAX filter to disallow Document Type Declarations since 27.65 // they are not legal in SOAP 27.66 SAXParser saxParser = null; 27.67 @@ -73,15 +78,15 @@ 27.68 } 27.69 } 27.70 try { 27.71 - saxParser = parserPool.get(); 27.72 + saxParser = parserPool.get().get(); 27.73 } catch (Exception e) { 27.74 log.severe("SAAJ0601.util.newSAXParser.exception"); 27.75 throw new SOAPExceptionImpl( 27.76 - "Couldn't get a SAX parser while constructing a envelope", 27.77 - e); 27.78 + "Couldn't get a SAX parser while constructing a envelope", 27.79 + e); 27.80 } 27.81 InputSource is = SAXSource.sourceToInputSource(src); 27.82 - if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) { 27.83 + if (is.getEncoding() == null && soapPart.getSourceCharsetEncoding() != null) { 27.84 is.setEncoding(soapPart.getSourceCharsetEncoding()); 27.85 } 27.86 XMLReader rejectFilter; 27.87 @@ -90,15 +95,15 @@ 27.88 } catch (Exception ex) { 27.89 log.severe("SAAJ0510.soap.cannot.create.envelope"); 27.90 throw new SOAPExceptionImpl( 27.91 - "Unable to create envelope from given source: ", 27.92 - ex); 27.93 + "Unable to create envelope from given source: ", 27.94 + ex); 27.95 } 27.96 src = new SAXSource(rejectFilter, is); 27.97 } 27.98 27.99 try { 27.100 Transformer transformer = 27.101 - EfficientStreamingTransformer.newTransformer(); 27.102 + EfficientStreamingTransformer.newTransformer(); 27.103 DOMResult result = new DOMResult(soapPart); 27.104 transformer.transform(src, result); 27.105 27.106 @@ -110,11 +115,11 @@ 27.107 } 27.108 log.severe("SAAJ0511.soap.cannot.create.envelope"); 27.109 throw new SOAPExceptionImpl( 27.110 - "Unable to create envelope from given source: ", 27.111 - ex); 27.112 + "Unable to create envelope from given source: ", 27.113 + ex); 27.114 } finally { 27.115 if (saxParser != null) { 27.116 - parserPool.returnParser(saxParser); 27.117 + parserPool.get().returnParser(saxParser); 27.118 } 27.119 } 27.120 }
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 28.3 @@ -0,0 +1,86 @@ 28.4 +/* 28.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. Oracle designates this 28.11 + * particular file as subject to the "Classpath" exception as provided 28.12 + * by Oracle in the LICENSE file that accompanied this code. 28.13 + * 28.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.17 + * version 2 for more details (a copy is included in the LICENSE file that 28.18 + * accompanied this code). 28.19 + * 28.20 + * You should have received a copy of the GNU General Public License version 28.21 + * 2 along with this work; if not, write to the Free Software Foundation, 28.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.23 + * 28.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28.25 + * or visit www.oracle.com if you need additional information or have any 28.26 + * questions. 28.27 + */ 28.28 + 28.29 +package com.sun.xml.internal.stream.buffer; 28.30 + 28.31 +import java.security.AccessController; 28.32 +import java.security.PrivilegedAction; 28.33 +import java.text.MessageFormat; 28.34 +import java.util.ResourceBundle; 28.35 +import java.util.WeakHashMap; 28.36 + 28.37 +/** 28.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 28.39 + */ 28.40 +abstract class ContextClassloaderLocal<V> { 28.41 + 28.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 28.43 + 28.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 28.45 + 28.46 + public V get() throws Error { 28.47 + ClassLoader tccl = getContextClassLoader(); 28.48 + V instance = CACHE.get(tccl); 28.49 + if (instance == null) { 28.50 + instance = createNewInstance(); 28.51 + CACHE.put(tccl, instance); 28.52 + } 28.53 + return instance; 28.54 + } 28.55 + 28.56 + public void set(V instance) { 28.57 + CACHE.put(getContextClassLoader(), instance); 28.58 + } 28.59 + 28.60 + protected abstract V initialValue() throws Exception; 28.61 + 28.62 + private V createNewInstance() { 28.63 + try { 28.64 + return initialValue(); 28.65 + } catch (Exception e) { 28.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 28.67 + } 28.68 + } 28.69 + 28.70 + private static String format(String property, Object... args) { 28.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 28.72 + return MessageFormat.format(text, args); 28.73 + } 28.74 + 28.75 + private static ClassLoader getContextClassLoader() { 28.76 + return (ClassLoader) 28.77 + AccessController.doPrivileged(new PrivilegedAction() { 28.78 + public Object run() { 28.79 + ClassLoader cl = null; 28.80 + try { 28.81 + cl = Thread.currentThread().getContextClassLoader(); 28.82 + } catch (SecurityException ex) { 28.83 + } 28.84 + return cl; 28.85 + } 28.86 + }); 28.87 + } 28.88 +} 28.89 +
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 29.3 @@ -0,0 +1,27 @@ 29.4 +# 29.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 29.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 +# 29.8 +# This code is free software; you can redistribute it and/or modify it 29.9 +# under the terms of the GNU General Public License version 2 only, as 29.10 +# published by the Free Software Foundation. Oracle designates this 29.11 +# particular file as subject to the "Classpath" exception as provided 29.12 +# by Oracle in the LICENSE file that accompanied this code. 29.13 +# 29.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 29.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.17 +# version 2 for more details (a copy is included in the LICENSE file that 29.18 +# accompanied this code). 29.19 +# 29.20 +# You should have received a copy of the GNU General Public License version 29.21 +# 2 along with this work; if not, write to the Free Software Foundation, 29.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.23 +# 29.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 29.25 +# or visit www.oracle.com if you need additional information or have any 29.26 +# questions. 29.27 +# 29.28 +# Error messages for ContextClassloaderLocal utility class 29.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 29.30 +
30.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Wed Mar 12 14:11:06 2014 -0700 30.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Fri Mar 14 23:01:25 2014 -0700 30.3 @@ -1,5 +1,5 @@ 30.4 /* 30.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 30.6 + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. 30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 * 30.9 * This code is free software; you can redistribute it and/or modify it 30.10 @@ -370,7 +370,12 @@ 30.11 writeTo(handler, errorHandler, isFragment()); 30.12 } 30.13 30.14 - private static final TransformerFactory trnsformerFactory = TransformerFactory.newInstance(); 30.15 + private static final ContextClassloaderLocal<TransformerFactory> trnsformerFactory = new ContextClassloaderLocal<TransformerFactory>() { 30.16 + @Override 30.17 + protected TransformerFactory initialValue() throws Exception { 30.18 + return TransformerFactory.newInstance(); 30.19 + } 30.20 + }; 30.21 30.22 /** 30.23 * Writes out the contents of this buffer as DOM node and append that to the given node. 30.24 @@ -382,7 +387,7 @@ 30.25 */ 30.26 public final Node writeTo(Node n) throws XMLStreamBufferException { 30.27 try { 30.28 - Transformer t = trnsformerFactory.newTransformer(); 30.29 + Transformer t = trnsformerFactory.get().newTransformer(); 30.30 t.transform(new XMLStreamBufferSource(this), new DOMResult(n)); 30.31 return n.getLastChild(); 30.32 } catch (TransformerException e) {
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 31.3 @@ -0,0 +1,86 @@ 31.4 +/* 31.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. Oracle designates this 31.11 + * particular file as subject to the "Classpath" exception as provided 31.12 + * by Oracle in the LICENSE file that accompanied this code. 31.13 + * 31.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.17 + * version 2 for more details (a copy is included in the LICENSE file that 31.18 + * accompanied this code). 31.19 + * 31.20 + * You should have received a copy of the GNU General Public License version 31.21 + * 2 along with this work; if not, write to the Free Software Foundation, 31.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.23 + * 31.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.25 + * or visit www.oracle.com if you need additional information or have any 31.26 + * questions. 31.27 + */ 31.28 + 31.29 +package com.sun.xml.internal.ws.api.streaming; 31.30 + 31.31 +import java.security.AccessController; 31.32 +import java.security.PrivilegedAction; 31.33 +import java.text.MessageFormat; 31.34 +import java.util.ResourceBundle; 31.35 +import java.util.WeakHashMap; 31.36 + 31.37 +/** 31.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 31.39 + */ 31.40 +abstract class ContextClassloaderLocal<V> { 31.41 + 31.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 31.43 + 31.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 31.45 + 31.46 + public V get() throws Error { 31.47 + ClassLoader tccl = getContextClassLoader(); 31.48 + V instance = CACHE.get(tccl); 31.49 + if (instance == null) { 31.50 + instance = createNewInstance(); 31.51 + CACHE.put(tccl, instance); 31.52 + } 31.53 + return instance; 31.54 + } 31.55 + 31.56 + public void set(V instance) { 31.57 + CACHE.put(getContextClassLoader(), instance); 31.58 + } 31.59 + 31.60 + protected abstract V initialValue() throws Exception; 31.61 + 31.62 + private V createNewInstance() { 31.63 + try { 31.64 + return initialValue(); 31.65 + } catch (Exception e) { 31.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 31.67 + } 31.68 + } 31.69 + 31.70 + private static String format(String property, Object... args) { 31.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 31.72 + return MessageFormat.format(text, args); 31.73 + } 31.74 + 31.75 + private static ClassLoader getContextClassLoader() { 31.76 + return (ClassLoader) 31.77 + AccessController.doPrivileged(new PrivilegedAction() { 31.78 + public Object run() { 31.79 + ClassLoader cl = null; 31.80 + try { 31.81 + cl = Thread.currentThread().getContextClassLoader(); 31.82 + } catch (SecurityException ex) { 31.83 + } 31.84 + return cl; 31.85 + } 31.86 + }); 31.87 + } 31.88 +} 31.89 +
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 32.3 @@ -0,0 +1,27 @@ 32.4 +# 32.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 32.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.7 +# 32.8 +# This code is free software; you can redistribute it and/or modify it 32.9 +# under the terms of the GNU General Public License version 2 only, as 32.10 +# published by the Free Software Foundation. Oracle designates this 32.11 +# particular file as subject to the "Classpath" exception as provided 32.12 +# by Oracle in the LICENSE file that accompanied this code. 32.13 +# 32.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 32.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32.17 +# version 2 for more details (a copy is included in the LICENSE file that 32.18 +# accompanied this code). 32.19 +# 32.20 +# You should have received a copy of the GNU General Public License version 32.21 +# 2 along with this work; if not, write to the Free Software Foundation, 32.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 32.23 +# 32.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 32.25 +# or visit www.oracle.com if you need additional information or have any 32.26 +# questions. 32.27 +# 32.28 +# Error messages for ContextClassloaderLocal utility class 32.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 32.30 +
33.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Wed Mar 12 14:11:06 2014 -0700 33.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Fri Mar 14 23:01:25 2014 -0700 33.3 @@ -1,5 +1,5 @@ 33.4 /* 33.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 33.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 33.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.8 * 33.9 * This code is free software; you can redistribute it and/or modify it 33.10 @@ -63,39 +63,43 @@ 33.11 33.12 private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName()); 33.13 33.14 + private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; 33.15 + 33.16 /** 33.17 * Singleton instance. 33.18 */ 33.19 - private static volatile @NotNull XMLStreamReaderFactory theInstance; 33.20 + private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader = 33.21 + new ContextClassloaderLocal<XMLStreamReaderFactory>() { 33.22 33.23 - private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; 33.24 + @Override 33.25 + protected XMLStreamReaderFactory initialValue() { 33.26 33.27 - static { 33.28 - XMLInputFactory xif = getXMLInputFactory(); 33.29 - XMLStreamReaderFactory f=null; 33.30 + XMLInputFactory xif = getXMLInputFactory(); 33.31 + XMLStreamReaderFactory f=null; 33.32 33.33 - // this system property can be used to disable the pooling altogether, 33.34 - // in case someone hits an issue with pooling in the production system. 33.35 - if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { 33.36 - f = Zephyr.newInstance(xif); 33.37 - } 33.38 + // this system property can be used to disable the pooling altogether, 33.39 + // in case someone hits an issue with pooling in the production system. 33.40 + if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { 33.41 + f = Zephyr.newInstance(xif); 33.42 + } 33.43 33.44 - if(f==null) { 33.45 - // is this Woodstox? 33.46 - if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { 33.47 - f = new Woodstox(xif); 33.48 - } 33.49 - } 33.50 + if(f==null) { 33.51 + // is this Woodstox? 33.52 + if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { 33.53 + f = new Woodstox(xif); 33.54 + } 33.55 + } 33.56 33.57 - if (f==null) { 33.58 - f = new Default(); 33.59 - } 33.60 + if (f==null) { 33.61 + f = new Default(); 33.62 + } 33.63 33.64 - theInstance = f; 33.65 - if (LOGGER.isLoggable(Level.FINE)) { 33.66 - LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance); 33.67 - } 33.68 - } 33.69 + if (LOGGER.isLoggable(Level.FINE)) { 33.70 + LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f); 33.71 + } 33.72 + return f; 33.73 + } 33.74 + }; 33.75 33.76 private static XMLInputFactory getXMLInputFactory() { 33.77 XMLInputFactory xif = null; 33.78 @@ -126,11 +130,11 @@ 33.79 if(f==null) { 33.80 throw new IllegalArgumentException(); 33.81 } 33.82 - theInstance = f; 33.83 + streamReader.set(f); 33.84 } 33.85 33.86 public static XMLStreamReaderFactory get() { 33.87 - return theInstance; 33.88 + return streamReader.get(); 33.89 } 33.90 33.91 public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {
34.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Wed Mar 12 14:11:06 2014 -0700 34.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Fri Mar 14 23:01:25 2014 -0700 34.3 @@ -1,5 +1,5 @@ 34.4 /* 34.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 34.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.8 * 34.9 * This code is free software; you can redistribute it and/or modify it 34.10 @@ -62,52 +62,54 @@ 34.11 /** 34.12 * Singleton instance. 34.13 */ 34.14 - private static volatile @NotNull XMLStreamWriterFactory theInstance; 34.15 + private static volatile ContextClassloaderLocal<XMLStreamWriterFactory> writerFactory = 34.16 + new ContextClassloaderLocal<XMLStreamWriterFactory>() { 34.17 34.18 + @Override 34.19 + protected XMLStreamWriterFactory initialValue() { 34.20 + XMLOutputFactory xof = null; 34.21 + if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) { 34.22 + try { 34.23 + xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance(); 34.24 + } catch (Exception e) { 34.25 + // Ignore and fallback to default XMLOutputFactory 34.26 + } 34.27 + } 34.28 + if (xof == null) { 34.29 + xof = XMLOutputFactory.newInstance(); 34.30 + } 34.31 34.32 - static { 34.33 - XMLOutputFactory xof = null; 34.34 - if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) { 34.35 - try { 34.36 - xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance(); 34.37 - } catch (Exception e) { 34.38 - // Ignore and fallback to default XMLOutputFactory 34.39 + XMLStreamWriterFactory f=null; 34.40 + 34.41 + // this system property can be used to disable the pooling altogether, 34.42 + // in case someone hits an issue with pooling in the production system. 34.43 + if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) { 34.44 + try { 34.45 + Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass(); 34.46 + if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) { 34.47 + f = new Zephyr(xof,clazz); 34.48 + } 34.49 + } catch (XMLStreamException ex) { 34.50 + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 34.51 + } catch (NoSuchMethodException ex) { 34.52 + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 34.53 + } 34.54 } 34.55 + 34.56 + if(f==null) { 34.57 + // is this Woodstox? 34.58 + if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory")) 34.59 + f = new NoLock(xof); 34.60 + } 34.61 + if (f == null) 34.62 + f = new Default(xof); 34.63 + 34.64 + if (LOGGER.isLoggable(Level.FINE)) { 34.65 + LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f); 34.66 + } 34.67 + return f; 34.68 } 34.69 - if (xof == null) { 34.70 - xof = XMLOutputFactory.newInstance(); 34.71 - } 34.72 - 34.73 - XMLStreamWriterFactory f=null; 34.74 - 34.75 - // this system property can be used to disable the pooling altogether, 34.76 - // in case someone hits an issue with pooling in the production system. 34.77 - if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) { 34.78 - try { 34.79 - Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass(); 34.80 - if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) { 34.81 - f = new Zephyr(xof,clazz); 34.82 - } 34.83 - } catch (XMLStreamException ex) { 34.84 - Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 34.85 - } catch (NoSuchMethodException ex) { 34.86 - Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 34.87 - } 34.88 - } 34.89 - 34.90 - if(f==null) { 34.91 - // is this Woodstox? 34.92 - if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory")) 34.93 - f = new NoLock(xof); 34.94 - } 34.95 - if (f == null) 34.96 - f = new Default(xof); 34.97 - 34.98 - theInstance = f; 34.99 - if (LOGGER.isLoggable(Level.FINE)) { 34.100 - LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f); 34.101 - } 34.102 - } 34.103 + }; 34.104 34.105 /** 34.106 * See {@link #create(OutputStream)} for the contract. 34.107 @@ -170,7 +172,7 @@ 34.108 * Gets the singleton instance. 34.109 */ 34.110 public static @NotNull XMLStreamWriterFactory get() { 34.111 - return theInstance; 34.112 + return writerFactory.get(); 34.113 } 34.114 34.115 /** 34.116 @@ -183,7 +185,7 @@ 34.117 @SuppressWarnings({"null", "ConstantConditions"}) 34.118 public static void set(@NotNull XMLStreamWriterFactory f) { 34.119 if(f==null) throw new IllegalArgumentException(); 34.120 - theInstance = f; 34.121 + writerFactory.set(f); 34.122 } 34.123 34.124 /**
35.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Wed Mar 12 14:11:06 2014 -0700 35.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Fri Mar 14 23:01:25 2014 -0700 35.3 @@ -37,6 +37,9 @@ 35.4 import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; 35.5 import com.sun.xml.internal.ws.developer.BindingTypeFeature; 35.6 35.7 +import javax.activation.CommandInfo; 35.8 +import javax.activation.CommandMap; 35.9 +import javax.activation.MailcapCommandMap; 35.10 import javax.xml.namespace.QName; 35.11 import javax.xml.ws.Service; 35.12 import javax.xml.ws.WebServiceFeature; 35.13 @@ -151,12 +154,61 @@ 35.14 return addressingVersion; 35.15 } 35.16 35.17 - public final 35.18 @NotNull 35.19 - Codec createCodec() { 35.20 + public final Codec createCodec() { 35.21 + 35.22 + // initialization from here should cover most of cases; 35.23 + // if not, it would be necessary to call 35.24 + // BindingImpl.initializeJavaActivationHandlers() 35.25 + // explicitly by programmer 35.26 + initializeJavaActivationHandlers(); 35.27 + 35.28 return bindingId.createEncoder(this); 35.29 } 35.30 35.31 + public static void initializeJavaActivationHandlers() { 35.32 + // DataHandler.writeTo() may search for DCH. So adding some default ones. 35.33 + try { 35.34 + CommandMap map = CommandMap.getDefaultCommandMap(); 35.35 + if (map instanceof MailcapCommandMap) { 35.36 + MailcapCommandMap mailMap = (MailcapCommandMap) map; 35.37 + 35.38 + // registering our DCH since javamail's DCH doesn't handle 35.39 + if (!cmdMapInitialized(mailMap)) { 35.40 + mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); 35.41 + mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); 35.42 + mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); 35.43 + mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); 35.44 + } 35.45 + } 35.46 + } catch (Throwable t) { 35.47 + // ignore the exception. 35.48 + } 35.49 + } 35.50 + 35.51 + private static boolean cmdMapInitialized(MailcapCommandMap mailMap) { 35.52 + CommandInfo[] commands = mailMap.getAllCommands("text/xml"); 35.53 + if (commands == null || commands.length == 0) { 35.54 + return false; 35.55 + } 35.56 + 35.57 + // SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too; 35.58 + // see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers 35.59 + // so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here 35.60 + // is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl. 35.61 + // This is also reason for duplication of Handler's code by JAX-WS 35.62 + String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"; 35.63 + String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler"; 35.64 + for (CommandInfo command : commands) { 35.65 + String commandClass = command.getCommandClass(); 35.66 + if (saajClassName.equals(commandClass) || 35.67 + jaxwsClassName.equals(commandClass)) { 35.68 + return true; 35.69 + } 35.70 + } 35.71 + return false; 35.72 + } 35.73 + 35.74 public static BindingImpl create(@NotNull BindingID bindingId) { 35.75 if (bindingId.equals(BindingID.XML_HTTP)) 35.76 return new HTTPBindingImpl();
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 36.3 @@ -0,0 +1,86 @@ 36.4 +/* 36.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.7 + * 36.8 + * This code is free software; you can redistribute it and/or modify it 36.9 + * under the terms of the GNU General Public License version 2 only, as 36.10 + * published by the Free Software Foundation. Oracle designates this 36.11 + * particular file as subject to the "Classpath" exception as provided 36.12 + * by Oracle in the LICENSE file that accompanied this code. 36.13 + * 36.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 36.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36.17 + * version 2 for more details (a copy is included in the LICENSE file that 36.18 + * accompanied this code). 36.19 + * 36.20 + * You should have received a copy of the GNU General Public License version 36.21 + * 2 along with this work; if not, write to the Free Software Foundation, 36.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 36.23 + * 36.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 36.25 + * or visit www.oracle.com if you need additional information or have any 36.26 + * questions. 36.27 + */ 36.28 + 36.29 +package com.sun.xml.internal.ws.commons.xmlutil; 36.30 + 36.31 +import java.security.AccessController; 36.32 +import java.security.PrivilegedAction; 36.33 +import java.text.MessageFormat; 36.34 +import java.util.ResourceBundle; 36.35 +import java.util.WeakHashMap; 36.36 + 36.37 +/** 36.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 36.39 + */ 36.40 +abstract class ContextClassloaderLocal<V> { 36.41 + 36.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 36.43 + 36.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 36.45 + 36.46 + public V get() throws Error { 36.47 + ClassLoader tccl = getContextClassLoader(); 36.48 + V instance = CACHE.get(tccl); 36.49 + if (instance == null) { 36.50 + instance = createNewInstance(); 36.51 + CACHE.put(tccl, instance); 36.52 + } 36.53 + return instance; 36.54 + } 36.55 + 36.56 + public void set(V instance) { 36.57 + CACHE.put(getContextClassLoader(), instance); 36.58 + } 36.59 + 36.60 + protected abstract V initialValue() throws Exception; 36.61 + 36.62 + private V createNewInstance() { 36.63 + try { 36.64 + return initialValue(); 36.65 + } catch (Exception e) { 36.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 36.67 + } 36.68 + } 36.69 + 36.70 + private static String format(String property, Object... args) { 36.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 36.72 + return MessageFormat.format(text, args); 36.73 + } 36.74 + 36.75 + private static ClassLoader getContextClassLoader() { 36.76 + return (ClassLoader) 36.77 + AccessController.doPrivileged(new PrivilegedAction() { 36.78 + public Object run() { 36.79 + ClassLoader cl = null; 36.80 + try { 36.81 + cl = Thread.currentThread().getContextClassLoader(); 36.82 + } catch (SecurityException ex) { 36.83 + } 36.84 + return cl; 36.85 + } 36.86 + }); 36.87 + } 36.88 +} 36.89 +
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 37.3 @@ -0,0 +1,27 @@ 37.4 +# 37.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 37.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.7 +# 37.8 +# This code is free software; you can redistribute it and/or modify it 37.9 +# under the terms of the GNU General Public License version 2 only, as 37.10 +# published by the Free Software Foundation. Oracle designates this 37.11 +# particular file as subject to the "Classpath" exception as provided 37.12 +# by Oracle in the LICENSE file that accompanied this code. 37.13 +# 37.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 37.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 37.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37.17 +# version 2 for more details (a copy is included in the LICENSE file that 37.18 +# accompanied this code). 37.19 +# 37.20 +# You should have received a copy of the GNU General Public License version 37.21 +# 2 along with this work; if not, write to the Free Software Foundation, 37.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 37.23 +# 37.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 37.25 +# or visit www.oracle.com if you need additional information or have any 37.26 +# questions. 37.27 +# 37.28 +# Error messages for ContextClassloaderLocal utility class 37.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 37.30 +
38.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Wed Mar 12 14:11:06 2014 -0700 38.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Fri Mar 14 23:01:25 2014 -0700 38.3 @@ -53,7 +53,12 @@ 38.4 // prevents instantiation 38.5 } 38.6 private static final Logger LOGGER = Logger.getLogger(Converter.class); 38.7 - private static final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); 38.8 + private static final ContextClassloaderLocal<XMLOutputFactory> xmlOutputFactory = new ContextClassloaderLocal<XMLOutputFactory>() { 38.9 + @Override 38.10 + protected XMLOutputFactory initialValue() throws Exception { 38.11 + return XMLOutputFactory.newInstance(); 38.12 + } 38.13 + }; 38.14 private static final AtomicBoolean logMissingStaxUtilsWarning = new AtomicBoolean(false); 38.15 38.16 /** 38.17 @@ -110,7 +115,7 @@ 38.18 stringOut = new StringWriter(); 38.19 XMLStreamWriter writer = null; 38.20 try { 38.21 - writer = xmlOutputFactory.createXMLStreamWriter(stringOut); 38.22 + writer = xmlOutputFactory.get().createXMLStreamWriter(stringOut); 38.23 if (createIndenter) { 38.24 writer = createIndenter(writer); 38.25 } 38.26 @@ -143,7 +148,7 @@ 38.27 38.28 try { 38.29 if (message != null) { 38.30 - XMLStreamWriter xsw = xmlOutputFactory.createXMLStreamWriter(baos, encoding); 38.31 + XMLStreamWriter xsw = xmlOutputFactory.get().createXMLStreamWriter(baos, encoding); 38.32 try { 38.33 message.writeTo(xsw); 38.34 } finally {
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 39.3 @@ -0,0 +1,86 @@ 39.4 +/* 39.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. Oracle designates this 39.11 + * particular file as subject to the "Classpath" exception as provided 39.12 + * by Oracle in the LICENSE file that accompanied this code. 39.13 + * 39.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.17 + * version 2 for more details (a copy is included in the LICENSE file that 39.18 + * accompanied this code). 39.19 + * 39.20 + * You should have received a copy of the GNU General Public License version 39.21 + * 2 along with this work; if not, write to the Free Software Foundation, 39.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.23 + * 39.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.25 + * or visit www.oracle.com if you need additional information or have any 39.26 + * questions. 39.27 + */ 39.28 + 39.29 +package com.sun.xml.internal.ws.developer; 39.30 + 39.31 +import java.security.AccessController; 39.32 +import java.security.PrivilegedAction; 39.33 +import java.text.MessageFormat; 39.34 +import java.util.ResourceBundle; 39.35 +import java.util.WeakHashMap; 39.36 + 39.37 +/** 39.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 39.39 + */ 39.40 +abstract class ContextClassloaderLocal<V> { 39.41 + 39.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 39.43 + 39.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 39.45 + 39.46 + public V get() throws Error { 39.47 + ClassLoader tccl = getContextClassLoader(); 39.48 + V instance = CACHE.get(tccl); 39.49 + if (instance == null) { 39.50 + instance = createNewInstance(); 39.51 + CACHE.put(tccl, instance); 39.52 + } 39.53 + return instance; 39.54 + } 39.55 + 39.56 + public void set(V instance) { 39.57 + CACHE.put(getContextClassLoader(), instance); 39.58 + } 39.59 + 39.60 + protected abstract V initialValue() throws Exception; 39.61 + 39.62 + private V createNewInstance() { 39.63 + try { 39.64 + return initialValue(); 39.65 + } catch (Exception e) { 39.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 39.67 + } 39.68 + } 39.69 + 39.70 + private static String format(String property, Object... args) { 39.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 39.72 + return MessageFormat.format(text, args); 39.73 + } 39.74 + 39.75 + private static ClassLoader getContextClassLoader() { 39.76 + return (ClassLoader) 39.77 + AccessController.doPrivileged(new PrivilegedAction() { 39.78 + public Object run() { 39.79 + ClassLoader cl = null; 39.80 + try { 39.81 + cl = Thread.currentThread().getContextClassLoader(); 39.82 + } catch (SecurityException ex) { 39.83 + } 39.84 + return cl; 39.85 + } 39.86 + }); 39.87 + } 39.88 +} 39.89 +
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 40.3 @@ -0,0 +1,27 @@ 40.4 +# 40.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 40.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40.7 +# 40.8 +# This code is free software; you can redistribute it and/or modify it 40.9 +# under the terms of the GNU General Public License version 2 only, as 40.10 +# published by the Free Software Foundation. Oracle designates this 40.11 +# particular file as subject to the "Classpath" exception as provided 40.12 +# by Oracle in the LICENSE file that accompanied this code. 40.13 +# 40.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 40.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 40.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40.17 +# version 2 for more details (a copy is included in the LICENSE file that 40.18 +# accompanied this code). 40.19 +# 40.20 +# You should have received a copy of the GNU General Public License version 40.21 +# 2 along with this work; if not, write to the Free Software Foundation, 40.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 40.23 +# 40.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 40.25 +# or visit www.oracle.com if you need additional information or have any 40.26 +# questions. 40.27 +# 40.28 +# Error messages for ContextClassloaderLocal utility class 40.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 40.30 +
41.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Wed Mar 12 14:11:06 2014 -0700 41.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Fri Mar 14 23:01:25 2014 -0700 41.3 @@ -1,5 +1,5 @@ 41.4 /* 41.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 41.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 41.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.8 * 41.9 * This code is free software; you can redistribute it and/or modify it 41.10 @@ -64,7 +64,12 @@ 41.11 @XmlType(name = "EndpointReferenceType", namespace = MemberSubmissionEndpointReference.MSNS) 41.12 public final class MemberSubmissionEndpointReference extends EndpointReference implements MemberSubmissionAddressingConstants { 41.13 41.14 - private final static JAXBContext msjc = MemberSubmissionEndpointReference.getMSJaxbContext(); 41.15 + private final static ContextClassloaderLocal<JAXBContext> msjc = new ContextClassloaderLocal<JAXBContext>() { 41.16 + @Override 41.17 + protected JAXBContext initialValue() throws Exception { 41.18 + return MemberSubmissionEndpointReference.getMSJaxbContext(); 41.19 + } 41.20 + }; 41.21 41.22 public MemberSubmissionEndpointReference() { 41.23 } 41.24 @@ -86,7 +91,7 @@ 41.25 } 41.26 41.27 try { 41.28 - Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.createUnmarshaller(); 41.29 + Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.get().createUnmarshaller(); 41.30 MemberSubmissionEndpointReference epr = unmarshaller.unmarshal(source,MemberSubmissionEndpointReference.class).getValue(); 41.31 41.32 this.addr = epr.addr; 41.33 @@ -106,7 +111,7 @@ 41.34 @Override 41.35 public void writeTo(Result result) { 41.36 try { 41.37 - Marshaller marshaller = MemberSubmissionEndpointReference.msjc.createMarshaller(); 41.38 + Marshaller marshaller = MemberSubmissionEndpointReference.msjc.get().createMarshaller(); 41.39 //marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); 41.40 marshaller.marshal(this, result); 41.41 } catch (JAXBException e) {
42.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Wed Mar 12 14:11:06 2014 -0700 42.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Fri Mar 14 23:01:25 2014 -0700 42.3 @@ -34,8 +34,6 @@ 42.4 import com.sun.xml.internal.ws.api.pipe.Codec; 42.5 import com.sun.xml.internal.ws.api.pipe.ContentType; 42.6 import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature; 42.7 -import javax.activation.CommandMap; 42.8 -import javax.activation.MailcapCommandMap; 42.9 42.10 import java.io.IOException; 42.11 import java.io.InputStream; 42.12 @@ -63,33 +61,6 @@ 42.13 */ 42.14 abstract class MimeCodec implements Codec { 42.15 42.16 - static { 42.17 - // DataHandler.writeTo() may search for DCH. So adding some default ones. 42.18 - try { 42.19 - CommandMap map = CommandMap.getDefaultCommandMap(); 42.20 - if (map instanceof MailcapCommandMap) { 42.21 - MailcapCommandMap mailMap = (MailcapCommandMap) map; 42.22 - String hndlrStr = ";;x-java-content-handler="; 42.23 - // registering our DCH since javamail's DCH doesn't handle 42.24 - // Source 42.25 - mailMap.addMailcap( 42.26 - "text/xml" + hndlrStr + XmlDataContentHandler.class.getName()); 42.27 - mailMap.addMailcap( 42.28 - "application/xml" + hndlrStr + XmlDataContentHandler.class.getName()); 42.29 - if (map.createDataContentHandler("image/*") == null) { 42.30 - mailMap.addMailcap( 42.31 - "image/*" + hndlrStr + ImageDataContentHandler.class.getName()); 42.32 - } 42.33 - if (map.createDataContentHandler("text/plain") == null) { 42.34 - mailMap.addMailcap( 42.35 - "text/plain" + hndlrStr + StringDataContentHandler.class.getName()); 42.36 - } 42.37 - } 42.38 - } catch (Throwable t) { 42.39 - // ignore the exception. 42.40 - } 42.41 - } 42.42 - 42.43 public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related"; 42.44 42.45 protected Codec mimeRootCodec;
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 43.3 @@ -0,0 +1,86 @@ 43.4 +/* 43.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. Oracle designates this 43.11 + * particular file as subject to the "Classpath" exception as provided 43.12 + * by Oracle in the LICENSE file that accompanied this code. 43.13 + * 43.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.17 + * version 2 for more details (a copy is included in the LICENSE file that 43.18 + * accompanied this code). 43.19 + * 43.20 + * You should have received a copy of the GNU General Public License version 43.21 + * 2 along with this work; if not, write to the Free Software Foundation, 43.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.23 + * 43.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.25 + * or visit www.oracle.com if you need additional information or have any 43.26 + * questions. 43.27 + */ 43.28 + 43.29 +package com.sun.xml.internal.ws.policy.sourcemodel.attach; 43.30 + 43.31 +import java.security.AccessController; 43.32 +import java.security.PrivilegedAction; 43.33 +import java.text.MessageFormat; 43.34 +import java.util.ResourceBundle; 43.35 +import java.util.WeakHashMap; 43.36 + 43.37 +/** 43.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 43.39 + */ 43.40 +abstract class ContextClassloaderLocal<V> { 43.41 + 43.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 43.43 + 43.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 43.45 + 43.46 + public V get() throws Error { 43.47 + ClassLoader tccl = getContextClassLoader(); 43.48 + V instance = CACHE.get(tccl); 43.49 + if (instance == null) { 43.50 + instance = createNewInstance(); 43.51 + CACHE.put(tccl, instance); 43.52 + } 43.53 + return instance; 43.54 + } 43.55 + 43.56 + public void set(V instance) { 43.57 + CACHE.put(getContextClassLoader(), instance); 43.58 + } 43.59 + 43.60 + protected abstract V initialValue() throws Exception; 43.61 + 43.62 + private V createNewInstance() { 43.63 + try { 43.64 + return initialValue(); 43.65 + } catch (Exception e) { 43.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 43.67 + } 43.68 + } 43.69 + 43.70 + private static String format(String property, Object... args) { 43.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 43.72 + return MessageFormat.format(text, args); 43.73 + } 43.74 + 43.75 + private static ClassLoader getContextClassLoader() { 43.76 + return (ClassLoader) 43.77 + AccessController.doPrivileged(new PrivilegedAction() { 43.78 + public Object run() { 43.79 + ClassLoader cl = null; 43.80 + try { 43.81 + cl = Thread.currentThread().getContextClassLoader(); 43.82 + } catch (SecurityException ex) { 43.83 + } 43.84 + return cl; 43.85 + } 43.86 + }); 43.87 + } 43.88 +} 43.89 +
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 44.3 @@ -0,0 +1,27 @@ 44.4 +# 44.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 44.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 44.7 +# 44.8 +# This code is free software; you can redistribute it and/or modify it 44.9 +# under the terms of the GNU General Public License version 2 only, as 44.10 +# published by the Free Software Foundation. Oracle designates this 44.11 +# particular file as subject to the "Classpath" exception as provided 44.12 +# by Oracle in the LICENSE file that accompanied this code. 44.13 +# 44.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 44.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 44.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 44.17 +# version 2 for more details (a copy is included in the LICENSE file that 44.18 +# accompanied this code). 44.19 +# 44.20 +# You should have received a copy of the GNU General Public License version 44.21 +# 2 along with this work; if not, write to the Free Software Foundation, 44.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 44.23 +# 44.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 44.25 +# or visit www.oracle.com if you need additional information or have any 44.26 +# questions. 44.27 +# 44.28 +# Error messages for ContextClassloaderLocal utility class 44.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 44.30 +
45.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Wed Mar 12 14:11:06 2014 -0700 45.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Fri Mar 14 23:01:25 2014 -0700 45.3 @@ -1,5 +1,5 @@ 45.4 /* 45.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 45.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 45.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.8 * 45.9 * This code is free software; you can redistribute it and/or modify it 45.10 @@ -83,7 +83,13 @@ 45.11 private static final QName POLICY = new QName("http://www.w3.org/ns/ws-policy", "Policy"); 45.12 private static final QName URI = new QName("http://www.w3.org/ns/ws-policy", "URI"); 45.13 private static final QName POLICIES = new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "Policies"); 45.14 - private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance(); 45.15 + private static final ContextClassloaderLocal<XMLInputFactory> XML_INPUT_FACTORY = new ContextClassloaderLocal<XMLInputFactory>() { 45.16 + @Override 45.17 + protected XMLInputFactory initialValue() throws Exception { 45.18 + return XMLInputFactory.newInstance(); 45.19 + } 45.20 + }; 45.21 + 45.22 private static final PolicyModelUnmarshaller POLICY_UNMARSHALLER = PolicyModelUnmarshaller.getXmlUnmarshaller(); 45.23 45.24 private final Map<URI, Policy> map = new HashMap<URI, Policy>(); 45.25 @@ -93,7 +99,7 @@ 45.26 public static Map<URI, Policy> unmarshal(final Reader source) throws PolicyException { 45.27 LOGGER.entering(source); 45.28 try { 45.29 - XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(source); 45.30 + XMLEventReader reader = XML_INPUT_FACTORY.get().createXMLEventReader(source); 45.31 ExternalAttachmentsUnmarshaller instance = new ExternalAttachmentsUnmarshaller(); 45.32 final Map<URI, Policy> map = instance.unmarshal(reader, null); 45.33 LOGGER.exiting(map);
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 46.3 @@ -0,0 +1,86 @@ 46.4 +/* 46.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 46.7 + * 46.8 + * This code is free software; you can redistribute it and/or modify it 46.9 + * under the terms of the GNU General Public License version 2 only, as 46.10 + * published by the Free Software Foundation. Oracle designates this 46.11 + * particular file as subject to the "Classpath" exception as provided 46.12 + * by Oracle in the LICENSE file that accompanied this code. 46.13 + * 46.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 46.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 46.17 + * version 2 for more details (a copy is included in the LICENSE file that 46.18 + * accompanied this code). 46.19 + * 46.20 + * You should have received a copy of the GNU General Public License version 46.21 + * 2 along with this work; if not, write to the Free Software Foundation, 46.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 46.23 + * 46.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 46.25 + * or visit www.oracle.com if you need additional information or have any 46.26 + * questions. 46.27 + */ 46.28 + 46.29 +package com.sun.xml.internal.ws.spi; 46.30 + 46.31 +import java.security.AccessController; 46.32 +import java.security.PrivilegedAction; 46.33 +import java.text.MessageFormat; 46.34 +import java.util.ResourceBundle; 46.35 +import java.util.WeakHashMap; 46.36 + 46.37 +/** 46.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 46.39 + */ 46.40 +abstract class ContextClassloaderLocal<V> { 46.41 + 46.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 46.43 + 46.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 46.45 + 46.46 + public V get() throws Error { 46.47 + ClassLoader tccl = getContextClassLoader(); 46.48 + V instance = CACHE.get(tccl); 46.49 + if (instance == null) { 46.50 + instance = createNewInstance(); 46.51 + CACHE.put(tccl, instance); 46.52 + } 46.53 + return instance; 46.54 + } 46.55 + 46.56 + public void set(V instance) { 46.57 + CACHE.put(getContextClassLoader(), instance); 46.58 + } 46.59 + 46.60 + protected abstract V initialValue() throws Exception; 46.61 + 46.62 + private V createNewInstance() { 46.63 + try { 46.64 + return initialValue(); 46.65 + } catch (Exception e) { 46.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 46.67 + } 46.68 + } 46.69 + 46.70 + private static String format(String property, Object... args) { 46.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 46.72 + return MessageFormat.format(text, args); 46.73 + } 46.74 + 46.75 + private static ClassLoader getContextClassLoader() { 46.76 + return (ClassLoader) 46.77 + AccessController.doPrivileged(new PrivilegedAction() { 46.78 + public Object run() { 46.79 + ClassLoader cl = null; 46.80 + try { 46.81 + cl = Thread.currentThread().getContextClassLoader(); 46.82 + } catch (SecurityException ex) { 46.83 + } 46.84 + return cl; 46.85 + } 46.86 + }); 46.87 + } 46.88 +} 46.89 +
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 47.3 @@ -0,0 +1,27 @@ 47.4 +# 47.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 47.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 +# 47.8 +# This code is free software; you can redistribute it and/or modify it 47.9 +# under the terms of the GNU General Public License version 2 only, as 47.10 +# published by the Free Software Foundation. Oracle designates this 47.11 +# particular file as subject to the "Classpath" exception as provided 47.12 +# by Oracle in the LICENSE file that accompanied this code. 47.13 +# 47.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 47.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.17 +# version 2 for more details (a copy is included in the LICENSE file that 47.18 +# accompanied this code). 47.19 +# 47.20 +# You should have received a copy of the GNU General Public License version 47.21 +# 2 along with this work; if not, write to the Free Software Foundation, 47.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.23 +# 47.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.25 +# or visit www.oracle.com if you need additional information or have any 47.26 +# questions. 47.27 +# 47.28 +# Error messages for StaticCache utility class 47.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 47.30 +
48.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Wed Mar 12 14:11:06 2014 -0700 48.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Fri Mar 14 23:01:25 2014 -0700 48.3 @@ -1,5 +1,5 @@ 48.4 /* 48.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 48.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 48.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.8 * 48.9 * This code is free software; you can redistribute it and/or modify it 48.10 @@ -80,7 +80,12 @@ 48.11 */ 48.12 public class ProviderImpl extends Provider { 48.13 48.14 - private final static JAXBContext eprjc = getEPRJaxbContext(); 48.15 + private final static ContextClassloaderLocal<JAXBContext> eprjc = new ContextClassloaderLocal<JAXBContext>() { 48.16 + @Override 48.17 + protected JAXBContext initialValue() throws Exception { 48.18 + return getEPRJaxbContext(); 48.19 + } 48.20 + }; 48.21 48.22 /** 48.23 * Convenient singleton instance. 48.24 @@ -148,7 +153,7 @@ 48.25 return AccessController.doPrivileged(new PrivilegedAction<EndpointReference>() { 48.26 public EndpointReference run() { 48.27 try { 48.28 - Unmarshaller unmarshaller = eprjc.createUnmarshaller(); 48.29 + Unmarshaller unmarshaller = eprjc.get().createUnmarshaller(); 48.30 return (EndpointReference) unmarshaller.unmarshal(eprInfoset); 48.31 } catch (JAXBException e) { 48.32 throw new WebServiceException("Error creating Marshaller or marshalling.", e);
49.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties Wed Mar 12 14:11:06 2014 -0700 49.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties Fri Mar 14 23:01:25 2014 -0700 49.3 @@ -26,4 +26,4 @@ 49.4 build-id=2.2.9-b130926.1035 49.5 build-version=JAX-WS RI 2.2.9-b130926.1035 49.6 major-version=2.2.9 49.7 -svn-revision=8c29a9a53251ff741fca1664a8221dc876b2eac8 49.8 +svn-revision=5f6196f2b90e9460065a4c2f4e30e065b245e51e
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 50.3 @@ -0,0 +1,86 @@ 50.4 +/* 50.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. Oracle designates this 50.11 + * particular file as subject to the "Classpath" exception as provided 50.12 + * by Oracle in the LICENSE file that accompanied this code. 50.13 + * 50.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.17 + * version 2 for more details (a copy is included in the LICENSE file that 50.18 + * accompanied this code). 50.19 + * 50.20 + * You should have received a copy of the GNU General Public License version 50.21 + * 2 along with this work; if not, write to the Free Software Foundation, 50.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.23 + * 50.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.25 + * or visit www.oracle.com if you need additional information or have any 50.26 + * questions. 50.27 + */ 50.28 + 50.29 +package com.sun.xml.internal.ws.util.xml; 50.30 + 50.31 +import java.security.AccessController; 50.32 +import java.security.PrivilegedAction; 50.33 +import java.text.MessageFormat; 50.34 +import java.util.ResourceBundle; 50.35 +import java.util.WeakHashMap; 50.36 + 50.37 +/** 50.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 50.39 + */ 50.40 +abstract class ContextClassloaderLocal<V> { 50.41 + 50.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 50.43 + 50.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 50.45 + 50.46 + public V get() throws Error { 50.47 + ClassLoader tccl = getContextClassLoader(); 50.48 + V instance = CACHE.get(tccl); 50.49 + if (instance == null) { 50.50 + instance = createNewInstance(); 50.51 + CACHE.put(tccl, instance); 50.52 + } 50.53 + return instance; 50.54 + } 50.55 + 50.56 + public void set(V instance) { 50.57 + CACHE.put(getContextClassLoader(), instance); 50.58 + } 50.59 + 50.60 + protected abstract V initialValue() throws Exception; 50.61 + 50.62 + private V createNewInstance() { 50.63 + try { 50.64 + return initialValue(); 50.65 + } catch (Exception e) { 50.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 50.67 + } 50.68 + } 50.69 + 50.70 + private static String format(String property, Object... args) { 50.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 50.72 + return MessageFormat.format(text, args); 50.73 + } 50.74 + 50.75 + private static ClassLoader getContextClassLoader() { 50.76 + return (ClassLoader) 50.77 + AccessController.doPrivileged(new PrivilegedAction() { 50.78 + public Object run() { 50.79 + ClassLoader cl = null; 50.80 + try { 50.81 + cl = Thread.currentThread().getContextClassLoader(); 50.82 + } catch (SecurityException ex) { 50.83 + } 50.84 + return cl; 50.85 + } 50.86 + }); 50.87 + } 50.88 +} 50.89 +
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 51.3 @@ -0,0 +1,27 @@ 51.4 +# 51.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 51.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 +# 51.8 +# This code is free software; you can redistribute it and/or modify it 51.9 +# under the terms of the GNU General Public License version 2 only, as 51.10 +# published by the Free Software Foundation. Oracle designates this 51.11 +# particular file as subject to the "Classpath" exception as provided 51.12 +# by Oracle in the LICENSE file that accompanied this code. 51.13 +# 51.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 51.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.17 +# version 2 for more details (a copy is included in the LICENSE file that 51.18 +# accompanied this code). 51.19 +# 51.20 +# You should have received a copy of the GNU General Public License version 51.21 +# 2 along with this work; if not, write to the Free Software Foundation, 51.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.23 +# 51.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.25 +# or visit www.oracle.com if you need additional information or have any 51.26 +# questions. 51.27 +# 51.28 +# Error messages for StaticCache utility class 51.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 51.30 +
52.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Wed Mar 12 14:11:06 2014 -0700 52.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Fri Mar 14 23:01:25 2014 -0700 52.3 @@ -1,5 +1,5 @@ 52.4 /* 52.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 52.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 52.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.8 * 52.9 * This code is free software; you can redistribute it and/or modify it 52.10 @@ -215,20 +215,28 @@ 52.11 } 52.12 } 52.13 52.14 - static final TransformerFactory transformerFactory = newTransformerFactory(); 52.15 + static final ContextClassloaderLocal<TransformerFactory> transformerFactory = new ContextClassloaderLocal<TransformerFactory>() { 52.16 + @Override 52.17 + protected TransformerFactory initialValue() throws Exception { 52.18 + return TransformerFactory.newInstance(); 52.19 + } 52.20 + }; 52.21 52.22 - static final SAXParserFactory saxParserFactory = newSAXParserFactory(true); 52.23 - 52.24 - static { 52.25 - saxParserFactory.setNamespaceAware(true); 52.26 - } 52.27 + static final ContextClassloaderLocal<SAXParserFactory> saxParserFactory = new ContextClassloaderLocal<SAXParserFactory>() { 52.28 + @Override 52.29 + protected SAXParserFactory initialValue() throws Exception { 52.30 + SAXParserFactory factory = SAXParserFactory.newInstance(); 52.31 + factory.setNamespaceAware(true); 52.32 + return factory; 52.33 + } 52.34 + }; 52.35 52.36 /** 52.37 * Creates a new identity transformer. 52.38 */ 52.39 public static Transformer newTransformer() { 52.40 try { 52.41 - return transformerFactory.newTransformer(); 52.42 + return transformerFactory.get().newTransformer(); 52.43 } catch (TransformerConfigurationException tex) { 52.44 throw new IllegalStateException("Unable to create a JAXP transformer"); 52.45 } 52.46 @@ -243,9 +251,9 @@ 52.47 // work around a bug in JAXP in JDK6u4 and earlier where the namespace processing 52.48 // is not turned on by default 52.49 StreamSource ssrc = (StreamSource) src; 52.50 - TransformerHandler th = ((SAXTransformerFactory) transformerFactory).newTransformerHandler(); 52.51 + TransformerHandler th = ((SAXTransformerFactory) transformerFactory.get()).newTransformerHandler(); 52.52 th.setResult(result); 52.53 - XMLReader reader = saxParserFactory.newSAXParser().getXMLReader(); 52.54 + XMLReader reader = saxParserFactory.get().newSAXParser().getXMLReader(); 52.55 reader.setContentHandler(th); 52.56 reader.setProperty(LEXICAL_HANDLER_PROPERTY, th); 52.57 reader.parse(toInputSource(ssrc));
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java Fri Mar 14 23:01:25 2014 -0700 53.3 @@ -0,0 +1,86 @@ 53.4 +/* 53.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. Oracle designates this 53.11 + * particular file as subject to the "Classpath" exception as provided 53.12 + * by Oracle in the LICENSE file that accompanied this code. 53.13 + * 53.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.17 + * version 2 for more details (a copy is included in the LICENSE file that 53.18 + * accompanied this code). 53.19 + * 53.20 + * You should have received a copy of the GNU General Public License version 53.21 + * 2 along with this work; if not, write to the Free Software Foundation, 53.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.23 + * 53.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 53.25 + * or visit www.oracle.com if you need additional information or have any 53.26 + * questions. 53.27 + */ 53.28 + 53.29 +package com.sun.xml.internal.xsom.util; 53.30 + 53.31 +import java.security.AccessController; 53.32 +import java.security.PrivilegedAction; 53.33 +import java.text.MessageFormat; 53.34 +import java.util.ResourceBundle; 53.35 +import java.util.WeakHashMap; 53.36 + 53.37 +/** 53.38 + * Simple utility ensuring that the value is cached only in case it is non-internal implementation 53.39 + */ 53.40 +abstract class ContextClassloaderLocal<V> { 53.41 + 53.42 + private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE"; 53.43 + 53.44 + private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>(); 53.45 + 53.46 + public V get() throws Error { 53.47 + ClassLoader tccl = getContextClassLoader(); 53.48 + V instance = CACHE.get(tccl); 53.49 + if (instance == null) { 53.50 + instance = createNewInstance(); 53.51 + CACHE.put(tccl, instance); 53.52 + } 53.53 + return instance; 53.54 + } 53.55 + 53.56 + public void set(V instance) { 53.57 + CACHE.put(getContextClassLoader(), instance); 53.58 + } 53.59 + 53.60 + protected abstract V initialValue() throws Exception; 53.61 + 53.62 + private V createNewInstance() { 53.63 + try { 53.64 + return initialValue(); 53.65 + } catch (Exception e) { 53.66 + throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); 53.67 + } 53.68 + } 53.69 + 53.70 + private static String format(String property, Object... args) { 53.71 + String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); 53.72 + return MessageFormat.format(text, args); 53.73 + } 53.74 + 53.75 + private static ClassLoader getContextClassLoader() { 53.76 + return (ClassLoader) 53.77 + AccessController.doPrivileged(new PrivilegedAction() { 53.78 + public Object run() { 53.79 + ClassLoader cl = null; 53.80 + try { 53.81 + cl = Thread.currentThread().getContextClassLoader(); 53.82 + } catch (SecurityException ex) { 53.83 + } 53.84 + return cl; 53.85 + } 53.86 + }); 53.87 + } 53.88 +} 53.89 +
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties Fri Mar 14 23:01:25 2014 -0700 54.3 @@ -0,0 +1,27 @@ 54.4 +# 54.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 54.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 +# 54.8 +# This code is free software; you can redistribute it and/or modify it 54.9 +# under the terms of the GNU General Public License version 2 only, as 54.10 +# published by the Free Software Foundation. Oracle designates this 54.11 +# particular file as subject to the "Classpath" exception as provided 54.12 +# by Oracle in the LICENSE file that accompanied this code. 54.13 +# 54.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 54.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.17 +# version 2 for more details (a copy is included in the LICENSE file that 54.18 +# accompanied this code). 54.19 +# 54.20 +# You should have received a copy of the GNU General Public License version 54.21 +# 2 along with this work; if not, write to the Free Software Foundation, 54.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.23 +# 54.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.25 +# or visit www.oracle.com if you need additional information or have any 54.26 +# questions. 54.27 +# 54.28 +# Error messages for ContextClassloaderLocal utility class 54.29 +FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0} 54.30 +
55.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Wed Mar 12 14:11:06 2014 -0700 55.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Fri Mar 14 23:01:25 2014 -0700 55.3 @@ -1,5 +1,5 @@ 55.4 /* 55.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 55.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 55.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.8 * 55.9 * This code is free software; you can redistribute it and/or modify it 55.10 @@ -63,10 +63,15 @@ 55.11 } 55.12 55.13 public AnnotationParser create(boolean disableSecureProcessing) { 55.14 - return new AnnotationParserImpl(); 55.15 + return new AnnotationParserImpl(disableSecureProcessing); 55.16 } 55.17 55.18 - private static final SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); 55.19 + private static final ContextClassloaderLocal<SAXTransformerFactory> stf = new ContextClassloaderLocal<SAXTransformerFactory>() { 55.20 + @Override 55.21 + protected SAXTransformerFactory initialValue() throws Exception { 55.22 + return (SAXTransformerFactory) SAXTransformerFactory.newInstance(); 55.23 + } 55.24 + }; 55.25 55.26 private static class AnnotationParserImpl extends AnnotationParser { 55.27 55.28 @@ -82,8 +87,9 @@ 55.29 55.30 AnnotationParserImpl(boolean disableSecureProcessing) { 55.31 try { 55.32 - transformer = stf.newTransformerHandler(); 55.33 - stf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing); 55.34 + SAXTransformerFactory factory = stf.get(); 55.35 + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing); 55.36 + transformer = factory.newTransformerHandler(); 55.37 } catch (TransformerConfigurationException e) { 55.38 throw new Error(e); // impossible 55.39 }
56.1 --- a/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Wed Mar 12 14:11:06 2014 -0700 56.2 +++ b/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Fri Mar 14 23:01:25 2014 -0700 56.3 @@ -1,5 +1,5 @@ 56.4 /* 56.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 56.6 + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. 56.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.8 * 56.9 * This code is free software; you can redistribute it and/or modify it 56.10 @@ -69,7 +69,7 @@ 56.11 @XmlType(name="EndpointReferenceType",namespace=W3CEndpointReference.NS) 56.12 public final class W3CEndpointReference extends EndpointReference { 56.13 56.14 - private final static JAXBContext w3cjc = getW3CJaxbContext(); 56.15 + private final JAXBContext w3cjc = getW3CJaxbContext(); 56.16 56.17 // should be changed to package private, keeping original modifier to keep backwards compatibility 56.18 protected static final String NS = "http://www.w3.org/2005/08/addressing";