【发布时间】:2012-04-23 13:45:04
【问题描述】:
我有三门课
@XmlRootElement
public class GeofenceParameter{
private GeofenceCenterAddress geofenceCenterAddress;
private GeofenceCenterCoordinates geofenceCenterCoordinates;
}
public class GeofenceCenterAddress extends GeofenceParameter{
}
public class GeofenceCenterCoordinate extends GeofenceParameter{
}
我已经制作了两个不同的 XmlAdapter 扩展类来编组和解组 GeofenceCenterAddress 和 GeofenceCentereCoordinate 中的地理围栏参数
Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{
}
Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{
}
用于根据 Soap 请求发送从 GeofenceParamter 获取与 GeofenceCenterAddress 或 GeofenceCenterCoordinate 类相关的实例。
为此,我在 package-info.java 文件 @XmlJavaTypeAdapters{(@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)),@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)} 中使用了注解
但在 Web 服务中,它会给我一个我在注释中指定的类的实例,即来自 GeofenceParamter 的 @XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate) class not of @XmlJavaTypeAdapter(type=forGeofenceCenterAddress)。
您能否帮助我在 JAXB 继承编组和解组中获取第二类的实例。
提前致谢
【问题讨论】: