This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO pattern

 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I've been reading posts of people who as failed on the assignment and some of them received this comment : "Missing DAO/integration classes".
Well. I communicate with 3 external systems:

1 - E-mail server. I have a DAO for it.
2 - WebService. I created a package with a Interface and a JAXB class in it and I made a note that the package represents the classes of a webservice client generated by wsimport tool. I injected the interface (@WebserviceClient) directly into my business EJB by a @WebServiceRef annotation.
3 - JMS: I receive messages from another system and I have a MDB that takes the message, unmarshal it and sends to my business EJB.

My question: For the cases number 2 and 3 I have classes that act as DAO but aren't named as so.

I woudn't do it in real life, but for the case of exam, do I have to create additional DAOs for the cases 2 and 3? I think it's strange, but as some people have failed for it, I think it's wise ask for your opinion.

Thanks

By the way. Do you think that the a approach I used in case 2, for represent the webservice integration, is appropriated?

Thanks a lot.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't use a DAO for accessing JMS or a web service. Maybe another pattern though. Facade/adapter?
 
Andres Olarte
Ranch Hand
Posts: 46
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the key here is the separation of concerns. Your service layer should only do business logic, it should not worry about issuing HTTP calls to the webservice. If you inject your @WebserviceClient into your service layer, that seems like a nice separation of concerns. DAO are supposed to provide abstraction to a persistent store. Normally this store is your database, but you could also access a BigData store using a webserice, and still call it a DAO.

I would say that names are not critical, but the intention of the classes is. You could move them to an "integration" package. You could rename them as Facade/Adapter like Jeanne suggested. Just make sure that the single responsibility of the class is evident, and that you separate your business logic from your data access/integration logic.

Andres
 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne and Thanks Andres.

I think Andres got my point of view. If I'm already injecting with @WebServiceRef in service layer (my business ejb) I already have a proper separation of concerns, then I don't need a DAO or Fa├žade, all the http stuff will be done by the generated @WebServiceCilent. I'll place the webservice client in a integration package and this is it.

Thanks again =]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic