users@jaxb.java.net

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

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 14 May 2007 17:02:42 -0700

Perhaps https://jaxb.dev.java.net/guide/Adding_behaviors.html might help.

Nicolas Pujol 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
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com