users@jaxb.java.net

XmlAdapter and no default constructor

From: jdemic <john.demic_at_gmail.com>
Date: Mon, 14 Aug 2006 14:37:11 -0700 (PDT)

Hey All,

I'm attempting to use XmlAdapter to adapt some classes from framework
classes that do not have default noarg constructors. the code looks like
this:

    protected String marshal(RemoteInvocationResult result) {
        String xml;
        try {
            StringWriter writer = new StringWriter();
            javax.xml.bind.Marshaller m = context.createMarshaller();
            m.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
            m.marshal(new JAXBElement(new QName("uri","local"),
RemoteInvocationResult.class, result),writer);
            xml = writer.toString();
        } catch (JAXBException ex) {
            System.out.println();
            throw(new XmlException("Could not map " + result, ex));
        }
        return xml;
    }

I wrote an XmlTypeAdapter for RemoteInvocationResult. I'm not sure how to
use the @XmlJavaTypeAdapter annotation to get the adapter to kick in. ive
attempted annotating the class as well as the above method to no avail.
I've also tried setting up the adapter in a package-info.java file. the
documentation ive looked at seems to assume one has access to the source of
the annotated object. this isnt the case with the above...

any ideas?
-- 
View this message in context: http://www.nabble.com/XmlAdapter-and-no-default-constructor-tf2105957.html#a5804748
Sent from the java.net - jaxb users forum at Nabble.com.