
Beginning Spring
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions

Persons
Content
INTRODUCTION xxxi
CHAPTER 1: POJO PROGRAMMING MODEL, LIGHTWEIGHT CONTAINERS, AND INVERSION OF CONTROL 1
CHAPTER 2: DEPENDENCY INJECTION WITH SPRING 17
CHAPTER 3: BUILDING WEB APPLICATIONS USING SPRING MVC 63
CHAPTER 4: JDBC DATA ACCESS WITH SPRING 103
CHAPTER 5: DATA ACCESS WITH JPA USING SPRING 137
CHAPTER 6: MANAGING TRANSACTIONS WITH SPRING 175
CHAPTER 7: TEST?]DRIVEN DEVELOPMENT WITH SPRING 209
CHAPTER 8: ASPECT?]ORIENTED PROGRAMMING WITH SPRING 237
CHAPTER 9: SPRING EXPRESSION LANGUAGE 263
Configuring Applications with SpEL 268
CHAPTER 10: CACHING 285
CHAPTER 11: RESTFUL WEB SERVICES WITH SPRING 305
CHAPTER 12: SECURING WEB APPLICATIONS WITH SPRING SECURITY 331
CHAPTER 13: NEXT STOP: SPRING 4.0 369
APPENDIX: SOLUTIONS TO EXERCISES 385
INDEX 425
INTRODUCTION
THE SPRING FRAMEWORK IS AN OPEN SOURCE ENTERPRISE APPLICATION framework licensed under Apache License version 2.0, which provides an extensive toolset for building applications that meet the enterprise demands. The idea itself came about because doing development with J2EE (the former version of Java Enterprise Edition) introduced a good deal of complexity in the enterprise world. Creating and deploying beans with Enterprise Java Beans (EJB) was a burden because, to create one bean, you had to create home and component interfaces along with the bean definition. Because the concept of dependency injection was also missing in the EJB world at those times, the lookup approach was the only way to find objects or resources.
The first version of the Spring Framework was based on the code published within Expert One-on-One J2EE Design and Development without EJB (Wrox, 2004) by Rod Johnson and Jürgen Höller. The main idea for the book was to reduce this complexity of enterprise application development with EJBs that was introduced to the EE world with J2EE. The first version of Spring was released in 2002, and milestone releases followed in 2004 and 2005. Version 1.0 brought the lightweight application framework along with features including JDBC abstraction, object relational mapping tools support, transaction management, scheduling and mail abstraction implementations, and the Model View Controller (MVC) web framework.
The 2.0 and 3.0 releases introduced important features to the framework, such as AspectJ support and REST support. At the time of writing this book, version 4.0 was released, and it now complies with the specifications provided by Java Enterprise Edition 7 and with Java 8 Standard Edition, which are the latest versions of Java. Within the book we also try to cover the features of the framework that ships with this latest edition.
Spring gained popularity with its core Dependency Injection (DI) pattern, which is also known as Inversion of Control (IoC). Because object-oriented programming introduces relationships between the objects, the DI approach tries to achieve a loose-coupled design by extracting the management of these dependencies to lead to an easy and manageable implementation. Another spectacular feature of Spring is provided by aspect-oriented programming (AOP), which offers an elegant approach to implementing the cross-cutting concerns in your application. Every web application is in need of features such as exception management, authentication and authorization, logging, and caching. The DI and AOP concepts are covered in detail in Chapters 2 and 8, respectively.
With the help of these major features, Spring provides easily testable, reusable code with no vendor lock-in because it can be ported easily between application servers such as WebLogic, JBoss, and Tomcat. With its layered architecture, it addresses different parts of complex enterprise application development.
We can definitely say that the Spring Framework has become the de facto standard for developing Java enterprise applications. In this book you will find all of the major features brought to the enterprise world by the framework.
WHO THIS BOOK IS FOR
As the book's title states, this book covers the Spring Framework on a beginner level, and it touches on intermediate concepts wherever needed. It explains what the framework offers and also illustrates the content by showing how these features actually work with comprehensive samples. The material presented within the book is suitable for Enterprise application developers who haven't tried the Spring Framework yet or who don't know the details of its core or the subprojects. The book will also be helpful to middle-level management, who will be enlightened about the ingredients of enterprise application development and will get to taste the different flavors of the Spring Framework.
We assume that readers have some knowledge of Java language principles and the ability to develop Java code with integrated development environments (IDEs) such as Eclipse, NetBeans, or others.
This book might not be suitable for people who are not familiar with the Java language and basic object-oriented programming concepts. We also believe that the book might be of no interest for readers who are not keen on the enterprise application development world with Java.
WHAT THIS BOOK COVERS
Spring provides a comprehensive configuration model, both with XML and Java annotations. Throughout the book we demonstrate both annotation-based configuration and XML-based configuration so that we give all the possible configuration scenarios.
The book first focuses on the core concepts and features of the Spring Framework. You take a look at the basic concepts, such as the non-invasive Plain Old Java Object (POJO) programming model approach, and then we define the Dependency Injection pattern (Inversion of Control). Spring also provides a Model View Controller implementation to build web applications; we cover the provided features in detail. The Java Database Connectivity and Java Persistence API features of the Spring Framework are also covered along with the transaction mechanism that it provides. We then focus on what Spring provides for doing test-driven development. Next we cover aspect-oriented programming for giving the reader insight on how Spring handles the implementation for cross-cutting concerns of a system. Spring Expression Languages, caching, and RESTful web services provide extensive features of the Spring Framework, and we cover them with real-world examples that will get you started on development within minutes. Then we dive into Spring Security, which became a de facto standard for applying security constraints on enterprise applications.
The final chapter wraps up the book with the latest features provided by version 4.0 of the framework. We describe the best of the breed because the book covers the major features of Spring by focusing on the latest version of the framework.
The following sections give you just a little bit of detail about what's covered in the 13 chapters of this book.
Dependency Injection and Configuration of Spring
This book covers the core concepts of the Spring Framework such as DI (which is also known as IoC) and its configuration model. The object-oriented programming principles depict having relationships between the objects that are instantiated. The main objective of the DI pattern is to separate the behaviors of those objects from the way that they depend on each other. That way the tenet of loose coupling is achieved with favoring usability and maintainability of the code. The idea of DI originated with Martin Fowler and has become very popular and widely adopted. It's also implemented within popular frameworks such as PicoContainer, Guice, and Spring.
The DI pattern resembles other patterns such as Factory or Strategy. We can say that with the Factory pattern the instantiation of objects is still within the responsibility of the Factory definition, which is your code, but with the DI it's externalized to another component/framework. On the other hand, with the Strategy pattern, the current implementation gets replaced with the help of multiple objects of a same interface, which contain that implementation inside. However, with the DI, the objects that contain those implementations are wired regardless of the implementation defined.
As of version 2.0 of the Spring Framework, the DI mechanism was being configured with the XML schemas along with the support of custom namespaces. As of version 2.5, Spring leveraged the use of Java 5 and the annotations to support auto discovery of components, annotation-driven autowiring of those components, and the life-cycle annotations to hook initialization and destruction callbacks. We cover all of these annotations introduced by the framework.
Spring 4.0
Chapter 13 covers the cutting-edge features of the latest version of Spring. Version 4.0 supports Java 8 with features like lambda expressions and method expressions. It also provides annotation-driven date formatting for the new DateTime API. Version 4.0 also complies with Java EE 7 specifications such as JPA 2.1, JMS 2.0, JTA 1.2, Bean Validation 1.1, and others. We demonstrate these features to give you insight about the best of breed of the most recent version.
Spring Annotations
Spring provides XML-based and annotation-based configuration mainly for dependency injection and also for the other features of the framework. We give the traditional XML configurations with the samples to show the complexity and the burden that they put on the developer. Throughout the book, we favor annotations wherever possible to ease your way and also to make the examples comprehensible in a practical way. We have tried to cover all of the annotations provided by the framework within the samples.
As of Spring 2.5, the JSR-250 Annotations API is also supported. It's the Java Specification Request that has the scope for annotation development, so it makes Spring more compliant with the EE edition of Java.
Spring Persistency Support with JDBC, JPA, and ORM
Spring provides an abstraction to the developers for JDBC database access. It eases development by reducing the boilerplate code for connection management, exception/transaction handling, and preparation and execution of the statements.
Spring...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.