Skip to main content

@XmlJavaTypeAdapters working?

1 reply [Last post]
jfdenise
Offline
Joined: 2004-12-20
Points: 0

I have a package-info.java file containing :
@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters({@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(value=CustomNotificationAdapter.class, type=CustomNotification.class)})

When I serialize a CustomNotification object, the associated Adapter is never called.

What am I missing.

Thanks.

Jean-Francois

Adapter class
=============
public class CustomNotificationAdapter extends XmlAdapter {

/** Creates a new instance of NotificationAdapter */
public CustomNotificationAdapter() {

}

public CustomNotification unmarshal(JAXBCustomNotificationType v) throws Exception {
System.out.println("In Adapter Unmarshal");
return new CustomNotification(null);
}

public JAXBCustomNotificationType marshal(CustomNotification v) throws Exception {
System.out.println("In Adapter Marshal");
JAXBCustomNotificationType customBean = new JAXBCustomNotificationType();
return customBean;
}
}

JAXB bound type
================

@XmlType(name = "JAXBCustomNotification")
public class JAXBCustomNotificationType extends NotificationType {

private String value;
/**
* Creates a new instance of JAXBCustomNotificationType
*/
public JAXBCustomNotificationType() {
}

public void setMyCustomExtension(String value) {
this.value = value;
}

public String getMyCustomExtension() {
return value;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sekhar
Offline
Joined: 2003-06-25
Points: 0

Please file an issue at https://jaxb.dev.java.net/servlets/ProjectIssues against this problem.