aspose file tools*
The moose likes Design and the fly likes What is Service layer in J2ee design Princples? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Design
Bookmark "What is Service layer in J2ee design Princples?" Watch "What is Service layer in J2ee design Princples?" New topic
Author

What is Service layer in J2ee design Princples?

Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
Hi All,

I am curious about what all there in service layers ?

is is business logic or what else?

Usually Client http request --> Action Servlet controller --> Action class called --> Service class --> DAO --> DAOImpl --> DB call

what services class contains?

Thanks,
Prabhat
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Yes, it is business logic. The action is meant to only deal with UI functions. The DAO is meant to deal with only database functions. The thing in between is the service layer.

I think you have a typo in your diagram. You have the service layer in two places.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
Yes it was type...i removed it in one place. thanks Jean..
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9383
    
    2

Have a look here:

http://corej2eepatterns.com/

There are different names that people use to call different tiers in a typical enterprise application. A service layer or otherwise a business logic layer is where you write the business rules / process which is the backbone of what you are developing. The reason being that when your business rule or process changes, you only have to change it in only one place.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
Thanks Joe..

I also investigated and below is the understanding

Action calls -> Controller Action Servlet class --> calls the service method of BO( like getCustomerService() of class CustomerService for BO Customer) --> calls DAO in this case it is CustomerDAO interface for getCustomer() method --> calls DAOImpl in this case CustomerDAOImpl (DB connection and persistence logic) --> DB calls

Controller Servlet --> free to ask about the service of BO( Customer) that is getCustomerDetails etc..
Customer POJO --> used as DTO to hold the data and nothing knows about the controller,DAO or Service Layer
Service Layer --> contains the service calls including business logic as per business requirement or validation at this level just to check the instance is customer or not before persisting the data into db.
Persistence layer --> connection to db , update,save,select query using either JDBC,JDBCtemplate,Hibernate,JPA

let me know if my understanding is better than last time.

Thanks,
Prabhat
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9383
    
    2

Prabhat Ranjan wrote:Thanks Joe..

let me know if my understanding is better than last time.

Thanks,
Prabhat


It is!
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
somthing more if we have EJB then it will come to service layer to use some business logic for application.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Service layer in J2ee design Princples?