• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

What is Service layer in J2ee design Princples?

 
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 39840
797
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it was type...i removed it in one place. thanks Jean..
 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prabhat Ranjan wrote:Thanks Joe..

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

Thanks,
Prabhat



It is!
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somthing more if we have EJB then it will come to service layer to use some business logic for application.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!