mirror of https://github.com/apache/poi.git
XSLF Performance - don't initialize the JAXBContext every time
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1873499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bb5bce5f6
commit
4a2273c370
|
@ -42,7 +42,19 @@ import org.apache.poi.util.XMLHelper;
|
||||||
*/
|
*/
|
||||||
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
||||||
protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
|
private final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
|
||||||
|
|
||||||
|
private static class SingletonHelper {
|
||||||
|
private static JAXBContext JAXB_CONTEXT;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
JAXB_CONTEXT = JAXBContext.newInstance(BINDING_PACKAGE);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static PresetGeometries _inst;
|
protected static PresetGeometries _inst;
|
||||||
|
|
||||||
|
@ -57,7 +69,7 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
streamReader.nextTag();
|
streamReader.nextTag();
|
||||||
|
|
||||||
// JAXB:
|
// JAXB:
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
JAXBContext jaxbContext = SingletonHelper.JAXB_CONTEXT;
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
|
||||||
long cntElem = 0;
|
long cntElem = 0;
|
||||||
|
@ -82,7 +94,7 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
*/
|
*/
|
||||||
public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) {
|
public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) {
|
||||||
try {
|
try {
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
JAXBContext jaxbContext = SingletonHelper.JAXB_CONTEXT;
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
|
JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
|
||||||
return new CustomGeometry(el.getValue());
|
return new CustomGeometry(el.getValue());
|
||||||
|
|
Loading…
Reference in New Issue