author | mkos |
Fri, 23 Aug 2013 09:57:21 +0100 | |
changeset 19645 | 36f707905f2b |
parent 16791 | fe5141eabb0e |
child 23961 | 439846965790 |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
16791 | 2 |
* Copyright (c) 1997, 2013, 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 |
||
66 |
/** |
|
67 |
* Singleton instance. |
|
68 |
*/ |
|
69 |
private static volatile @NotNull XMLStreamReaderFactory theInstance; |
|
70 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
71 |
private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
72 |
|
12009 | 73 |
static { |
74 |
XMLInputFactory xif = getXMLInputFactory(); |
|
75 |
XMLStreamReaderFactory f=null; |
|
76 |
||
77 |
// this system property can be used to disable the pooling altogether, |
|
78 |
// in case someone hits an issue with pooling in the production system. |
|
16791 | 79 |
if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { |
12009 | 80 |
f = Zephyr.newInstance(xif); |
16791 | 81 |
} |
12009 | 82 |
|
83 |
if(f==null) { |
|
84 |
// is this Woodstox? |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
85 |
if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { |
12009 | 86 |
f = new Woodstox(xif); |
16791 | 87 |
} |
12009 | 88 |
} |
89 |
||
16791 | 90 |
if (f==null) { |
12009 | 91 |
f = new Default(); |
16791 | 92 |
} |
12009 | 93 |
|
94 |
theInstance = f; |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
95 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
96 |
LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
97 |
} |
12009 | 98 |
} |
99 |
||
100 |
private static XMLInputFactory getXMLInputFactory() { |
|
101 |
XMLInputFactory xif = null; |
|
102 |
if (getProperty(XMLStreamReaderFactory.class.getName()+".woodstox")) { |
|
103 |
try { |
|
104 |
xif = (XMLInputFactory)Class.forName("com.ctc.wstx.stax.WstxInputFactory").newInstance(); |
|
105 |
} catch (Exception e) { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
106 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
107 |
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
|
108 |
} |
12009 | 109 |
} |
110 |
} |
|
111 |
if (xif == null) { |
|
16791 | 112 |
xif = XmlUtil.newXMLInputFactory(true); |
12009 | 113 |
} |
114 |
xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); |
|
115 |
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false); |
|
116 |
xif.setProperty(XMLInputFactory.IS_COALESCING, true); |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
117 |
|
12009 | 118 |
return xif; |
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Overrides the singleton {@link XMLStreamReaderFactory} instance that |
|
123 |
* the JAX-WS RI uses. |
|
124 |
*/ |
|
125 |
public static void set(XMLStreamReaderFactory f) { |
|
16791 | 126 |
if(f==null) { |
127 |
throw new IllegalArgumentException(); |
|
128 |
} |
|
12009 | 129 |
theInstance = f; |
130 |
} |
|
131 |
||
132 |
public static XMLStreamReaderFactory get() { |
|
133 |
return theInstance; |
|
134 |
} |
|
135 |
||
136 |
public static XMLStreamReader create(InputSource source, boolean rejectDTDs) { |
|
137 |
try { |
|
138 |
// Char stream available? |
|
139 |
if (source.getCharacterStream() != null) { |
|
140 |
return get().doCreate(source.getSystemId(), source.getCharacterStream(), rejectDTDs); |
|
141 |
} |
|
142 |
||
143 |
// Byte stream available? |
|
144 |
if (source.getByteStream() != null) { |
|
145 |
return get().doCreate(source.getSystemId(), source.getByteStream(), rejectDTDs); |
|
146 |
} |
|
147 |
||
148 |
// Otherwise, open URI |
|
149 |
return get().doCreate(source.getSystemId(), new URL(source.getSystemId()).openStream(),rejectDTDs); |
|
150 |
} catch (IOException e) { |
|
151 |
throw new XMLReaderException("stax.cantCreate",e); |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
public static XMLStreamReader create(@Nullable String systemId, InputStream in, boolean rejectDTDs) { |
|
156 |
return get().doCreate(systemId,in,rejectDTDs); |
|
157 |
} |
|
158 |
||
159 |
public static XMLStreamReader create(@Nullable String systemId, InputStream in, @Nullable String encoding, boolean rejectDTDs) { |
|
160 |
return (encoding == null) |
|
161 |
? create(systemId, in, rejectDTDs) |
|
162 |
: get().doCreate(systemId,in,encoding,rejectDTDs); |
|
163 |
} |
|
164 |
||
165 |
public static XMLStreamReader create(@Nullable String systemId, Reader reader, boolean rejectDTDs) { |
|
166 |
return get().doCreate(systemId,reader,rejectDTDs); |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Should be invoked when the code finished using an {@link XMLStreamReader}. |
|
171 |
* |
|
172 |
* <p> |
|
173 |
* If the recycled instance implements {@link RecycleAware}, |
|
174 |
* {@link RecycleAware#onRecycled()} will be invoked to let the instance |
|
175 |
* know that it's being recycled. |
|
176 |
* |
|
177 |
* <p> |
|
178 |
* It is not a hard requirement to call this method on every {@link XMLStreamReader} |
|
179 |
* instance. Not doing so just reduces the performance by throwing away |
|
180 |
* possibly reusable instances. So the caller should always consider the effort |
|
181 |
* it takes to recycle vs the possible performance gain by doing so. |
|
182 |
* |
|
183 |
* <p> |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
184 |
* This method may be invoked by multiple threads concurrently. |
12009 | 185 |
* |
186 |
* @param r |
|
187 |
* The {@link XMLStreamReader} instance that the caller finished using. |
|
188 |
* This could be any {@link XMLStreamReader} implementation, not just |
|
189 |
* the ones that were created from this factory. So the implementation |
|
190 |
* of this class needs to be aware of that. |
|
191 |
*/ |
|
192 |
public static void recycle(XMLStreamReader r) { |
|
193 |
get().doRecycle(r); |
|
194 |
if (r instanceof RecycleAware) { |
|
195 |
((RecycleAware)r).onRecycled(); |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
// implementations |
|
200 |
||
201 |
public abstract XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs); |
|
202 |
||
203 |
private XMLStreamReader doCreate(String systemId, InputStream in, @NotNull String encoding, boolean rejectDTDs) { |
|
204 |
Reader reader; |
|
205 |
try { |
|
206 |
reader = new InputStreamReader(in, encoding); |
|
207 |
} catch(UnsupportedEncodingException ue) { |
|
208 |
throw new XMLReaderException("stax.cantCreate", ue); |
|
209 |
} |
|
210 |
return doCreate(systemId, reader, rejectDTDs); |
|
211 |
} |
|
212 |
||
213 |
public abstract XMLStreamReader doCreate(String systemId, Reader reader, boolean rejectDTDs); |
|
214 |
||
215 |
public abstract void doRecycle(XMLStreamReader r); |
|
216 |
||
217 |
/** |
|
218 |
* Interface that can be implemented by {@link XMLStreamReader} to |
|
219 |
* be notified when it's recycled. |
|
220 |
* |
|
221 |
* <p> |
|
222 |
* This provides a filtering {@link XMLStreamReader} an opportunity to |
|
223 |
* recycle its inner {@link XMLStreamReader}. |
|
224 |
*/ |
|
225 |
public interface RecycleAware { |
|
226 |
void onRecycled(); |
|
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* {@link XMLStreamReaderFactory} implementation for SJSXP/JAXP RI. |
|
231 |
*/ |
|
16791 | 232 |
private static final class Zephyr extends XMLStreamReaderFactory { |
12009 | 233 |
private final XMLInputFactory xif; |
234 |
||
235 |
private final ThreadLocal<XMLStreamReader> pool = new ThreadLocal<XMLStreamReader>(); |
|
236 |
||
237 |
/** |
|
238 |
* Sun StAX impl <code>XMLReaderImpl.setInputSource()</code> method via reflection. |
|
239 |
*/ |
|
240 |
private final Method setInputSourceMethod; |
|
241 |
||
242 |
/** |
|
243 |
* Sun StAX impl <code>XMLReaderImpl.reset()</code> method via reflection. |
|
244 |
*/ |
|
245 |
private final Method resetMethod; |
|
246 |
||
247 |
/** |
|
248 |
* The Sun StAX impl's {@link XMLStreamReader} implementation clas. |
|
249 |
*/ |
|
250 |
private final Class zephyrClass; |
|
251 |
||
252 |
/** |
|
253 |
* Creates {@link Zephyr} instance if the given {@link XMLInputFactory} is the one |
|
254 |
* from Zephyr. |
|
255 |
*/ |
|
256 |
public static @Nullable |
|
257 |
XMLStreamReaderFactory newInstance(XMLInputFactory xif) { |
|
258 |
// check if this is from Zephyr |
|
259 |
try { |
|
260 |
Class<?> clazz = xif.createXMLStreamReader(new StringReader("<foo/>")).getClass(); |
|
261 |
// JDK has different XMLStreamReader impl class. Even if we check for that, |
|
262 |
// it doesn't have setInputSource(InputSource). Let it use Default |
|
263 |
if(!(clazz.getName().startsWith("com.sun.xml.internal.stream.")) ) |
|
264 |
return null; // nope |
|
265 |
return new Zephyr(xif,clazz); |
|
266 |
} catch (NoSuchMethodException e) { |
|
267 |
return null; // this factory is not for zephyr |
|
268 |
} catch (XMLStreamException e) { |
|
269 |
return null; // impossible to fail to parse <foo/>, but anyway |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
public Zephyr(XMLInputFactory xif, Class clazz) throws NoSuchMethodException { |
|
274 |
zephyrClass = clazz; |
|
275 |
setInputSourceMethod = clazz.getMethod("setInputSource", InputSource.class); |
|
276 |
resetMethod = clazz.getMethod("reset"); |
|
277 |
||
278 |
try { |
|
279 |
// Turn OFF internal factory caching in Zephyr. |
|
280 |
// Santiago told me that this makes it thread-safe. |
|
281 |
xif.setProperty("reuse-instance", false); |
|
282 |
} catch (IllegalArgumentException e) { |
|
283 |
// falls through |
|
284 |
} |
|
285 |
this.xif = xif; |
|
286 |
} |
|
287 |
||
288 |
/** |
|
289 |
* Fetchs an instance from the pool if available, otherwise null. |
|
290 |
*/ |
|
291 |
private @Nullable XMLStreamReader fetch() { |
|
292 |
XMLStreamReader sr = pool.get(); |
|
293 |
if(sr==null) return null; |
|
294 |
pool.set(null); |
|
295 |
return sr; |
|
296 |
} |
|
297 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
298 |
@Override |
12009 | 299 |
public void doRecycle(XMLStreamReader r) { |
300 |
if(zephyrClass.isInstance(r)) |
|
301 |
pool.set(r); |
|
302 |
} |
|
303 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
304 |
@Override |
12009 | 305 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
306 |
try { |
|
307 |
XMLStreamReader xsr = fetch(); |
|
308 |
if(xsr==null) |
|
309 |
return xif.createXMLStreamReader(systemId,in); |
|
310 |
||
311 |
// try re-using this instance. |
|
312 |
InputSource is = new InputSource(systemId); |
|
313 |
is.setByteStream(in); |
|
314 |
reuse(xsr,is); |
|
315 |
return xsr; |
|
316 |
} catch (IllegalAccessException e) { |
|
317 |
throw new XMLReaderException("stax.cantCreate",e); |
|
318 |
} catch (InvocationTargetException e) { |
|
319 |
throw new XMLReaderException("stax.cantCreate",e); |
|
320 |
} catch (XMLStreamException e) { |
|
321 |
throw new XMLReaderException("stax.cantCreate",e); |
|
322 |
} |
|
323 |
} |
|
324 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
325 |
@Override |
12009 | 326 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
327 |
try { |
|
328 |
XMLStreamReader xsr = fetch(); |
|
329 |
if(xsr==null) |
|
330 |
return xif.createXMLStreamReader(systemId,in); |
|
331 |
||
332 |
// try re-using this instance. |
|
333 |
InputSource is = new InputSource(systemId); |
|
334 |
is.setCharacterStream(in); |
|
335 |
reuse(xsr,is); |
|
336 |
return xsr; |
|
337 |
} catch (IllegalAccessException e) { |
|
338 |
throw new XMLReaderException("stax.cantCreate",e); |
|
339 |
} catch (InvocationTargetException e) { |
|
340 |
Throwable cause = e.getCause(); |
|
341 |
if (cause == null) { |
|
342 |
cause = e; |
|
343 |
} |
|
344 |
throw new XMLReaderException("stax.cantCreate", cause); |
|
345 |
} catch (XMLStreamException e) { |
|
346 |
throw new XMLReaderException("stax.cantCreate",e); |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
private void reuse(XMLStreamReader xsr, InputSource in) throws IllegalAccessException, InvocationTargetException { |
|
351 |
resetMethod.invoke(xsr); |
|
352 |
setInputSourceMethod.invoke(xsr,in); |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
/** |
|
357 |
* Default {@link XMLStreamReaderFactory} implementation |
|
358 |
* that can work with any {@link XMLInputFactory}. |
|
359 |
* |
|
360 |
* <p> |
|
361 |
* {@link XMLInputFactory} is not required to be thread-safe, but |
|
362 |
* if the create method on this implementation is synchronized, |
|
363 |
* 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
|
364 |
* race condition</a>). Hence, using a XMLInputFactory per thread. |
12009 | 365 |
*/ |
366 |
public static final class Default extends XMLStreamReaderFactory { |
|
367 |
||
368 |
private final ThreadLocal<XMLInputFactory> xif = new ThreadLocal<XMLInputFactory>() { |
|
369 |
@Override |
|
370 |
public XMLInputFactory initialValue() { |
|
371 |
return getXMLInputFactory(); |
|
372 |
} |
|
373 |
}; |
|
374 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
375 |
@Override |
12009 | 376 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
377 |
try { |
|
378 |
return xif.get().createXMLStreamReader(systemId,in); |
|
379 |
} catch (XMLStreamException e) { |
|
380 |
throw new XMLReaderException("stax.cantCreate",e); |
|
381 |
} |
|
382 |
} |
|
383 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
384 |
@Override |
12009 | 385 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
386 |
try { |
|
387 |
return xif.get().createXMLStreamReader(systemId,in); |
|
388 |
} catch (XMLStreamException e) { |
|
389 |
throw new XMLReaderException("stax.cantCreate",e); |
|
390 |
} |
|
391 |
} |
|
392 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
393 |
@Override |
12009 | 394 |
public void doRecycle(XMLStreamReader r) { |
395 |
// there's no way to recycle with the default StAX API. |
|
396 |
} |
|
397 |
||
398 |
} |
|
399 |
||
400 |
/** |
|
401 |
* Similar to {@link Default} but doesn't do any synchronization. |
|
402 |
* |
|
403 |
* <p> |
|
404 |
* This is useful when you know your {@link XMLInputFactory} is thread-safe by itself. |
|
405 |
*/ |
|
406 |
public static class NoLock extends XMLStreamReaderFactory { |
|
407 |
private final XMLInputFactory xif; |
|
408 |
||
409 |
public NoLock(XMLInputFactory xif) { |
|
410 |
this.xif = xif; |
|
411 |
} |
|
412 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
413 |
@Override |
12009 | 414 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
415 |
try { |
|
416 |
return xif.createXMLStreamReader(systemId,in); |
|
417 |
} catch (XMLStreamException e) { |
|
418 |
throw new XMLReaderException("stax.cantCreate",e); |
|
419 |
} |
|
420 |
} |
|
421 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
422 |
@Override |
12009 | 423 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
424 |
try { |
|
425 |
return xif.createXMLStreamReader(systemId,in); |
|
426 |
} catch (XMLStreamException e) { |
|
427 |
throw new XMLReaderException("stax.cantCreate",e); |
|
428 |
} |
|
429 |
} |
|
430 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
431 |
@Override |
12009 | 432 |
public void doRecycle(XMLStreamReader r) { |
433 |
// there's no way to recycle with the default StAX API. |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
/** |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
438 |
* Handles Woodstox's XIF, but sets properties to do the string interning, sets various limits, ... |
12009 | 439 |
* Woodstox {@link XMLInputFactory} is thread safe. |
440 |
*/ |
|
441 |
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
|
442 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
457 |
/* Woodstox default setting: |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
458 |
int mMaxAttributesPerElement = 1000; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
459 |
int mMaxAttributeSize = 65536 * 8; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
460 |
int mMaxChildrenPerElement = Integer.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
461 |
int mMaxElementDepth = 1000; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
462 |
long mMaxElementCount = Long.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
463 |
long mMaxCharacters = Long.MAX_VALUE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
464 |
*/ |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
465 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
466 |
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
|
467 |
private int maxAttributeSize = DEFAULT_MAX_ATTRIBUTE_SIZE; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
468 |
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
|
469 |
private int maxElementDepth = DEFAULT_MAX_ELEMENT_DEPTH; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
470 |
private long maxElementCount = DEFAULT_MAX_ELEMENT_COUNT; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
471 |
private long maxCharacters = DEFAULT_MAX_CHARACTERS; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
472 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
473 |
// 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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
private static final java.lang.String P_INTERN_NSURIS = "org.codehaus.stax2.internNsUris"; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
481 |
|
12009 | 482 |
public Woodstox(XMLInputFactory xif) { |
483 |
super(xif); |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
484 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
485 |
if (xif.isPropertySupported(P_INTERN_NSURIS)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
486 |
xif.setProperty(P_INTERN_NSURIS, true); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
487 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
488 |
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
|
489 |
} |
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 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
492 |
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
|
493 |
maxAttributesPerElement = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
494 |
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
|
495 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
496 |
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
|
497 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
498 |
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
|
499 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
500 |
} |
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 |
if (xif.isPropertySupported(P_MAX_ATTRIBUTE_SIZE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
503 |
maxAttributeSize = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
504 |
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
|
505 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
506 |
xif.setProperty(P_MAX_ATTRIBUTE_SIZE, maxAttributeSize); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
507 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
508 |
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
|
509 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
510 |
} |
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 |
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
|
513 |
maxChildrenPerElement = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
514 |
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
|
515 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
516 |
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
|
517 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
518 |
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
|
519 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
520 |
} |
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 |
if (xif.isPropertySupported(P_MAX_ELEMENT_DEPTH)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
523 |
maxElementDepth = Integer.valueOf(buildIntegerValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
524 |
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
|
525 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
526 |
xif.setProperty(P_MAX_ELEMENT_DEPTH, maxElementDepth); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
527 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
528 |
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
|
529 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
530 |
} |
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 |
if (xif.isPropertySupported(P_MAX_ELEMENT_COUNT)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
533 |
maxElementCount = Long.valueOf(buildLongValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
534 |
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
|
535 |
); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
536 |
xif.setProperty(P_MAX_ELEMENT_COUNT, maxElementCount); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
537 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
538 |
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
|
539 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
540 |
} |
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 |
if (xif.isPropertySupported(P_MAX_CHARACTERS)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
543 |
maxCharacters = Long.valueOf(buildLongValue( |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
544 |
PROPERTY_MAX_CHARACTERS, DEFAULT_MAX_CHARACTERS) |
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 |
xif.setProperty(P_MAX_CHARACTERS, maxCharacters); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
547 |
if (LOGGER.isLoggable(Level.FINE)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
548 |
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
|
549 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
550 |
} |
12009 | 551 |
} |
552 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
553 |
@Override |
12009 | 554 |
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) { |
555 |
return super.doCreate(systemId, in, rejectDTDs); |
|
556 |
} |
|
557 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
558 |
@Override |
12009 | 559 |
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) { |
560 |
return super.doCreate(systemId, in, rejectDTDs); |
|
561 |
} |
|
562 |
} |
|
563 |
||
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
564 |
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
|
565 |
String propVal = System.getProperty(propertyName); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
566 |
if (propVal != null && propVal.length() > 0) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
567 |
try { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
568 |
Integer value = Integer.parseInt(propVal); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
569 |
if (value > 0) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
570 |
// return with the value in System property |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
571 |
return value; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
572 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
573 |
} catch (NumberFormatException nfe) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
574 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
575 |
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
|
576 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
577 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
578 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
579 |
// return with the default value |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
580 |
return defaultValue; |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
581 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
582 |
|
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
583 |
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
|
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 |
long value = Long.parseLong(propVal); |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
588 |
if (value > 0L) { |
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 |
// defult will be returned |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
594 |
if (LOGGER.isLoggable(Level.WARNING)) { |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
595 |
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
|
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 |
} |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
599 |
// return with the default value |
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
600 |
return defaultValue; |
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 |
|
12009 | 603 |
private static Boolean getProperty(final String prop) { |
604 |
return AccessController.doPrivileged( |
|
605 |
new java.security.PrivilegedAction<Boolean>() { |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
606 |
@Override |
12009 | 607 |
public Boolean run() { |
608 |
String value = System.getProperty(prop); |
|
609 |
return value != null ? Boolean.valueOf(value) : Boolean.FALSE; |
|
610 |
} |
|
611 |
} |
|
612 |
); |
|
613 |
} |
|
19645
36f707905f2b
8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents:
16791
diff
changeset
|
614 |
|
12009 | 615 |
} |