author | mkos |
Fri, 30 Oct 2015 10:34:46 +0100 | |
changeset 33547 | e4c76ac38b12 |
parent 27837 | 86d4f46e622a |
child 45678 | 65fdff10664d |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
33547
e4c76ac38b12
8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents:
27837
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.xml.internal.ws.api.streaming; |
|
27 |
||
28 |
import com.sun.istack.internal.NotNull; |
|
29 |
import com.sun.istack.internal.Nullable; |
|
30 |
import com.sun.xml.internal.ws.streaming.XMLReaderException; |
|
16791 | 31 |
import com.sun.xml.internal.ws.util.xml.XmlUtil; |
12009 | 32 |
import org.xml.sax.InputSource; |
33 |
||
34 |
import javax.xml.stream.XMLInputFactory; |
|
35 |
import javax.xml.stream.XMLStreamException; |
|
36 |
import javax.xml.stream.XMLStreamReader; |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
37 |
import java.io.IOException; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
38 |
import java.io.InputStream; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
39 |
import java.io.InputStreamReader; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
40 |
import java.io.Reader; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
41 |
import java.io.StringReader; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
42 |
import java.io.UnsupportedEncodingException; |
12009 | 43 |
import java.lang.reflect.InvocationTargetException; |
44 |
import java.lang.reflect.Method; |
|
45 |
import java.net.URL; |
|
16791 | 46 |
import java.security.AccessController; |
47 |
import java.util.logging.Level; |
|
12009 | 48 |
import java.util.logging.Logger; |
49 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
50 |
import com.sun.xml.internal.ws.resources.StreamingMessages; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
51 |
|
12009 | 52 |
/** |
53 |
* Factory for {@link XMLStreamReader}. |
|
54 |
* |
|
55 |
* <p> |
|
56 |
* This wraps {@link XMLInputFactory} and allows us to reuse {@link XMLStreamReader} instances |
|
57 |
* when appropriate. |
|
58 |
* |
|
59 |
* @author Kohsuke Kawaguchi |
|
60 |
*/ |
|
16791 | 61 |
@SuppressWarnings("StaticNonFinalUsedInInitialization") |
12009 | 62 |
public abstract class XMLStreamReaderFactory { |
63 |
||
64 |
private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName()); |
|
65 |
||
23961 | 66 |
private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; |
67 |
||
12009 | 68 |
/** |
69 |
* Singleton instance. |
|
70 |
*/ |
|
23961 | 71 |
private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader = |
72 |
new ContextClassloaderLocal<XMLStreamReaderFactory>() { |
|
12009 | 73 |
|
23961 | 74 |
@Override |
75 |
protected XMLStreamReaderFactory initialValue() { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
76 |
|
23961 | 77 |
XMLInputFactory xif = getXMLInputFactory(); |
78 |
XMLStreamReaderFactory f=null; |
|
12009 | 79 |
|
23961 | 80 |
// this system property can be used to disable the pooling altogether, |
81 |
// in case someone hits an issue with pooling in the production system. |
|
82 |
if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { |
|
83 |
f = Zephyr.newInstance(xif); |
|
84 |
} |
|
12009 | 85 |
|
23961 | 86 |
if(f==null) { |
87 |
// is this Woodstox? |
|
88 |
if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { |
|
89 |
f = new Woodstox(xif); |
|
90 |
} |
|
91 |
} |
|
12009 | 92 |
|
23961 | 93 |
if (f==null) { |
94 |
f = new Default(); |
|
95 |
} |
|
12009 | 96 |
|
23961 | 97 |
if (LOGGER.isLoggable(Level.FINE)) { |
98 |
LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f); |
|
99 |
} |
|
100 |
return f; |
|
101 |
} |
|
102 |
}; |
|
12009 | 103 |
|
104 |
private static XMLInputFactory getXMLInputFactory() { |
|
105 |
XMLInputFactory xif = null; |
|
106 |
if (getProperty(XMLStreamReaderFactory.class.getName()+".woodstox")) { |
|
107 |
try { |
|
108 |
xif = (XMLInputFactory)Class.forName("com.ctc.wstx.stax.WstxInputFactory").newInstance(); |
|
109 |
} catch (Exception e) { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
110 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
111 |
LOGGER.log(Level.WARNING, StreamingMessages.WOODSTOX_CANT_LOAD(CLASS_NAME_OF_WSTXINPUTFACTORY), e); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
112 |
} |
12009 | 113 |
} |
114 |
} |
|
115 |
if (xif == null) { |
|
16791 | 116 |
xif = XmlUtil.newXMLInputFactory(true); |
12009 | 117 |
} |
118 |
xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); |
|
119 |
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false); |
|
120 |
xif.setProperty(XMLInputFactory.IS_COALESCING, true); |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
121 |
|
12009 | 122 |
return xif; |
123 |
} |
|
124 |
||
125 |
/** |
|
126 |
* Overrides the singleton {@link XMLStreamReaderFactory} instance that |
|
127 |
* the JAX-WS RI uses. |
|
128 |
*/ |
|
129 |
public static void set(XMLStreamReaderFactory f) { |
|
16791 | 130 |
if(f==null) { |
131 |
throw new IllegalArgumentException(); |
|
132 |
} |
|
23961 | 133 |
streamReader.set(f); |
12009 | 134 |
} |
135 |
||
136 |
public static XMLStreamReaderFactory get() { |
|
23961 | 137 |
return streamReader.get(); |
12009 | 138 |
} |
139 |
||
140 |
public static XMLStreamReader create(InputSource source, boolean rejectDTDs) { |
|
141 |
try { |
|
142 |
// Char stream available? |
|
143 |
if (source.getCharacterStream() != null) { |
|
144 |
return get().doCreate(source.getSystemId(), source.getCharacterStream(), rejectDTDs); |
|
145 |
} |
|
146 |
||
147 |
// Byte stream available? |
|
148 |
if (source.getByteStream() != null) { |
|
149 |
return get().doCreate(source.getSystemId(), source.getByteStream(), rejectDTDs); |
|
150 |
} |
|
151 |
||
152 |
// Otherwise, open URI |
|
153 |
return get().doCreate(source.getSystemId(), new URL(source.getSystemId()).openStream(),rejectDTDs); |
|
154 |
} catch (IOException e) { |
|
155 |
throw new XMLReaderException("stax.cantCreate",e); |
|
156 |
} |
|
157 |
} |
|
158 |
||
159 |
public static XMLStreamReader create(@Nullable String systemId, InputStream in, boolean rejectDTDs) { |
|
160 |
return get().doCreate(systemId,in,rejectDTDs); |
|
161 |
} |
|
162 |
||
163 |
public static XMLStreamReader create(@Nullable String systemId, InputStream in, @Nullable String encoding, boolean rejectDTDs) { |
|
164 |
return (encoding == null) |
|
165 |
? create(systemId, in, rejectDTDs) |
|
166 |
: get().doCreate(systemId,in,encoding,rejectDTDs); |
|
167 |
} |
|
168 |
||
169 |
public static XMLStreamReader create(@Nullable String systemId, Reader reader, boolean rejectDTDs) { |
|
170 |
return get().doCreate(systemId,reader,rejectDTDs); |
|
171 |
} |
|
172 |
||
173 |
/** |
|
174 |
* Should be invoked when the code finished using an {@link XMLStreamReader}. |
|
175 |
* |
|
176 |
* <p> |
|
177 |
* If the recycled instance implements {@link RecycleAware}, |
|
178 |
* {@link RecycleAware#onRecycled()} will be invoked to let the instance |
|
179 |
* know that it's being recycled. |
|
180 |
* |
|
181 |
* <p> |
|
182 |
* It is not a hard requirement to call this method on every {@link XMLStreamReader} |
|
183 |
* instance. Not doing so just reduces the performance by throwing away |
|
184 |
* possibly reusable instances. So the caller should always consider the effort |
|
185 |
* it takes to recycle vs the possible performance gain by doing so. |
|
186 |
* |
|
187 |
* <p> |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
188 |
* This method may be invoked by multiple threads concurrently. |
12009 | 189 |
* |
190 |
* @param r |
|
191 |
* The {@link XMLStreamReader} instance that the caller finished using. |
|
192 |
* This could be any {@link XMLStreamReader} implementation, not just |
|
193 |
* the ones that were created from this factory. So the implementation |
|
194 |
* of this class needs to be aware of that. |
|
195 |
*/ |
|
196 |
public static void recycle(XMLStreamReader r) { |
|
33547
e4c76ac38b12
8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents:
27837
diff
changeset
|
197 |
/* the XMLStreamReaderFactory recycle becomes expenisve in the threadLocal get operation. |
12009 | 198 |
get().doRecycle(r); |
199 |
if (r instanceof RecycleAware) { |
|
200 |
((RecycleAware)r).onRecycled(); |
|
33547
e4c76ac38b12
8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents:
27837
diff
changeset
|
201 |
}*/ |
12009 | 202 |
} |
203 |
||
204 |
// implementations |
|
205 |
||
206 |
public abstract XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs); |
|
207 |
||
208 |
private XMLStreamReader doCreate(String systemId, InputStream in, @NotNull String encoding, boolean rejectDTDs) { |
|
209 |
Reader reader; |
|
210 |
try { |
|
211 |
reader = new InputStreamReader(in, encoding); |
|
212 |
} catch(UnsupportedEncodingException ue) { |
|
213 |
throw new XMLReaderException("stax.cantCreate", ue); |
|
214 |
} |
|
215 |
return doCreate(systemId, reader, rejectDTDs); |
|
216 |
} |
|
217 |
||
218 |
public abstract XMLStreamReader doCreate(String systemId, Reader reader, boolean rejectDTDs); |
|
219 |
||
220 |
public abstract void doRecycle(XMLStreamReader r); |
|
221 |
||
222 |
/** |
|
223 |
* Interface that can be implemented by {@link XMLStreamReader} to |
|
224 |
* be notified when it's recycled. |
|
225 |
* |
|
226 |
* <p> |
|
227 |
* This provides a filtering {@link XMLStreamReader} an opportunity to |
|
228 |
* recycle its inner {@link XMLStreamReader}. |
|
229 |
*/ |
|
230 |
public interface RecycleAware { |
|
231 |
void onRecycled(); |
|
232 |
} |
|
233 |
||
234 |
/** |
|
235 |
* {@link XMLStreamReaderFactory} implementation for SJSXP/JAXP RI. |
|
236 |
*/ |
|
16791 | 237 |
private static final class Zephyr extends XMLStreamReaderFactory { |
12009 | 238 |
private final XMLInputFactory xif; |
239 |
||
240 |
private final ThreadLocal<XMLStreamReader> pool = new ThreadLocal<XMLStreamReader>(); |
|
241 |
||
242 |
/** |
|
243 |
* Sun StAX impl <code>XMLReaderImpl.setInputSource()</code> method via reflection. |
|
244 |
*/ |
|
245 |
private final Method setInputSourceMethod; |
|
246 |
||
247 |
/** |
|
248 |
* Sun StAX impl <code>XMLReaderImpl.reset()</code> method via reflection. |
|
249 |
*/ |
|
250 |
private final Method resetMethod; |
|
251 |
||
252 |
/** |
|
253 |
* The Sun StAX impl's {@link XMLStreamReader} implementation clas. |
|
254 |
*/ |
|
255 |
private final Class zephyrClass; |
|
256 |
||
257 |
/** |
|
258 |
* Creates {@link Zephyr} instance if the given {@link XMLInputFactory} is the one |
|
259 |
* from Zephyr. |
|
260 |
*/ |
|
261 |
public static @Nullable |
|
262 |
XMLStreamReaderFactory newInstance(XMLInputFactory xif) { |
|
263 |
// check if this is from Zephyr |
|
264 |
try { |
|
265 |
Class<?> clazz = xif.createXMLStreamReader(new StringReader("<foo/>")).getClass(); |
|
266 |
// JDK has different XMLStreamReader impl class. Even if we check for that, |
|
267 |
// it doesn't have setInputSource(InputSource). Let it use Default |
|
268 |
if(!(clazz.getName().startsWith("com.sun.xml.internal.stream.")) ) |
|
269 |
return null; // nope |
|
270 |
return new Zephyr(xif,clazz); |
|
271 |
} catch (NoSuchMethodException e) { |
|
272 |
return null; // this factory is not for zephyr |
|
273 |
} catch (XMLStreamException e) { |
|
274 |
return null; // impossible to fail to parse <foo/>, but anyway |
|
275 |
} |
|
276 |
} |
|
277 |
||
278 |
public Zephyr(XMLInputFactory xif, Class clazz) throws NoSuchMethodException { |
|
279 |
zephyrClass = clazz; |
|
280 |
setInputSourceMethod = clazz.getMethod("setInputSource", InputSource.class); |
|
281 |
resetMethod = clazz.getMethod("reset"); |
|
282 |
||
283 |
try { |
|
284 |
// Turn OFF internal factory caching in Zephyr. |
|
285 |
// Santiago told me that this makes it thread-safe. |
|
286 |
xif.setProperty("reuse-instance", false); |
|
287 |
} catch (IllegalArgumentException e) { |
|
288 |
// falls through |
|
289 |
} |
|
290 |
this.xif = xif; |
|
291 |
} |
|
292 |
||
293 |
/** |
|
294 |
* Fetchs an instance from the pool if available, otherwise null. |
|
295 |
*/ |
|
296 |
private @Nullable XMLStreamReader fetch() { |
|
297 |
XMLStreamReader sr = pool.get(); |
|
298 |
if(sr==null) return null; |
|
299 |
pool.set(null); |
|
300 |
return sr; |
|
301 |
} |
|
302 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
303 |
@Override |
12009 | 304 |
public void doRecycle(XMLStreamReader r) { |
305 |
if(zephyrClass.isInstance(r)) |
|
306 |
pool.set(r); |
|
307 |
} |
|
308 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
309 |
@Override |
12009 | 310 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
311 |
try { |
|
312 |
XMLStreamReader xsr = fetch(); |
|
313 |
if(xsr==null) |
|
314 |
return xif.createXMLStreamReader(systemId,in); |
|
315 |
||
316 |
// try re-using this instance. |
|
317 |
InputSource is = new InputSource(systemId); |
|
318 |
is.setByteStream(in); |
|
319 |
reuse(xsr,is); |
|
320 |
return xsr; |
|
321 |
} catch (IllegalAccessException e) { |
|
322 |
throw new XMLReaderException("stax.cantCreate",e); |
|
323 |
} catch (InvocationTargetException e) { |
|
324 |
throw new XMLReaderException("stax.cantCreate",e); |
|
325 |
} catch (XMLStreamException e) { |
|
326 |
throw new XMLReaderException("stax.cantCreate",e); |
|
327 |
} |
|
328 |
} |
|
329 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
330 |
@Override |
12009 | 331 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
332 |
try { |
|
333 |
XMLStreamReader xsr = fetch(); |
|
334 |
if(xsr==null) |
|
335 |
return xif.createXMLStreamReader(systemId,in); |
|
336 |
||
337 |
// try re-using this instance. |
|
338 |
InputSource is = new InputSource(systemId); |
|
339 |
is.setCharacterStream(in); |
|
340 |
reuse(xsr,is); |
|
341 |
return xsr; |
|
342 |
} catch (IllegalAccessException e) { |
|
343 |
throw new XMLReaderException("stax.cantCreate",e); |
|
344 |
} catch (InvocationTargetException e) { |
|
345 |
Throwable cause = e.getCause(); |
|
346 |
if (cause == null) { |
|
347 |
cause = e; |
|
348 |
} |
|
349 |
throw new XMLReaderException("stax.cantCreate", cause); |
|
350 |
} catch (XMLStreamException e) { |
|
351 |
throw new XMLReaderException("stax.cantCreate",e); |
|
352 |
} |
|
353 |
} |
|
354 |
||
355 |
private void reuse(XMLStreamReader xsr, InputSource in) throws IllegalAccessException, InvocationTargetException { |
|
356 |
resetMethod.invoke(xsr); |
|
357 |
setInputSourceMethod.invoke(xsr,in); |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
/** |
|
362 |
* Default {@link XMLStreamReaderFactory} implementation |
|
363 |
* that can work with any {@link XMLInputFactory}. |
|
364 |
* |
|
365 |
* <p> |
|
366 |
* {@link XMLInputFactory} is not required to be thread-safe, but |
|
367 |
* if the create method on this implementation is synchronized, |
|
368 |
* it may run into (see <a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=555"> |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
369 |
* race condition</a>). Hence, using a XMLInputFactory per thread. |
12009 | 370 |
*/ |
371 |
public static final class Default extends XMLStreamReaderFactory { |
|
372 |
||
373 |
private final ThreadLocal<XMLInputFactory> xif = new ThreadLocal<XMLInputFactory>() { |
|
374 |
@Override |
|
375 |
public XMLInputFactory initialValue() { |
|
376 |
return getXMLInputFactory(); |
|
377 |
} |
|
378 |
}; |
|
379 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
380 |
@Override |
12009 | 381 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
382 |
try { |
|
383 |
return xif.get().createXMLStreamReader(systemId,in); |
|
384 |
} catch (XMLStreamException e) { |
|
385 |
throw new XMLReaderException("stax.cantCreate",e); |
|
386 |
} |
|
387 |
} |
|
388 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
389 |
@Override |
12009 | 390 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
391 |
try { |
|
392 |
return xif.get().createXMLStreamReader(systemId,in); |
|
393 |
} catch (XMLStreamException e) { |
|
394 |
throw new XMLReaderException("stax.cantCreate",e); |
|
395 |
} |
|
396 |
} |
|
397 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
398 |
@Override |
12009 | 399 |
public void doRecycle(XMLStreamReader r) { |
400 |
// there's no way to recycle with the default StAX API. |
|
401 |
} |
|
402 |
||
403 |
} |
|
404 |
||
405 |
/** |
|
406 |
* Similar to {@link Default} but doesn't do any synchronization. |
|
407 |
* |
|
408 |
* <p> |
|
409 |
* This is useful when you know your {@link XMLInputFactory} is thread-safe by itself. |
|
410 |
*/ |
|
411 |
public static class NoLock extends XMLStreamReaderFactory { |
|
412 |
private final XMLInputFactory xif; |
|
413 |
||
414 |
public NoLock(XMLInputFactory xif) { |
|
415 |
this.xif = xif; |
|
416 |
} |
|
417 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
418 |
@Override |
12009 | 419 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
420 |
try { |
|
421 |
return xif.createXMLStreamReader(systemId,in); |
|
422 |
} catch (XMLStreamException e) { |
|
423 |
throw new XMLReaderException("stax.cantCreate",e); |
|
424 |
} |
|
425 |
} |
|
426 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
427 |
@Override |
12009 | 428 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
429 |
try { |
|
430 |
return xif.createXMLStreamReader(systemId,in); |
|
431 |
} catch (XMLStreamException e) { |
|
432 |
throw new XMLReaderException("stax.cantCreate",e); |
|
433 |
} |
|
434 |
} |
|
435 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
436 |
@Override |
12009 | 437 |
public void doRecycle(XMLStreamReader r) { |
438 |
// there's no way to recycle with the default StAX API. |
|
439 |
} |
|
440 |
} |
|
441 |
||
442 |
/** |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
443 |
* Handles Woodstox's XIF, but sets properties to do the string interning, sets various limits, ... |
12009 | 444 |
* Woodstox {@link XMLInputFactory} is thread safe. |
445 |
*/ |
|
446 |
public static final class Woodstox extends NoLock { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
447 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
448 |
public final static String PROPERTY_MAX_ATTRIBUTES_PER_ELEMENT = "xml.ws.maximum.AttributesPerElement"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
449 |
public final static String PROPERTY_MAX_ATTRIBUTE_SIZE = "xml.ws.maximum.AttributeSize"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
450 |
public final static String PROPERTY_MAX_CHILDREN_PER_ELEMENT = "xml.ws.maximum.ChildrenPerElement"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
451 |
public final static String PROPERTY_MAX_ELEMENT_COUNT = "xml.ws.maximum.ElementCount"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
452 |
public final static String PROPERTY_MAX_ELEMENT_DEPTH = "xml.ws.maximum.ElementDepth"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
453 |
public final static String PROPERTY_MAX_CHARACTERS = "xml.ws.maximum.Characters"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
454 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
455 |
private static final int DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT = 500; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
456 |
private static final int DEFAULT_MAX_ATTRIBUTE_SIZE = 65536 * 8; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
457 |
private static final int DEFAULT_MAX_CHILDREN_PER_ELEMENT = Integer.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
458 |
private static final int DEFAULT_MAX_ELEMENT_DEPTH = 500; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
459 |
private static final long DEFAULT_MAX_ELEMENT_COUNT = Integer.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
460 |
private static final long DEFAULT_MAX_CHARACTERS = Long.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
461 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
462 |
/* Woodstox default setting: |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
463 |
int mMaxAttributesPerElement = 1000; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
464 |
int mMaxAttributeSize = 65536 * 8; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
465 |
int mMaxChildrenPerElement = Integer.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
466 |
int mMaxElementDepth = 1000; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
467 |
long mMaxElementCount = Long.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
468 |
long mMaxCharacters = Long.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
469 |
*/ |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
470 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
471 |
private int maxAttributesPerElement = DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
472 |
private int maxAttributeSize = DEFAULT_MAX_ATTRIBUTE_SIZE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
473 |
private int maxChildrenPerElement = DEFAULT_MAX_CHILDREN_PER_ELEMENT; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
474 |
private int maxElementDepth = DEFAULT_MAX_ELEMENT_DEPTH; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
475 |
private long maxElementCount = DEFAULT_MAX_ELEMENT_COUNT; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
476 |
private long maxCharacters = DEFAULT_MAX_CHARACTERS; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
477 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
478 |
// Note: this is a copy from com.ctc.wstx.api.WstxInputProperties, to be removed in the future |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
479 |
private static final java.lang.String P_MAX_ATTRIBUTES_PER_ELEMENT = "com.ctc.wstx.maxAttributesPerElement"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
480 |
private static final java.lang.String P_MAX_ATTRIBUTE_SIZE = "com.ctc.wstx.maxAttributeSize"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
481 |
private static final java.lang.String P_MAX_CHILDREN_PER_ELEMENT = "com.ctc.wstx.maxChildrenPerElement"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
482 |
private static final java.lang.String P_MAX_ELEMENT_COUNT = "com.ctc.wstx.maxElementCount"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
483 |
private static final java.lang.String P_MAX_ELEMENT_DEPTH = "com.ctc.wstx.maxElementDepth"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
484 |
private static final java.lang.String P_MAX_CHARACTERS = "com.ctc.wstx.maxCharacters"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
485 |
private static final java.lang.String P_INTERN_NSURIS = "org.codehaus.stax2.internNsUris"; |
27837
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
486 |
private static final java.lang.String P_RETURN_NULL_FOR_DEFAULT_NAMESPACE = "com.ctc.wstx.returnNullForDefaultNamespace"; |
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
487 |
|
12009 | 488 |
public Woodstox(XMLInputFactory xif) { |
489 |
super(xif); |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
490 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
491 |
if (xif.isPropertySupported(P_INTERN_NSURIS)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
492 |
xif.setProperty(P_INTERN_NSURIS, true); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
493 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
494 |
LOGGER.log(Level.FINE, P_INTERN_NSURIS + " is {0}", true); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
495 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
496 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
497 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
498 |
if (xif.isPropertySupported(P_MAX_ATTRIBUTES_PER_ELEMENT)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
499 |
maxAttributesPerElement = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
500 |
PROPERTY_MAX_ATTRIBUTES_PER_ELEMENT, DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
501 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
502 |
xif.setProperty(P_MAX_ATTRIBUTES_PER_ELEMENT, maxAttributesPerElement); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
503 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
504 |
LOGGER.log(Level.FINE, P_MAX_ATTRIBUTES_PER_ELEMENT + " is {0}", maxAttributesPerElement); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
505 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
506 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
507 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
508 |
if (xif.isPropertySupported(P_MAX_ATTRIBUTE_SIZE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
509 |
maxAttributeSize = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
510 |
PROPERTY_MAX_ATTRIBUTE_SIZE, DEFAULT_MAX_ATTRIBUTE_SIZE) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
511 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
512 |
xif.setProperty(P_MAX_ATTRIBUTE_SIZE, maxAttributeSize); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
513 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
514 |
LOGGER.log(Level.FINE, P_MAX_ATTRIBUTE_SIZE + " is {0}", maxAttributeSize); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
515 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
516 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
517 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
518 |
if (xif.isPropertySupported(P_MAX_CHILDREN_PER_ELEMENT)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
519 |
maxChildrenPerElement = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
520 |
PROPERTY_MAX_CHILDREN_PER_ELEMENT, DEFAULT_MAX_CHILDREN_PER_ELEMENT) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
521 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
522 |
xif.setProperty(P_MAX_CHILDREN_PER_ELEMENT, maxChildrenPerElement); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
523 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
524 |
LOGGER.log(Level.FINE, P_MAX_CHILDREN_PER_ELEMENT + " is {0}", maxChildrenPerElement); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
525 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
526 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
527 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
528 |
if (xif.isPropertySupported(P_MAX_ELEMENT_DEPTH)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
529 |
maxElementDepth = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
530 |
PROPERTY_MAX_ELEMENT_DEPTH, DEFAULT_MAX_ELEMENT_DEPTH) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
531 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
532 |
xif.setProperty(P_MAX_ELEMENT_DEPTH, maxElementDepth); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
533 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
534 |
LOGGER.log(Level.FINE, P_MAX_ELEMENT_DEPTH + " is {0}", maxElementDepth); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
535 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
536 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
537 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
538 |
if (xif.isPropertySupported(P_MAX_ELEMENT_COUNT)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
539 |
maxElementCount = Long.valueOf(buildLongValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
540 |
PROPERTY_MAX_ELEMENT_COUNT, DEFAULT_MAX_ELEMENT_COUNT) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
541 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
542 |
xif.setProperty(P_MAX_ELEMENT_COUNT, maxElementCount); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
543 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
544 |
LOGGER.log(Level.FINE, P_MAX_ELEMENT_COUNT + " is {0}", maxElementCount); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
545 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
546 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
547 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
548 |
if (xif.isPropertySupported(P_MAX_CHARACTERS)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
549 |
maxCharacters = Long.valueOf(buildLongValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
550 |
PROPERTY_MAX_CHARACTERS, DEFAULT_MAX_CHARACTERS) |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
551 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
552 |
xif.setProperty(P_MAX_CHARACTERS, maxCharacters); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
553 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
554 |
LOGGER.log(Level.FINE, P_MAX_CHARACTERS + " is {0}", maxCharacters); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
555 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
556 |
} |
27837
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
557 |
//Using try/catch instead of isPropertySupported because Woodstox |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
558 |
//isPropertySupported is not always reliable |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
559 |
try { |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
560 |
//this is needed to make sure Woodstox behavior is spec compliant for |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
561 |
//calls to XMLStreamReader.getNamespacePrefix |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
562 |
xif.setProperty(P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, Boolean.TRUE); |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
563 |
if (LOGGER.isLoggable(Level.FINE)) { |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
564 |
LOGGER.log(Level.FINE, P_RETURN_NULL_FOR_DEFAULT_NAMESPACE + " is {0}", xif.getProperty(P_RETURN_NULL_FOR_DEFAULT_NAMESPACE)); |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
565 |
} |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
566 |
} catch (Throwable t) { |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
567 |
//ignore - this should not happen Woodstox 4.1.2 or later (maybe older version of Woodstox). |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
568 |
LOGGER.log(Level.WARNING, "Expected property not found in Woodstox input factory: '{0}'", P_RETURN_NULL_FOR_DEFAULT_NAMESPACE); |
86d4f46e622a
8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents:
25871
diff
changeset
|
569 |
} |
12009 | 570 |
} |
571 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
572 |
@Override |
12009 | 573 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
574 |
return super.doCreate(systemId, in, rejectDTDs); |
|
575 |
} |
|
576 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
577 |
@Override |
12009 | 578 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
579 |
return super.doCreate(systemId, in, rejectDTDs); |
|
580 |
} |
|
581 |
} |
|
582 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
583 |
private static int buildIntegerValue(String propertyName, int defaultValue) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
584 |
String propVal = System.getProperty(propertyName); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
585 |
if (propVal != null && propVal.length() > 0) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
586 |
try { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
587 |
Integer value = Integer.parseInt(propVal); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
588 |
if (value > 0) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
589 |
// return with the value in System property |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
590 |
return value; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
591 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
592 |
} catch (NumberFormatException nfe) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
593 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
594 |
LOGGER.log(Level.WARNING, StreamingMessages.INVALID_PROPERTY_VALUE_INTEGER(propertyName, propVal, Integer.toString(defaultValue)), nfe); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
595 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
596 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
597 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
598 |
// return with the default value |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
599 |
return defaultValue; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
600 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
601 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
602 |
private static long buildLongValue(String propertyName, long defaultValue) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
603 |
String propVal = System.getProperty(propertyName); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
604 |
if (propVal != null && propVal.length() > 0) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
605 |
try { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
606 |
long value = Long.parseLong(propVal); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
607 |
if (value > 0L) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
608 |
// return with the value in System property |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
609 |
return value; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
610 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
611 |
} catch (NumberFormatException nfe) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
612 |
// defult will be returned |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
613 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
614 |
LOGGER.log(Level.WARNING, StreamingMessages.INVALID_PROPERTY_VALUE_LONG(propertyName, propVal, Long.toString(defaultValue)), nfe); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
615 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
616 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
617 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
618 |
// return with the default value |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
619 |
return defaultValue; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
620 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
621 |
|
12009 | 622 |
private static Boolean getProperty(final String prop) { |
623 |
return AccessController.doPrivileged( |
|
624 |
new java.security.PrivilegedAction<Boolean>() { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
625 |
@Override |
12009 | 626 |
public Boolean run() { |
627 |
String value = System.getProperty(prop); |
|
628 |
return value != null ? Boolean.valueOf(value) : Boolean.FALSE; |
|
629 |
} |
|
630 |
} |
|
631 |
); |
|
632 |
} |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
633 |
|
12009 | 634 |
} |