I have architecture problem, I greatly appreciate your time if you have some time on this problem.
I am developing service layer for my project.
I have to communicate with swing client and web ( that deployed in different container)
We have remoting mechanism in place ( written using apache http client )
New Service layer that I am trying to develope is going to reside in another different container.
All the applications will be with in same firewall and they will not going to outside firewall
Also I have existing DAO layer and it give a set of DTO objects
With the above things in mind
I am planning to have my own set of DTO's to pass to clients. Here is what I want to do
1. Swing/Web client calls Remoting layer using DTO's given by service layer
2. Remoting Layer translates every thing in to XML ( we are using xstream ?? is it bad? what are the alternatives?)
3. Service Layer unmarshalls the XML in to DTO's back ( Do I need introduce Domain Objects ?? ,
Current services do not have domain objects concept )
4. Takes the clients request and communicates with DAO Layer
5. Fills the results in to DTO's back
Is the above architecure good ? I am afraid not because I feel I do not have concept of Domain objects
Also I have 2 different set of DTO's ( one from DAO layer and one from Service Layer)
Also Service Layer is trying to give DTO's back to client ? We do not want xml over head because everything in one firewall
am I doing it right? Where can I improve this architecure?
Thanks for your time, I really appreciate your help
I don't know why you want to use DTO. DTO is for remote interfaces, this is no remote interface, a Swing client calls a servlet, it's only URL calling.
I also don't understand how using firewall is an issue for using XML. If you don't want big data size, you can use JSON, or send binary data.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Joined: Jan 22, 2003
Are you using Spring? There are many remoting options in Spring Framework for this. You can use the HttpInvoker since both sides are Java.
Mark, Thanks for the suggestion. I have plans to rewrite this remoting layer using Spring's http invoker.
But The question here is whether service layer need to maintain its own DTOs and pass it client or
do we need to use DTO's that is given by DAO layer ( these complicated and composite FAT DTO's , we cannot change this )
do you think Jason is best alternative too.? or using spring http invoker solves this problem too?
You can just use XML to communicate.
Kengkaj, Yes I am afraid of over head and big data sizes. Also we may not stick to one schema because our domain is too big
and different clients has different needs.
I will look in to Jason more.
It depends on what you want to send over. With HttpInvoker, it ends up just looking like you are calling a method on a class and getting an return Java class back. Just like the classes were local to each other. That is the easiest, over XML or JSON.
Personally, it would be best to send the Domain objects returned from the DAO, because if you create DTO (anti-pattern) then you have to write and maintain all that error-prone adapter code to convert too and from your domain objects to your DTOs.
Joined: Jan 22, 2003
Thank you Mark !, Great and Helpful Advise!
subject: Remoting - Communication between swing client and servlet