Hi Annie/Wouter,
I would add that the "rolls-royce" solution will come about when insteading of
having to use the "delegation model" you describe (your class "has a" castor
bean) you can use a inheritance model (your class "is a" castor bean). In
particular my interest (documented in a past thread) is the following cycle:
1. .xsd schema => SourceGenerator => castor beans
2. castor beans => MappingTool => mapping.xml
3. write your classes which extend the castor beans where business logic is
needed, and change the mapping.xml file so that your classes are created during
unmarshalling (rather then just the castor beans).
In my usage this would be the ideal as it:
a. saves the need to write the all facade methods to delegate to the castor
marshalling/unmarshalling methods in the bean
b. means you only create one object (which is both business and castor
aware) instead of two (one business object and one castor bean) for each
instance of your classes.
Of course if there is a lot of business logic (or it needs to be distributed)
then the overhead of having to objects/delegation may well be worth the trouble
(or EJB wouldn't exist ;-)
The cycle I outline above is not currently possible due to some
incompatibilities between the SourceGenerator and MappingTool detailed in past
postings, but is sounds like Arnaud Blandin's mapping extensions in 0.9.4 may
well help the cause (feel free to correct me/clarify Arnaud).
Cheers,
Norval
|--------+--------------------------->
| | wouter.zoons@glob|
| | alsign.net |
| | |
| | 28/03/2002 09:52 |
| | AM |
| | Please respond to|
| | castor-dev |
| | |
|--------+--------------------------->
>--------------------------------------------------------|
| |
| To: [EMAIL PROTECTED] |
| cc: (bcc: Norval Hope/ISD/VWA) |
| Subject: Re: [castor-dev] about source |
| generator |
>--------------------------------------------------------|
hi Annie,
just a small remark on what you said about regenerating the java
files...
It is a good idea to generate a new class for each class generated by
the 'source generator',
this class typically encapsulates the generated one and implements the
'business logic'.
I got the idea from J2EE and EJB more specifically, where you have the
notion of entity beans and session beans.
In short: the entity beans (in this case the auto-generated classes) are
responsible for the persistence (loading/saving/etc...) whereas the
session beans (in this case the classes you write yourself) handle the
context specific tasks.
This allows regeneration of the auto-generated classes since you will
never tough them yourself. Small changes such as changes in cardinality
of an element or type of an attribute will therefore only need an update
of the classes you write yourself (you will first auto-generate
everything again, and then patch one not-auto-generated file)
I guess most people take this approach.
ps: The classes I write myself each take their respective auto-generated
class as an argument in the constructor and typically only have one
other public method. This, however, is completely up to the developer.
It worked from the first time with me using Castor and I must say I was
VERY impressed by the result
(reusability/maintainability/stability/etc...)
good luck!
Wouter.
I hope my explanation is clear enough...
ps: It would be a very cool feature in Castor if the 'session beans'
were also generated using some kind om 'mapping' file or something. this
would certainly help a lot! Does anybody know if some request like this
has been posted before (I did not find it in the archives)
-----Original Message-----
From: Annie Zhang [mailto:[EMAIL PROTECTED]]
Sent: woensdag 27 maart 2002 23:04
To: [EMAIL PROTECTED]
Subject: [castor-dev] about source generator
Hi, I'm a newbie of Castor. I want to use Castor with Oracle to generate
all value objects of tables. What steps should I take? And How the
source generator can help me to generate source code?
Suppose I have add some code to the generated java files, and in the
further, I modify the table definiation. What will happen if I
re-generate the java files? All the code I added will lost?
Thanks
Annie
|
hi
Annie,
just a
small remark on what you said about regenerating the java
files...
It
is a good idea to generate a new class for each class generated
by the 'source generator',
this
class typically encapsulates the generated one and implements the 'business
logic'.
I got
the idea from J2EE and EJB more specifically, where you have the notion of
entity beans and session beans.
In
short: the entity beans (in this case the auto-generated classes) are
responsible for the persistence (loading/saving/etc...) whereas the session
beans (in this case the classes you write yourself) handle the context specific
tasks.
This
allows regeneration of the auto-generated classes since you will never tough
them yourself. Small changes such as changes in cardinality of an element or
type of an attribute will therefore only need an update of the classes you write
yourself (you will first auto-generate everything again, and then patch one
not-auto-generated file)
I guess most people take this
approach.
ps: The classes I write myself each take their
respective auto-generated class as an argument in the constructor and typically
only have one other public method. This, however, is completely up to the
developer. It worked from the first time with me using Castor and I must say I
was VERY impressed by the result
(reusability/maintainability/stability/etc...)
good luck!
Wouter.
I
hope my explanation is clear enough...
ps: It
would be a very cool feature in Castor if the 'session beans' were also
generated using some kind om 'mapping' file or something. this would certainly
help a lot! Does anybody know if some request like this has been posted before
(I did not find it in the archives)
|
