Announcement Announcement Module
No announcement yet.
Layerd Architecture Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Layerd Architecture

    Hi Guys,

    I am new to Spring and just started a project. In there i have decided to use 3 layes web, Service and DAO. So method callings should be from web to Service
    and then service to DAO. In here i need to use business logic from another service. So can we call one service from another service. Or do we have to write that service class as another utility class. what is the best practise for above scenario. your help will be appriciated


  • #2
    Per se, there is nothing wrong with calling one service from another. Yet there are a few things to look out for:
    - Invoking a service method often starts (and ends) a transaction. Make sure you don't start a new transaction, when you invoke a service method from within a service method. This could lead to inconsistencies
    - A utility class might be easier for maintenance in the long run. There is simply less code to look at in case of changes.
    - Needing the same functionality in two places is a strong hint to put that functionality into the domain model if possible or into an aspect or a proxy.



    • #3

      great post, it really helped me alot…gives me alot of information… thanks…. nice job…
      Credit Repair | Bad Credit Repair Report