users@jaxb.java.net

JAXB Life Cycle Events for Sub classes of impl classes

From: <stuart.d.davies_at_bt.com>
Date: Wed, 23 Mar 2005 15:41:12 -0000

I am very impressed with JAXB and after a small amount of effort have
been able to implement a complex application. As with all these things,
there comes a point where that small detail causes big problems. I am at
that point!

I have created a Sub Class that requires certain values to be derived by
the implementation. This derived value is read millions of times so I
would like to derive it only when the dependencies change.
  
        For example in MySubClass of MyClassImpl, A is derived from X
and Y:

        My first solution was to override setX() and setY() methods in
MySubClass and derive A within the setters.
        The problem is that during unmarshalling the setters are not
used. The properties are set directly.

        My second solution was to (in addition to my first solution)
derive A from X and Y when all values of MySubClass have been set.
Conceptually at the endElement event.
        The problem is that there do not appear to be any life cycle
events exposed that I can trap. There is no startedUnMarshal,
endedUnmarshal etc.

        My third solution would be to add listeners to the bean managed
bindings for bound and constrained properties but these do not appear to
be implemented.

        My fourth solution is to use a series of flags but I dislike
this for it's complexity and poor design.

Could you please recommend a solution.

Regards

       Stuart D Davies
       BT Exact
       Phone +44 117 3024552