aspose file tools*
The moose likes Java in General and the fly likes Preventing access of DAO layer from Service layer. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Preventing access of DAO layer from Service layer." Watch "Preventing access of DAO layer from Service layer." New topic
Author

Preventing access of DAO layer from Service layer.

chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 72

Hi
I have question regarding DAO design pattern.
Generally we separate service layer from database layer by interface like DAO.
e.g


Now I will acccess the DAO class from the service layer as follows.


My question is as all of my DAO classes are public I can even access it from VIEW layer also.
How can I prevent the DAO access from Viwe layer.
Please help. I am very much confused.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just don't use them on the view layer. Or don't expose them to the view layer: not knowing what your view layer is makes it harder to help.
chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 72

Hi David
Thanks for your fast response..
How can I prevent them from exposing to View layer?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depends on the view layer. You may not be able to, if the view layer can instantiate arbitrary classes, at least not without some trickery. Which cannot possibly be worth it in almost all situations. What are you so afraid of that you must absolutely restrict access to your app's classes?
chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 72

one solution I found is if I use the Factory design pattern for DAO layer....I can prevent the access to DAO classes...
is that ok?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How does that prevent access to the DAO classes? Couldn't I just instantiate one in the JSP using a scriptlet or tag?

What *specifically* are you trying to accomplish?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preventing access of DAO layer from Service layer.
 
Similar Threads
Implementing Patterns
How automatically DAO methods get called upon
Database connection type return problem
Front controller and DAO, design question!
How automatically DAO methods get called upon