Reputation: 3294
I Am having three classes
@XmlRootElement
public class GeofenceParameter{
private GeofenceCenterAddress geofenceCenterAddress;
private GeofenceCenterCoordinates geofenceCenterCoordinates;
}
public class GeofenceCenterAddress extends GeofenceParameter{
}
public class GeofenceCenterCoordinate extends GeofenceParameter{
}
I Have made two different XmlAdapter extended classes to marshall and unmarshall the Geofence Paramtere in GeofenceCenterAddress And GeofenceCentereCoordinate
Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{
}
Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{
}
for getting the instance of releated to either GeofenceCenterAddress or GeofenceCenterCoordinate class from GeofenceParamter depending upon Soap request send.
For This i have used annotation in package-info.java file @XmlJavaTypeAdapters{(@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)),@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)}
But In Web Service it will give me the instance of class which i have specified fist in the annotation i.e of this @XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate) class not of @XmlJavaTypeAdapter(type=forGeofenceCenterAddress)
from GeofenceParamter.
Can U Please Help me in geeting the instance of second class also in JAXB inheritence Marshalling And Unmarshalling.
Thanks In Advance
Upvotes: 4
Views: 444
Reputation: 609
I don't remember having used @XmlJavaTypeAdapters
, but the normal usage of the @XmlJavaTypeAdapter
annotation would simply be @XmlJavaTypeAdapter(forGeofenceCenterCoordinate.class)
.
The type parameter is only necessary if the annotation is applied at the package level.
Upvotes: 1