Announcement Announcement Module
Collapse
No announcement yet.
Business Layer for Web Applicatin projects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Business Layer for Web Applicatin projects

    Hi all,

    We generated a web project using Spring Roo. It's pretty awesome since a lot of work is done automatically. I now was wondering, if it's possible to force Spring Roo to use a business layer?

    Right now the Spring Controllers access directly the domain models (Data Layer). We would like to use a layer in between to handle the business logic, since we don't want to do it in the web controllers. The reason for that is that we plan to offer a web service in the near future. So it would make sense that both the web application and the web service access the service components. Additionally we don't have to duplicate logic and security constraints.

  • #2
    While I like the same pattern you describe I believe that the roo philosophy is that the logic should go on the domain objects. Your WS would be reusing the business logic this way.

    Comment


    • #3
      Roo can't generate a Services layer for you at this stage (I can't see how they could add much other than placeholder logic to it anyway), but there is nothing stopping you from adding one.

      For an app thats going to be large enough, not adding the business logic to the Entities can make a lot of sense. What some people don't seem to have grasped in that the Roo Entity classes are both simultanously ActiveRecord and JavaBean. While design for these are both often abused, they are both intended to be primarily Data Transfer Objects (DTO's).

      If you do put business logic in them, you have to watch out for a bunch of traps, especially around the use of javabeans. Many things that act on javabeans expect to be able to call getX on everything, so you never want to add a business method with that name. RooToStrings and Xml/Json serializers especially. (In both cases you can annotate to have them avoid it)

      Comment

      Working...
      X