|
Replies:
5
-
Last Post:
Sep 4, 2008 9:09 AM
by: caroljmcdonald
|
|
|
|
|
|
|
best way to copy SOAP <-> ORM ?
Posted:
Sep 2, 2008 1:17 AM
|
|
|
Few days evaluating my options about binding my SOAP message objects to my JPA entities....
I have:
A soap type, let's say A A JPA entity type, let's say B
@XmlType(name = "", propOrder = {"number", ... }) class A { int number; .. }
@Entity class B { int other; ... }
How to copy the values of the message to the entity ??
Options I am considering right now:
1) Brute force, copying one by one the fields and properties from one side to another. Simple, fast and the most reliable solution, but with a lot of identical code for all entities... The number of line codes required to copy is linearly coupled with the number of entities and its attributes (can be thousands of lines to code and maintain).
2) Reflection: trying to match the getters and setters names.. it works fine for shallow copy but becomes wierd in collections and deep clonage (Dozer mess). Reflection reduces the number of lines, ad depending on the simplicity of the models, can be a good option. You pay a bit of performance but in my early experiments, the cost/benefit of reflection is good.
3) Adapters using annotations: http://tssblog.blogs.techtarget.com/2007/02/08/combining-orm-and-soap-part-1/ * My problem is not to convert Object to XML, it is to convert Object to Object (from different models)
3) Inheritance between the soap objects and entities (entities are subclasses of XML generated objects, so I need to copy only from xml to entites, the reverse order is naturally bounded by casting. What means you solve half of the problem 
hoping to hear from you something new 
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
Re: best way to copy SOAP <-> ORM ?
Posted:
Sep 2, 2008 3:02 AM
in response to: Felipe Gaúcho
|
|
|
You could try writing your own XJC plugin which injects specific converter code into your generated beans.
I've done this to generate custom serializers and I can say it's way faster than using reflection.
|
|
|
|
|
|
|
|
Re: best way to copy SOAP <-> ORM ?
Posted:
Sep 2, 2008 3:05 AM
in response to: wasppit
|
|
|
even worse, because I am looking to reduce the amout of plumbing code of copying from one side to another.... and also to reduce the cost of that copying operation (proceed several times in the common web-services operations...)
injecting the adapter I will add another cost in my adaption process...
On Tue, Sep 2, 2008 at 12:02 PM, <metro@javadesktop.org> wrote: > You could try writing your own XJC plugin which injects specific converter code into your generated beans. > > I've done this to generate custom serializers and I can say it's way faster than using reflection. > [Message sent by forum member 'wasppit' (wasppit)] > > http://forums.java.net/jive/thread.jspa?messageID=296645 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net > For additional commands, e-mail: users-help@metro.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
|
Re: best way to copy SOAP <-> ORM ?
Posted:
Sep 2, 2008 3:37 AM
in response to: Felipe Gaúcho
|
|
|
Well, the code would be generated, so you should only care about the extra jar size. Injection happens at build time, therefore you have no runtime penalty.
The trick is to inject specific code, e.g. if a bean has 2 fields, than only 2 lines of code will be generated, tailored for those 2 fields. This is as fast as it gets.
By the way, are your soap beans generated from wsdl/xsd or are you writing them by hand?
|
|
|
|
|
|
|
|
Re: best way to copy SOAP <-> ORM ?
Posted:
Sep 2, 2008 4:04 AM
in response to: wasppit
|
|
|
my project is WSDL first.. it is generated automatically by wsimport...
Full source code available is you want to check it out: https://cejug-classifieds.dev.java.net/
---------- if you want to try:
SVN: https://cejug-classifieds.dev.java.net/svn/cejug-classifieds/trunk/cejug-classifieds-server
after checkout:
- setup the environment variable AS_HOME - start database and server: asadmin start-database asadmin start-domain domain1
and run ant deploy
The project will be up and running at http://localhost:8080/cejug-classifieds-server
On Tue, Sep 2, 2008 at 12:37 PM, <metro@javadesktop.org> wrote: > Well, the code would be generated, so you should only care about the extra jar size. Injection happens at build time, therefore you have no runtime penalty. > > The trick is to inject specific code, e.g. if a bean has 2 fields, than only 2 lines of code will be generated, tailored for those 2 fields. This is as fast as it gets. > > By the way, are your soap beans generated from wsdl/xsd or are you writing them by hand? > [Message sent by forum member 'wasppit' (wasppit)] > > http://forums.java.net/jive/thread.jspa?messageID=296660 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net > For additional commands, e-mail: users-help@metro.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|