0

Jaxb の新機能です。オブジェクト ファクトリに 1 つ疑問があります。疑問は、オブジェクト ファクトリクラスのcreateXXXBeanメソッドで、UnMarshall プロセスを呼び出すときに Bean インスタンスがいつ作成されるかです。以下の 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);
4

1 に答える 1

0
@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);
   }
}
于 2012-09-05T18:33:21.563 に答える