Java Reference
In-Depth Information
MVC also contains a view management layer (not shown for simplicity), which is respon-
sible for locating an appropriate view (which may be another JSP). It also binds the data
objects returned by the page controllers after invoking the model objects in the business
tier and finally dispatches the HTTP response to the client. All the objects that are
responsible for view management, controller management, and the page controllers
themselves are registered in the underlying Spring IOC container. Thus, all the benefits of
this container are available to the Spring MVC module. Note that the gateway servlet is
not part of the Spring IOC container; rather, it is managed by the web server.
Spring MVC is a versatile module and supports almost any view and model technol-
ogy available. If your development team is more confident with Java Server Faces ( JSF) or
Struts, for example, it is quite possible to integrate these frameworks with Spring MVC.
You can very well use template-based view engines such as Velocity and FreeMarker;
document-based views such as PDF, Microsoft Word, and Microsoft Excel; and rich user
interfaces provided by Adobe Flex. As far as the model is concerned, Spring MVC not only
gels well with POJO business components, but it goes equally well with distributed EJB
components.
Business Tier
With Spring you can develop business components as plain Java classes without any
framework dependency. This is in complete contrast to the EJB programming model,
which demands the implementation of several different interfaces along with deploy-
ment descriptors, making life complicated for the developer.
The POJO business objects are all configured in the Spring IOC container just like
any other bean shown in earlier examples. They are responsible for executing business
rules, and in the process they manipulate application data using the data access API
available in the integration tier.
The Spring AOP module plays a significant role in the business tier. It can be used to
declaratively apply and control transaction and security on the POJO business compo-
nents.
It is possible to utilize Spring AOP to develop custom aspects that collect audit trail
information or instrument method execution time without affecting the existing applica-
tion code.
It is possible to develop a mixed solution with Spring POJO and EJBs. Spring IOC
implements the service locator pattern (to be discussed in Chapter 4) to look up (pull DI)
the EJB home interfaces and then injects those objects into the POJO business objects.
Note that the system-level services provided by the EJB container are now available to the
application. In this scenario, the Spring Framework played the role of an EJB client using
a session bean. Spring also helps with EJB implementation through convenient super-
classes. We will delve into this in greater detail as part of the Spring business layer
patterns in Chapter 4.
 
Search WWH ::




Custom Search