src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java

changeset 558
d950f4a0753b
parent 515
6cd506508147
child 637
9c07ef4934dd
equal deleted inserted replaced
557:9dbb9554e406 558:d950f4a0753b
1 /* 1 /*
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
368 368
369 public final void writeTo(ContentHandler handler, ErrorHandler errorHandler) throws SAXException { 369 public final void writeTo(ContentHandler handler, ErrorHandler errorHandler) throws SAXException {
370 writeTo(handler, errorHandler, isFragment()); 370 writeTo(handler, errorHandler, isFragment());
371 } 371 }
372 372
373 private static final TransformerFactory trnsformerFactory = TransformerFactory.newInstance(); 373 private static final ContextClassloaderLocal<TransformerFactory> trnsformerFactory = new ContextClassloaderLocal<TransformerFactory>() {
374 @Override
375 protected TransformerFactory initialValue() throws Exception {
376 return TransformerFactory.newInstance();
377 }
378 };
374 379
375 /** 380 /**
376 * Writes out the contents of this buffer as DOM node and append that to the given node. 381 * Writes out the contents of this buffer as DOM node and append that to the given node.
377 * 382 *
378 * Faster implementation would be desirable. 383 * Faster implementation would be desirable.
380 * @return 385 * @return
381 * The newly added child node. 386 * The newly added child node.
382 */ 387 */
383 public final Node writeTo(Node n) throws XMLStreamBufferException { 388 public final Node writeTo(Node n) throws XMLStreamBufferException {
384 try { 389 try {
385 Transformer t = trnsformerFactory.newTransformer(); 390 Transformer t = trnsformerFactory.get().newTransformer();
386 t.transform(new XMLStreamBufferSource(this), new DOMResult(n)); 391 t.transform(new XMLStreamBufferSource(this), new DOMResult(n));
387 return n.getLastChild(); 392 return n.getLastChild();
388 } catch (TransformerException e) { 393 } catch (TransformerException e) {
389 throw new XMLStreamBufferException(e); 394 throw new XMLStreamBufferException(e);
390 } 395 }

mercurial