public V get() throws Error { ClassLoader tccl = getContextClassLoader(); V instance = CACHE.get(tccl); if (instance == null) { instance = createNewInstance(); CACHE.put(tccl, instance); } return instance; }
private V createNewInstance() { try { return initialValue(); } catch (Exception e) { throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e); } }
public void set(V instance) { CACHE.put(getContextClassLoader(), instance); }
/** * Writes out the contents of this buffer as DOM node and append that to the given node. * * Faster implementation would be desirable. * * @return * The newly added child node. */ public final Node writeTo(Node n) throws XMLStreamBufferException { try { Transformer t = trnsformerFactory.get().newTransformer(); t.transform(new XMLStreamBufferSource(this), new DOMResult(n)); return n.getLastChild(); } catch (TransformerException e) { throw new XMLStreamBufferException(e); } }