0
Inside Spring OXM框架JAXBContext.newInstance()
如何創建。它是單例還是多例。我的要求是我想要singleton jaxbcontext
對象?請分享Spring OXM的詳細信息。謝謝。春天的oxm是否會創建singleton jaxbcontext?
Inside Spring OXM框架JAXBContext.newInstance()
如何創建。它是單例還是多例。我的要求是我想要singleton jaxbcontext
對象?請分享Spring OXM的詳細信息。謝謝。春天的oxm是否會創建singleton jaxbcontext?
我得到了答案,它的內部創造單JAXB上下文中Jaxb2Marshaller
,就像這樣:
public JAXBContext getJaxbContext() {
if (this.jaxbContext != null) {
return this.jaxbContext;
}
synchronized (this.jaxbContextMonitor) {
if (this.jaxbContext == null) {
try {
if (StringUtils.hasLength(this.contextPath)) {
this.jaxbContext = createJaxbContextFromContextPath();
}
else if (!ObjectUtils.isEmpty(this.classesToBeBound)) {
this.jaxbContext = createJaxbContextFromClasses();
}
else if (!ObjectUtils.isEmpty(this.packagesToScan)) {
this.jaxbContext = createJaxbContextFromPackages();
}
}
catch (JAXBException ex) {
throw convertJaxbException(ex);
}
}
return this.jaxbContext;
}
}