我定义一个静态工厂方法:静态工厂方法
@XmlType(factoryClass=DummyFactory.class, factoryMethod="createNew")
public abstract MyClass() {
}
的原因,我使用工厂方法是MyClass
是抽象的,以及如何获得一个实例它依赖于一定的注解的类。该逻辑嵌入在工厂方法createNew
中。
另外,工厂类DummyFactory
是抽象的。据我了解,如果工厂方法是静态的(http://download.oracle.com/javaee/6/api/javax/xml/bind/annotation/XmlType.html),工厂类不需要提供默认构造函数。
这是工厂类看起来像一个原始的简化:
public abstract class DummyFactory {
public static MyClass createNew() {
// code for returning a new instance of MyClass
}
}
然而,当我尝试解组XML文档,我得到以下异常:
Exception [EclipseLink-171] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The factory class does not define a public default constructor, or the constructor raised an exception.
Internal Exception: java.lang.InstantiationException
第一我认为我没有正确地解释工厂类和方法,但后来我尝试了JAXB RI,并且在那里工作的很好。 所以我的问题是:
有没有办法让MOXY与抽象工厂类一起工作?
(JAXB RI给了我其他类型的问题,这就是我不愿意使用它的原因)。
我是莫西领先,这似乎是一个错误。你可以为这个问题输入一个错误:https://bugs.eclipse.org/bugs/enter_bug.cgi?product = EclipseLink。我们应该能够在Moday上得到解决。 –
完成。提交的问题:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 362984。非常感谢您的快速回复。 – Sergio
我们已经想出了修复方案,我们只需要清除测试。我希望明天我们会检查修复。 –