users@jaxb.java.net

Re: Problem with jxb:class implClass and jaxb1.0 to 2.1.3 conversion

From: Nicolas Pujol <nicolaspujol_at_yahoo.com>
Date: Mon, 23 Apr 2007 08:24:05 -0700 (PDT)

I found out that I could get the code to run if I
explicitly specified the object factory as such:

u.setProperty("com.sun.xml.bind.ObjectFactory",new
ObjectFactory());
where the specified objectfactory is actually the JAXB
generated factory ! Somehow my JAXBContext does not
seem to be setting itself up properly. Ideas?

Nicolas

--- Nicolas Pujol <nicolaspujol_at_yahoo.com> wrote:

> Hi,
>
> I am working on a JAXB1.0 to 2.0 (2.1.3 to be
> exact)conversion and something that used to work
> does
> not work anymore. Specifically, I could provide an
> implementation class where i had some additional
> logic
> and have JAXB automagically create an instance of
> it.
>
> I used to have this:
>
> <jxb:bindings
> node="//xs:complexType[@name='t_processType']">
>
> <jxb:class name="ProcessType"
> implClass="com.home.model.binding.MyProcessType"/>
> </jxb:bindings>
>
> So when i unmarshalled i could do :
>
> MyProcessType myType = (MyProcessType)
> u.unmarshal(stream);
>
> where I had this for class MyProcessType
>
> public class MyProcessType extends
> com.home.model.binding.impl.ProcessTypeImpl
>
> and com.home.model.binding.impl.ProcessTypeImpl was
> generated by jaxb.
>
>
> I am trying to achieve something similar with
> JAXB2.0
> and it is not working. What I did is to change
> MyProcessType to:
>
> public class MyProcessType extends ProcessType
>
> However, the object returned by u.unmarshal(stream)
> is
> of type ProcessType and NOT MyProcessType.
>
> I don't understand because there is indeed a
> corresponding objectFactory method that looks like
> this :
>
> public ProcessType createProcessType() {
> return new MyProcessType();
> }
>
> though it does not seem to get called as the no-arg
> constructor for MyProcessType() is not called ( i
> tried putting in a sys.out)
> In any case, any feedback on how to have
> u.unmarshal(stream) return an object of type
> MyProcessType would be great.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail:
> users-help_at_jaxb.dev.java.net
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com