Typical web application architecture with Spring

Spring has been the framework of choice to wire Java Enterprise applications during the last decade and half. Applications used a layered architecture with all cross-cutting concerns being managed using aspect-oriented programming. The following diagram shows a typical architecture for a web application developed with Spring:

The typical layers in such an application are listed here. We will list cross-cutting concerns as a separate layer, though in reality, they are applicable across all layers:

  • Web layer: This is typically responsible for controlling the web application flow (controller and/or Front Controller) and rendering the view.
  • Business layer: This is where all your business logic is written. Most applications have transaction management starting from the business layer.
  • Data layer: It is also responsible for talking to the database. This is responsible for persisting/retrieving data in Java objects to the tables in the database.
  • Integration layer: Applications talk to other applications, either over queues or by invoking web services. The integration layer establishes such connections with other applications.
  • Cross-cutting concerns: These are concerns across different layers--logging, security, transaction management, and so on. Since Spring IoC container manages the beans, it can weave these concerns around the beans through Aspect-oriented programming (AOP).

Let's discuss each of the layers and the frameworks used in more detail.