Hello all.
I generated java objects from an XSD with JAXB.
Every time I fill with data an instance of it, I need to execute a
"calculation" with it. I do that applying an XSLT transformation that
takes a long time.
What I need is to have a "status" attribute, with which I could know if
any attribute has changed since the last "calculation" in order to
return the last calculation result instead of calculating it every time
if nothing has changed.
The XSD changes every now and then, so I don't want to make changes
manually to the "generated" classes, since those changes will disappear
the next time I need to re-generate the classes.
I have been looking for a way to solve this and have thought about many
ways to do it.
Any Ideas?
Any suggestions?
Note that there could be more than one instance of the "JAXB generated"
class, so I shouldn't put the "status" attribute in some other place but
in there. (I think)
Thanks in advance.
Ely.
P.S:
This is what I'm stuck with now.
As of now, I have used AOP extensions and AOP advices in order to make
all the "changes" I have had to make. (Adding some attributes, methods,
data validation, etc).
The problem with this particular change (to add a "status" attribute) is
that when my AOP advice code gets triggered by any inner class or "type
object" setter method (generated with JAXB), the attributes and methods
from the outer classes can't be reached.
For example, imagine I added a "status" attribute and created a
"resetStatus()" method into the extracted outer Class "Comprobante".
If I try to do something like this from the advice code:
----------- BEGIN -------------
Comprobante.this.resetStatus();
----------- END ---------------
Y get the following error message:
----------- BEGIN -------------
No enclosing instance of the type Comprobante is accessible in scope
----------- END ---------------
That's why I was thinking that maybe, if the classes generated by JAXB
could have a "myOwner" attribute that gets assigned upon creation from
the ObjectFactory created by JAXB, could easily solve my problem, since
I could be able to reach the "resetStatus()" method.
I really hope anyone has a better idea of how to add a "status" attribute.
My thought solution sounds so complicated that I think there must be a
better way to do it.