何时在jaxb中创建对象工厂实例



我是Jaxb的新手。我对对象工厂有一个疑问。令人怀疑的是,它何时会被创建bean实例,其中在objectfactory类createXXXBean方法中,当调用UnMarshall进程时。检查下面的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.CreateFruitbea()

JAXBContext jContext=JAXBContext.newInstance(ObjectFactory.class);
UnMarshaller unmarshall=jContext.CreateMarshaller();
JAXBElement jElement=unmarshall.UnMarshall(XML_PATH);
@XmlRegistry
public class ObjectFactory {
   private static final QName FRUIT_QNAME = new QName("...", "...");
   public ObjectFactory() {
   }
   public Fruittype createFruittype() {
      return new Fruittype();
   }
   @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);
   }
}

最新更新