Spring_in_Action_Fo_v1_MEAP (1).pdf

(1413 KB) Pobierz
MEAP Edition
Manning Early Access Program
Spring in Action 4E version 1
Copyright 2013 Manning Publications
For more information on this and other Manning titles go to
www.manning.com
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=837
Licensed to Andy Piper <andypiperuk@gmail.com>
brief contents
P
ART
1: C
ORE
S
PRING
1. Springing into Action
2. Wiring Beans
3. Advanced bean wiring
4. Aspect-oriented Spring
P
ART
2: S
PRING ON THE
W
EB
5. Building web apps with Spring MVC
6. Spring web views
7. Advanced Spring MVC
8. Working with Spring Web Flow
9. Securing Spring Web
P
ART
3: S
PRING IN THE
B
ACKEND
10. Persisting data with Spring and JDBC
11. Spring and ORM
12. Working with Schema-less Data
13. Caching data
14. Securing Methods
P
ART
4: I
NTEGRATING
S
PRING
15. Working with remote services
16. Creating REST APIs with Spring MVC
17. Consuming REST APIs
18. Messaging with Spring
19. Sending emails with Spring
20. Managing Spring Beans with JMX
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=837
Licensed to Andy Piper <andypiperuk@gmail.com>
1
Springing into action
1
This chapter covers
Exploring Spring’s core modules
Decoupling application objects
Managing cross-cutting concerns with AOP
Spring’s bean container
It all started with a bean.
In 1996, the Java programming language was still a young, exciting,
up-and-coming platform. Many developers flocked to the language because they’d
seen how to create rich and dynamic web applications using applets. They soon
learned that there was more to this strange new language than animated juggling
cartoon characters. Unlike any language before it, Java made it possible to write
complex applications made up of discrete parts. They came for the applets, but
they stayed for the components.
In December of that year, Sun Microsystems published the JavaBeans 1.00-A
specification. JavaBeans defined a software component model for Java. This
specification defined a set of coding policies that enabled simple Java objects to be
reusable and easily composed into more complex applications. Although
JavaBeans were intended as a general-purpose means of defining reusable
application components, they were primarily used as a model for building user
interface widgets. They seemed too simple to be capable of any "real" work.
Enterprise developers wanted more.
Sophisticated applications often require services such as transaction support,
security, and distributed computing—services not directly provided by the
JavaBeans specification. So in March 1998, Sun published version 1.0 of the
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=837
Licensed to Andy Piper <andypiperuk@gmail.com>
2
Enterprise JavaBeans (EJB) specification. This specification extended the notion of
Java components to the server side, providing much-needed enterprise services, but
failed to continue the simplicity of the original JavaBeans specification. Except in
name, EJB bears little resemblance to the original JavaBeans specification.
Despite the fact that many successful applications have been built based on the
original EJB specs, EJB failed to achiev its intended purpose: to simplify enterprise
application development. It’s true that EJB’s declarative programming model
simplified many infrastructural aspects of development, such as transactions and
security. But in a different way, EJBs complicated development by mandating
deployment descriptors and plumbing code (home and remote/local interfaces).
Over time, many developers became disenchanted with EJB. As a result, its
popularity declined, leaving many developers looking for an easier way.
Today, Java component development has returned to its roots. New
programming techniques, including aspect-oriented programming (AOP) and
dependency injection (DI), are giving JavaBeans much of the power previously
reserved for EJBs. These techniques furnish plain-old Java objects (POJOs) with a
declarative programming model reminiscent of EJB, but without all of EJB’s
complexity. No longer must you resort to writing an unwieldy EJB component
when a simple JavaBean will suffice.
In fairness, even EJBs have evolved to promote a POJO-based programming
model. Employing ideas such as DI and AOP, the latest EJB specification is
significantly simpler than its predecessors. But for many developers, this move is
too little, too late. By the time the EJB 3 specification had entered the scene, other
POJO-based development frameworks had already established themselves as de
facto standards in the Java community and in many ways had advanced beyond
EJB's capabilities.
An early leader in the movement to lightweight POJO-based development was
the Spring Framework. Arguably, Spring served as the catalyst for POJO-oriented
development in Java, leading to other frameworks and specifications adhering to
simpler development models. Now that Spring is over 10 years old, it continues to
lead the charge toward simplifying Java development.
This book is an exploration of the Spring Framework and several Spring-related
projects. In this chapter, we’ll examine the Spring Framework at a high level,
giving you a taste of what Spring is about. This chapter will give you a good idea
of the types of problems Spring solves, and will set the stage for the rest of the
book. First things first—let’s find out what Spring is all about.
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=837
Licensed to Andy Piper <andypiperuk@gmail.com>
Zgłoś jeśli naruszono regulamin