1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Thu May 30 10:58:13 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Wed Jun 12 14:47:09 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -42,6 +42,7 @@ 1.11 import java.io.StringWriter; 1.12 import java.lang.reflect.InvocationTargetException; 1.13 import java.lang.reflect.Method; 1.14 +import java.util.logging.Level; 1.15 import java.util.logging.Logger; 1.16 1.17 /** 1.18 @@ -53,6 +54,7 @@ 1.19 * 1.20 * @author Kohsuke Kawaguchi 1.21 */ 1.22 +@SuppressWarnings("StaticNonFinalUsedInInitialization") 1.23 public abstract class XMLStreamWriterFactory { 1.24 1.25 private static final Logger LOGGER = Logger.getLogger(XMLStreamWriterFactory.class.getName()); 1.26 @@ -80,8 +82,19 @@ 1.27 1.28 // this system property can be used to disable the pooling altogether, 1.29 // in case someone hits an issue with pooling in the production system. 1.30 - if(!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) 1.31 - f = Zephyr.newInstance(xof); 1.32 + if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) { 1.33 + try { 1.34 + Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass(); 1.35 + if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) { 1.36 + f = new Zephyr(xof,clazz); 1.37 + } 1.38 + } catch (XMLStreamException ex) { 1.39 + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 1.40 + } catch (NoSuchMethodException ex) { 1.41 + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); 1.42 + } 1.43 + } 1.44 + 1.45 if(f==null) { 1.46 // is this Woodstox? 1.47 if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory")) 1.48 @@ -91,7 +104,9 @@ 1.49 f = new Default(xof); 1.50 1.51 theInstance = f; 1.52 - LOGGER.fine("XMLStreamWriterFactory instance is = "+theInstance); 1.53 + if (LOGGER.isLoggable(Level.FINE)) { 1.54 + LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f); 1.55 + } 1.56 } 1.57 1.58 /** 1.59 @@ -165,6 +180,7 @@ 1.60 * @param f 1.61 * must not be null. 1.62 */ 1.63 + @SuppressWarnings({"null", "ConstantConditions"}) 1.64 public static void set(@NotNull XMLStreamWriterFactory f) { 1.65 if(f==null) throw new IllegalArgumentException(); 1.66 theInstance = f; 1.67 @@ -220,10 +236,12 @@ 1.68 this.xof = xof; 1.69 } 1.70 1.71 + @Override 1.72 public XMLStreamWriter doCreate(OutputStream out) { 1.73 return doCreate(out,"UTF-8"); 1.74 } 1.75 1.76 + @Override 1.77 public synchronized XMLStreamWriter doCreate(OutputStream out, String encoding) { 1.78 try { 1.79 XMLStreamWriter writer = xof.createXMLStreamWriter(out,encoding); 1.80 @@ -233,6 +251,7 @@ 1.81 } 1.82 } 1.83 1.84 + @Override 1.85 public void doRecycle(XMLStreamWriter r) { 1.86 // no recycling 1.87 } 1.88 @@ -284,10 +303,12 @@ 1.89 return sr; 1.90 } 1.91 1.92 + @Override 1.93 public XMLStreamWriter doCreate(OutputStream out) { 1.94 return doCreate(out,"UTF-8"); 1.95 } 1.96 1.97 + @Override 1.98 public XMLStreamWriter doCreate(OutputStream out, String encoding) { 1.99 XMLStreamWriter xsw = fetch(); 1.100 if(xsw!=null) { 1.101 @@ -311,6 +332,7 @@ 1.102 return new HasEncodingWriter(xsw, encoding); 1.103 } 1.104 1.105 + @Override 1.106 public void doRecycle(XMLStreamWriter r) { 1.107 if (r instanceof HasEncodingWriter) { 1.108 r = ((HasEncodingWriter)r).getWriter(); 1.109 @@ -340,10 +362,12 @@ 1.110 this.xof = xof; 1.111 } 1.112 1.113 + @Override 1.114 public XMLStreamWriter doCreate(OutputStream out) { 1.115 return doCreate(out, SOAPBindingCodec.UTF8_ENCODING); 1.116 } 1.117 1.118 + @Override 1.119 public XMLStreamWriter doCreate(OutputStream out, String encoding) { 1.120 try { 1.121 XMLStreamWriter writer = xof.createXMLStreamWriter(out,encoding); 1.122 @@ -353,6 +377,7 @@ 1.123 } 1.124 } 1.125 1.126 + @Override 1.127 public void doRecycle(XMLStreamWriter r) { 1.128 // no recycling 1.129 } 1.130 @@ -367,6 +392,7 @@ 1.131 this.encoding = encoding; 1.132 } 1.133 1.134 + @Override 1.135 public String getEncoding() { 1.136 return encoding; 1.137 }