Java Reference
In-Depth Information
Service Layer
The service layer consists of the business tier components of Java EE such as Enterprise JavaBeans
(EJBs). The service layer can access the data access layer, but there should be no tight coupling
between the service layer and the data access layer. In fact, the service layer should not know
anything about the web or data access layer. The service layer provides a coarse-grained interface
for the web layer.
Data Access Layer
The data access layer consists of the data tier components of Java EE such as JDBC and JPA. This
layer should not contain any business logic. This layer abstracts the actual persistence mechanism
(in other words, JDBC or JPA) from the service layer by providing the coarse-grained interface to the
service layer.
Note The call flow in this architecture is always from the top layer to the bottom layer. In other words, the
service layer should be able to call the data access layer but not vice versa.
In this chapter, you will build the data access layer of the bookstore application and query it via a
stand-alone Java application. In Chapter 2, you will replace this stand-alone Java application with
a web layer using the web tier components of Java EE (specifically, servlets and JSPs). You will
use this data access layer throughout this topic, and from Chapter 4 onward you will build a web
application repeatedly by rebuilding the web layer using different web frameworks.
Oracle and the Java Community Process (JCP) provide standardized enterprise components, and if
successful enterprise applications can be built using these components, then why do we need web
frameworks? What are web frameworks for? The next section answers these questions.
Java Web Frameworks
While Java EE does a great job of standardizing the enterprise infrastructure, providing an
application model, and providing components adequate to develop web applications, two major
problems are associated with it.
Interacting directly with the Java EE components often results in massive
boilerplate code and even code redundancy.
Creating an enterprise application using the Java EE infrastructure is a nontrivial
task that requires a great deal of expertise. The team members usually involved
in creating an enterprise Java EE application act in varied roles, and all of them
may not have the level of expertise that meets the Java EE criteria.
Frameworks address these two major problems (and several other concerns discussed in detail in
Chapter 3). Table 1-4 describes the web frameworks you will learn about in this topic.
 
 
Search WWH ::




Custom Search