我是 Jaxb 的新手。我对Object factory有一个疑问。疑问是何时在 objectfactory 类createXXXBean方法中创建 bean 实例,调用 UnMarshall Process 时。检查下面的 objectfactory.createFruitbean()
@XmlElementDecl(namespace = "http://as.com/items/types", name = "fruitbean")
public JAXBElement<Fruittype> createFruitbean(Fruittype value) {
return new JAXBElement<Fruittype>(_Fruitbean_QNAME, Fruittype.class, null, value);
}
请帮我。
更新 :-
我对上面的代码没有任何异常。我对 ObjectFactory.createFruitBean() 有疑问。在下面的代码片段中,它将在何处/何时调用该方法,即 ObjectFactory.createFruitbean()
JAXBContext jContext=JAXBContext.newInstance(ObjectFactory.class);
UnMarshaller unmarshall=jContext.CreateMarshaller();
JAXBElement jElement=unmarshall.UnMarshall(XML_PATH);