I think there are two options:

1) Make the JAXB databinding as the default databinding for POJOs (simple and complex types).

2) Keep the POJO databindings and implement the POJO<-->XML transformers using JAXB-impl

Thanks,
Raymond

----- Original Message ----- From: "Jean-Sebastien Delfino" <[EMAIL PROTECTED]>
To: <tuscany-dev@ws.apache.org>
Sent: Monday, November 26, 2007 3:26 PM
Subject: Re: Data transformation from/to POJO


Raymond Feng wrote:
Hi,

I just did a test to see how JAXB-RI handles the POJO without any annotations. The result seems to be promising.

I started with a POJO:

public class MyBean {
   private int age;
   private String name;
   private List<String> notes = new ArrayList<String>();

   public int getAge() {
       return age;
   }
   public void setAge(int age) {
       this.age = age;
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public List<String> getNotes() {
       return notes;
   }
   public void setNotes(List<String> notes) {
       this.notes = notes;
   }
}

The following test case is then successful.

public void testPOJO() throws Exception {
   JAXBContext context = JAXBContext.newInstance(MyBean.class);
   StringWriter writer = new StringWriter();
   MyBean bean = new MyBean();
   bean.setName("Test");
   bean.setAge(20);
   bean.getNotes().add("1");
   bean.getNotes().add("2");
JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1";, "bean"), Object.class, bean);
   context.createMarshaller().marshal(element, writer);
   System.out.println(writer.toString());
Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
   assertTrue(result instanceof JAXBElement);
   JAXBElement e2 = (JAXBElement)result;
   assertTrue(e2.getValue() instanceof MyBean);
}

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:bean xsi:type="myBean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:ns2="http://ns1";><age>20</age><name>Test</name></ns2:bean>



Good that it seems promising :) what do I need to do to get the JaxB to XML transformer to pick up the Item bean in the store tutorial?

--
Jean-Sebastien

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to