Monday, December 27, 2010

Design and develop a reference J2EE Architecture (Struts 2.0, Spring 3.0, and Hibernate 3.0)

Goal: Design and develop a reference J2EE Architecture using current Java/JEE open source frameworks/DB/Servers which can be used as a quick reference for small to medium size enterprise applications.

Architecture:
               
Clients:
 Client can be
  1. Browser access though Struts 2 interface.
  2. Swing Application through Spring Remote Services
  3. .NET application connected through web services.
  4. Other applications can interact through web services.
Presentation/Interface Layer :
 This layer can have different modules to expose the business services in different modes.
1. Struts 2 can be used by browser client and is main interface.
2. Services can be exposed as DWR services so any UI with JavaScript capability can access business services.
3. Services can be exposed as Remote Service using Sprint Remote and other java client or Swing applications can use this interface.
4. Services can be exposed as web services for other clients.
5. Presentation layer (Struts 2)responsible for Authentication, Authorization, calling business logic through service layer, view preparation and dispatch response.
6. For Authentication and Authorization we can use Spring ACGI security module for Struts 2.
7. Service layer POJO objects will be injected by Spring 3 into Struts 2 Action classes.
Service Layer:
1. Service layer will be responsible to provide one method for each use case for different modules.
2. Handle authentication and authorization when called from other than presentation layer.
3. Transaction management will use Spring 3 transaction strategy. Business and Integration layers will not do any transaction related activities.
4. Hibernate transaction manager will be injected by Spring3 in this layer.
5. Audit logging will be handled by this layer.
6. This layer POJOs can be exposed as web service or remote services using Spring3.
7. This layer will also be responsible for validation of incoming information but only when request is coming from other than presentation layer because presentation layer will have their own validation mechanism using Apache validator framework.
8. All validations will be applied on methods using Spring3 method interceptors.
Business Layer:
1. All business logic will be implemented in this layer without considering transaction management and other concerns.
2. DAO will be used to save the objects states to database or main frames.
3. DAO objects will be injected by Spring 3 into a DAO adoptor which will call DAO interface implementation objects.
4. No Direct call to DB, JMS or web services to get/update/insert the information from this layer.
5. If need to interact with JMS or web service call integration layer.
Integration Layer:
1. This layer will be responsible for all data access related activities.
2. Interaction with Database thorough JPA/JDBC, Web Services and Message broker (JMS). We can use any JPA implementaion like Hibernate, TopLink, Eclipse etc.
Framework/Technologies and servers:
1. Java/J2EE
2. Struts 2.2.1
3. Spring 3.0
4. Hibernate 3.0 /JPA
5. Tomcat 6.0/Glassfish
6. MySQL as Database

3 comments:

  1. Hai,
    Your blog gives clear idea about web framework and its functionality. I appreciate your knowledge sharing. Will you send your email Id to my id: arun05bca@gmail.com

    Thanks in advance,
    Regards: Arun Balachandren

    ReplyDelete
  2. Explanation is clear and nice. Could you please send some demo application based on spring+Hibernate+Struts2 to my mail id: shaileshsaxena12@gmail.com . Thanks in advance.

    ReplyDelete